Add activation welcome and notices close #21

This commit is contained in:
Brian Miyaji
2014-03-31 01:42:56 +11:00
parent 87e0c574f4
commit dcec47abcf
17 changed files with 540 additions and 154 deletions

View File

@@ -1,12 +1,14 @@
/* Messages */
.sportspress-message {
border-left-color: #6bc2a5 !important;
border-left-color: #00a69c !important;
}
.sportspress-message a.button-primary,
.sportspress-message a.button-secondary {
background: #6bc2a5;
border-color: #409e7f;
.sportspress-message a.button-secondary,
p.sportspress-actions input.button-primary,
p.sportspress-actions input.button-primary:active {
background: #3bbab3;
border-color: #15a29a;
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
color: #fff;
@@ -14,9 +16,11 @@
}
.sportspress-message a.button-primary:hover,
.sportspress-message a.button-secondary:hover {
background: #3bad87;
border-color: #338a6d;
.sportspress-message a.button-secondary:hover,
p.sportspress-actions input.button-primary:hover,
p.sportspress-actions input.button-primary:focus {
background: #00a69c;
border-color: #009187;
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
box-shadow: inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);
color: #fff;
@@ -27,4 +31,58 @@
-moz-opacity: 0.7;
opacity: 0.7;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
}
.sp-feature a {
text-decoration: none;
}
.sp-feature p.sportspress-actions {
margin-top: 16px;
}
.about-sportspress-wrap div.updated {
display: block!important;
}
.about-sportspress-wrap .changelog .sportspress-steps {
margin-top: 24px;
}
.about-sportspress-wrap .changelog .sportspress-steps li {
line-height: 16px;
list-style-type: none;
margin-left: 0;
}
.about-sportspress-wrap .changelog .sportspress-steps li a {
display: block;
padding: 0 0 8px;
background: transparent!important;
}
.sportspress-steps .welcome-icon:before {
font: 400 20px/1 "sportspress";
speak: none;
display: inline-block;
padding: 0 10px 0 0;
top: -1px;
position: relative;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-decoration: none!important;
vertical-align: top;
color: #888;
}
.sportspress-steps .welcome-add-team:before {
content: "\f334";
}
.sportspress-steps .welcome-add-player:before {
content: "\f307";
}
.sportspress-steps .welcome-add-event:before {
content: "\f145";
}

View File

@@ -77,7 +77,7 @@
.sportspress table.form-table fieldset p.description {
margin-bottom: 8px;
}
.sportspress table.sp-admin-config-table .edit {
.sp-admin-config-table .edit {
text-align: right;
}
.sportspress table.form-table .sp-color-box {

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@@ -37,17 +37,13 @@ class SP_Admin_Notices {
* Add notices + styles if needed.
*/
public function add_notices() {
if ( get_option( '_sp_needs_config' ) == 1 ) {
if ( get_option( '_sp_needs_welcome' ) == 1 ) {
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ) );
add_action( 'admin_notices', array( $this, 'install_notice' ) );
}
$notices = get_option( 'sportspress_admin_notices', array() );
if ( isset( $_GET['skip_install_sportspress'] ) ):
update_option( '_sp_needs_config', $_GET['_sp_needs_config'] ? 0 : 1 );
endif;
if ( ! empty( $_GET['hide_theme_support_notice'] ) ) {
$notices = array_diff( $notices, array( 'theme_support' ) );
update_option( 'sportspress_admin_notices', $notices );
@@ -80,7 +76,7 @@ class SP_Admin_Notices {
$screen = get_current_screen();
// If we have just installed, show a message with the install pages button
if ( get_option( '_sp_needs_config' ) == 1 && $screen->id != 'settings_page_sportspress' ) {
if ( get_option( '_sp_needs_welcome' ) == 1 && $screen->id != 'settings_page_sportspress' ) {
include( 'views/html-notice-install.php' );
}
}

View File

@@ -597,6 +597,95 @@ class SP_Admin_Settings {
return true;
}
/**
* Configure sport
*
* @access public
* @return void
*/
public static function configure_sport( $sport ) {
// Get array of taxonomies to insert
$term_groups = sp_array_value( $sport, 'term', array() );
foreach( $term_groups as $taxonomy => $terms ):
// Find empty terms and destroy
$allterms = get_terms( $taxonomy, 'hide_empty=0' );
foreach( $allterms as $term ):
if ( $term->count == 0 )
wp_delete_term( $term->term_id, $taxonomy );
endforeach;
// Insert terms
foreach( $terms as $term ):
wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) );
endforeach;
endforeach;
// Get array of post types to insert
$post_groups = sp_array_value( $sport, 'posts', array() );
// Loop through each post type
foreach( $post_groups as $post_type => $posts ):
$args = array(
'post_type' => $post_type,
'numberposts' => -1,
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => '_sp_preset',
'value' => 1
)
)
);
// Delete posts
$old_posts = get_posts( $args );
foreach( $old_posts as $post ):
wp_delete_post( $post->ID, true);
endforeach;
// Add posts
foreach( $posts as $index => $post ):
// Make sure post doesn't overlap
if ( ! get_page_by_path( $post['post_name'], OBJECT, $post_type ) ):
// Translate post title
$post['post_title'] = __( $post['post_title'], 'sportspress' );
// Set post type
$post['post_type'] = $post_type;
// Increment menu order by 2 and publish post
$post['menu_order'] = $index * 2 + 2;
$post['post_status'] = 'publish';
$id = wp_insert_post( $post );
// Flag as preset
update_post_meta( $id, '_sp_preset', 1 );
// Update meta
if ( array_key_exists( 'meta', $post ) ):
foreach ( $post['meta'] as $key => $value ):
update_post_meta( $id, $key, $value );
endforeach;
endif;
// Update terms
if ( array_key_exists( 'tax_input', $post ) ):
foreach ( $post['tax_input'] as $taxonomy => $terms ):
wp_set_object_terms( $id, $terms, $taxonomy, false );
endforeach;
endif;
endif;
endforeach;
endforeach;
update_option( 'sportspress_primary_result', 0 );
}
}
endif;

View File

@@ -0,0 +1,303 @@
<?php
/**
* Welcome Page Class
*
* Shows a feature overview for the new version (major) and credits.
*
* Adapted from code in EDD (Copyright (c) 2012, Pippin Williamson) and WP.
*
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 0.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* SP_Admin_Welcome class.
*/
class SP_Admin_Welcome {
private $plugin;
/**
* __construct function.
*
* @access public
* @return void
*/
public function __construct() {
$this->plugin = 'sportspress/sportspress.php';
add_action( 'admin_menu', array( $this, 'admin_menus') );
add_action( 'admin_head', array( $this, 'admin_head' ) );
add_action( 'admin_init', array( $this, 'welcome' ) );
}
/**
* Add admin menus/screens
*
* @access public
* @return void
*/
public function admin_menus() {
$welcome_page_title = __( 'Welcome to SportsPress', 'sportspress' );
// About
$about = add_dashboard_page( $welcome_page_title, $welcome_page_title, 'manage_options', 'sp-about', array( $this, 'about_screen' ) );
add_action( 'admin_print_styles-'. $about, array( $this, 'admin_css' ) );
}
/**
* admin_css function.
*
* @access public
* @return void
*/
public function admin_css() {
wp_enqueue_style( 'sportspress-activation', plugins_url( '/assets/css/activation.css', SP_PLUGIN_FILE ), array(), SP_VERSION );
}
/**
* Add styles just for this page, and remove dashboard page links.
*
* @access public
* @return void
*/
public function admin_head() {
remove_submenu_page( 'index.php', 'sp-about' );
remove_submenu_page( 'index.php', 'sp-translators' );
// Badge for welcome page
$badge_url = SP()->plugin_url() . '/assets/images/welcome/sp-badge.png';
?>
<style type="text/css">
/*<![CDATA[*/
.sp-badge {
position: relative;;
background: #2f4265 url(<?php echo $badge_url; ?>) no-repeat center top;
text-rendering: optimizeLegibility;
padding-top: 160px;
height: 42px;
width: 165px;
font-size: 14px;
text-align: center;
color: #e6e7e8;
margin: 5px 0 0 0;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,.2);
box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.about-wrap .sp-badge {
position: absolute;
top: 0;
right: 0;
}
.about-wrap .sp-feature {
overflow: visible !important;
*zoom:1;
}
.about-wrap .sp-feature:before,
.about-wrap .sp-feature:after {
content: " ";
display: table;
}
.about-wrap .sp-feature:after {
clear: both;
}
.about-wrap .feature-rest div {
width: 50% !important;
padding-right: 100px;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0 !important;
}
.about-wrap .feature-rest div.last-feature {
padding-left: 100px;
padding-right: 0;
}
.about-integrations {
background: #fff;
margin: 20px 0;
padding: 1px 20px 10px;
}
/*]]>*/
</style>
<?php
}
/**
* Into text/links shown on all about pages.
*
* @access private
* @return void
*/
private function intro() {
// Flush after upgrades
if ( ! empty( $_GET['sp-updated'] ) || ! empty( $_GET['sp-installed'] ) )
flush_rewrite_rules();
// Drop minor version if 0
$major_version = substr( SP()->version, 0, 3 );
?>
<h1><?php printf( __( 'Welcome to SportsPress!', 'sportspress' ), $major_version ); ?></h1>
<div class="about-text sportspress-about-text">
<?php
if ( ! empty( $_GET['sp-installed'] ) )
$message = __( 'Thanks, all done!', 'sportspress' );
elseif ( ! empty( $_GET['sp-updated'] ) )
$message = __( 'Thank you for updating to the latest version!', 'sportspress' );
else
$message = __( 'Thanks for installing!', 'sportspress' );
printf( __( '%s SportsPress %s is more powerful, stable, and secure than ever before. We hope you enjoy it.', 'sportspress' ), $message, $major_version );
?>
</div>
<div class="sp-badge"><?php printf( __( 'Version %s', 'sportspress' ), SP()->version ); ?></div>
<p class="sportspress-actions">
<?php if ( false ): ?><a href="<?php echo admin_url( add_query_arg( array( 'page' => 'sportspress' ), 'options-general.php' ) ); ?>" class="button button-primary"><?php _e( 'Settings', 'sportspress' ); ?></a><?php endif; ?>
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://ow.ly/vaGUv" data-text="An open-source (free) #WordPress plugin that helps you build professional league websites." data-via="ThemeBoy" data-size="large" data-hashtags="SportsPress">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</p>
<?php if ( false ): ?>
<h2 class="nav-tab-wrapper">
<a class="nav-tab <?php if ( $_GET['page'] == 'sp-about' ) echo 'nav-tab-active'; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-about' ), 'index.php' ) ) ); ?>">
<?php _e( 'Get Started', 'sportspress' ); ?>
</a><a class="nav-tab <?php if ( $_GET['page'] == 'sp-translators' ) echo 'nav-tab-active'; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sp-translators' ), 'index.php' ) ) ); ?>">
<?php _e( 'Translators', 'sportspress' ); ?>
</a>
</h2>
<?php
endif;
}
/**
* Output the about screen.
*/
public function about_screen() {
include_once( 'class-sp-admin-settings.php' );
?>
<div class="wrap about-wrap about-sportspress-wrap">
<?php $this->intro(); ?>
<!--<div class="changelog point-releases"></div>-->
<div class="changelog">
<h3><?php _e( 'Get Started', 'sportspress' ); ?></h3>
<?php
// Save settings
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
$sport = SP()->sports->$_POST['sportspress_sport'];
SP_Admin_Settings::configure_sport( $sport );
update_option( 'sportspress_sport', $_POST['sportspress_sport'] );
endif;
if ( isset( $_POST['sportspress_default_country'] ) ):
update_option( 'sportspress_default_country', $_POST['sportspress_default_country'] );
update_option( '_sportspress_needs_welcome', 1 );
?>
<div id="message" class="updated sportspress-message">
<p><strong><?php _e( 'Your settings have been saved.', 'sportspress' ); ?></strong></p>
</div>
<?php endif; ?>
<div class="sp-feature feature-section col three-col">
<div>
<form method="post" id="mainform" action="" enctype="multipart/form-data">
<h4><?php _e( 'Base Location', 'sportspress' ); ?></h4>
<?php
$selected = (string) get_option( 'sportspress_default_country', 'AU' );
$continents = SP()->countries->continents;
?>
<p>
<select name="sportspress_default_country" data-placeholder="<?php _e( 'Choose a country&hellip;', 'sportspress' ); ?>" title="Country" class="chosen-select<?php if ( is_rtl() ): ?> chosen-rtl<?php endif; ?>">
<?php SP()->countries->country_dropdown_options( $selected ); ?>
</select>
</p>
<h4><?php printf( __( 'Select %s', 'sportspress' ), __( 'Sport', 'sportspress' ) ); ?></h4>
<?php
$sport_options = sp_get_sport_options();
$class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
$settings = array( array(
'id' => 'sportspress_sport',
'default' => 'soccer',
'type' => 'select',
'class' => $class,
'options' => $sport_options,
));
SP_Admin_Settings::output_fields( $settings );
?>
<p class="submit sportspress-actions">
<input name="save" class="button-primary" type="submit" value="<?php _e( 'Save changes', 'sportspress' ); ?>" />
<input type="hidden" name="subtab" id="last_tab" />
<?php wp_nonce_field( 'sportspress-settings' ); ?>
</p>
</form>
</div>
<div>
<h4><?php _e( 'Next Steps', 'sportspress' ); ?></h4>
<ul class="sportspress-steps">
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_team' ), 'post-new.php' ) ) ); ?>" class="welcome-icon welcome-add-team"><?php _e( 'Add New Team', 'sportspress' ); ?></a></li>
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_player' ), 'post-new.php' ) ) ); ?>" class="welcome-icon welcome-add-player"><?php _e( 'Add New Player', 'sportspress' ); ?></a></li>
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'post-new.php' ) ) ); ?>" class="welcome-icon welcome-add-event"><?php _e( 'Add New Event', 'sportspress' ); ?></a></li>
</ul>
</div>
<div class="last-feature">
<h4><?php _e( 'Translators', 'sportspress' ); ?></h4>
<p><?php _e( 'SportsPress has been kindly translated into several other languages thanks to our translation team. Want to see your name? <a href="https://www.transifex.com/projects/p/sportspress/">Translate SportsPress</a>.', 'sportspress' ); ?></p>
<?php
$translator_handles = array( 'Abdulelah', 'aylaview', 'Bhelpful2', 'JensZ', 'karimjarro', 'Spirossmil', 'ThemeBoy' );
$translator_links = array();
foreach ( $translator_handles as $handle ):
$translator_links[] = '<a href="https://www.transifex.com/accounts/profile/' . $handle . '">' . $handle . '</a>';
endforeach;
?>
<p class="wp-credits-list">
<?php echo implode( ', ', $translator_links ); ?>
</p>
</div>
</div>
</div>
<div class="return-to-dashboard">
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress' ), 'options-general.php' ) ) ); ?>"><?php _e( 'Go to SportsPress Settings', 'sportspress' ); ?></a>
</div>
</div>
<?php
}
/**
* Sends user to the welcome page on first activation
*/
public function welcome() {
// Bail if no activation redirect transient is set
if ( ! get_transient( '_sp_activation_redirect' ) )
return;
// Delete the redirect transient
delete_transient( '_sp_activation_redirect' );
// Bail if we are waiting to install or update via the interface update/install links
if ( get_option( '_sp_needs_update' ) == 1 || get_option( '_sp_needs_pages' ) == 1 )
return;
// Bail if activating from network, or bulk, or within an iFrame
if ( is_network_admin() || isset( $_GET['activate-multi'] ) || defined( 'IFRAME_REQUEST' ) )
return;
if ( ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] ) && ( isset( $_GET['plugin'] ) && strstr( $_GET['plugin'], 'sportspress.php' ) ) )
return;
wp_redirect( admin_url( 'index.php?page=sp-about' ) );
exit;
}
}
new SP_Admin_Welcome();

View File

@@ -38,7 +38,7 @@ class SP_Admin {
// Classes we only need if the ajax is not-ajax
if ( ! is_ajax() ) {
include( 'class-sp-admin-menus.php' );
// include( 'class-sp-admin-welcome.php' );
include( 'class-sp-admin-welcome.php' );
include( 'class-sp-admin-notices.php' );
include( 'class-sp-admin-assets.php' );
include( 'class-sp-admin-permalink-settings.php' );

View File

@@ -41,13 +41,6 @@ class SP_Settings_Config extends SP_Settings_Page {
*/
public function get_settings() {
$sports = sp_get_sport_options();
$sport_options = array();
foreach ( $sports as $slug => $data ):
$sport_options[ $slug ] = $data['name'];
endforeach;
if ( ! get_option( 'sportspress_sport' ) )
$sport_options = array_merge( array( 0 => __( '&mdash; Select &mdash;', 'sportspress' ) ), $sport_options );
return apply_filters('sportspress_event_settings', array(
@@ -58,7 +51,7 @@ class SP_Settings_Config extends SP_Settings_Page {
'id' => 'sportspress_sport',
'default' => 'soccer',
'type' => 'select',
'options' => $sport_options,
'options' => $sports,
),
array( 'type' => 'results' ),
@@ -83,90 +76,9 @@ class SP_Settings_Config extends SP_Settings_Page {
*/
public function save() {
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
$sport = SP()->sports->$_POST['sportspress_sport'];
// Get array of taxonomies to insert
$term_groups = sp_array_value( $sport, 'term', array() );
foreach( $term_groups as $taxonomy => $terms ):
// Find empty terms and destroy
$allterms = get_terms( $taxonomy, 'hide_empty=0' );
foreach( $allterms as $term ):
if ( $term->count == 0 )
wp_delete_term( $term->term_id, $taxonomy );
endforeach;
// Insert terms
foreach( $terms as $term ):
wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) );
endforeach;
endforeach;
// Get array of post types to insert
$post_groups = sp_array_value( $sport, 'posts', array() );
// Loop through each post type
foreach( $post_groups as $post_type => $posts ):
$args = array(
'post_type' => $post_type,
'numberposts' => -1,
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => '_sp_preset',
'value' => 1
)
)
);
// Delete posts
$old_posts = get_posts( $args );
foreach( $old_posts as $post ):
wp_delete_post( $post->ID, true);
endforeach;
// Add posts
foreach( $posts as $index => $post ):
// Make sure post doesn't overlap
if ( ! get_page_by_path( $post['post_name'], OBJECT, $post_type ) ):
// Translate post title
$post['post_title'] = __( $post['post_title'], 'sportspress' );
// Set post type
$post['post_type'] = $post_type;
// Increment menu order by 2 and publish post
$post['menu_order'] = $index * 2 + 2;
$post['post_status'] = 'publish';
$id = wp_insert_post( $post );
// Flag as preset
update_post_meta( $id, '_sp_preset', 1 );
// Update meta
if ( array_key_exists( 'meta', $post ) ):
foreach ( $post['meta'] as $key => $value ):
update_post_meta( $id, $key, $value );
endforeach;
endif;
// Update terms
if ( array_key_exists( 'tax_input', $post ) ):
foreach ( $post['tax_input'] as $taxonomy => $terms ):
wp_set_object_terms( $id, $terms, $taxonomy, false );
endforeach;
endif;
endif;
endforeach;
endforeach;
update_option( 'sportspress_primary_result', 0 );
update_option( '_sp_needs_config', 0 );
SP_Admin_Settings::configure_sport( $sport );
update_option( '_sp_needs_welcome', 0 );
elseif ( isset( $_POST['sportspress_primary_result'] ) ):
update_option( 'sportspress_primary_result', $_POST['sportspress_primary_result'] );
endif;

View File

@@ -40,18 +40,6 @@ class SP_Settings_Events extends SP_Settings_Page {
$settings = array(
array( 'title' => __( 'Event Options', 'sportspress' ), 'type' => 'title','desc' => '', 'id' => 'event_options' ),
array(
'title' => __( 'Number of Teams', 'sportspress' ),
'id' => 'sportspress_event_num_teams',
'class' => 'small-text',
'default' => '2',
'type' => 'number',
'custom_attributes' => array(
'min' => 0,
'step' => 1
)
),
array( 'type' => 'delimiter' ),

View File

@@ -112,6 +112,13 @@ class SP_Settings_General extends SP_Settings_Page {
* Save settings
*/
public function save() {
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
$sport = SP()->sports->$_POST['sportspress_sport'];
SP_Admin_Settings::configure_sport( $sport );
update_option( 'sportspress_sport', $_POST['sportspress_sport'] );
update_option( '_sp_needs_welcome', 0 );
endif;
$settings = $this->get_settings();
SP_Admin_Settings::save_fields( $settings );

View File

@@ -17,6 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
*/
function sp_get_screen_ids() {
return apply_filters( 'sportspress_screen_ids', array(
'dashboard_page_sp-about',
'settings_page_sportspress',
'edit-sp_result',
'sp_result',

View File

@@ -2,9 +2,9 @@
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
<div id="message" class="updated sportspress-message">
<p><?php _e( '<strong>Welcome to SportsPress</strong> &#8211; Get Started', 'sportspress' ); ?></p>
<p><strong><?php printf( __( 'Welcome to SportsPress %s', 'sportspress' ), SP()->version ); ?></strong></p>
<p class="submit">
<a class="button-primary" href="<?php echo admin_url('options-general.php?page=sportspress&tab=config'); ?>"><?php _e( 'Configure SportsPress', 'sportspress' ); ?></a>
<a class="button-secondary" href="<?php echo add_query_arg('skip_install_sportspress', 'true' ); ?>"><?php _e( 'Skip setup', 'sportspress' ); ?></a>
<a class="button-primary" href="<?php echo admin_url( add_query_arg( array( 'page' => 'sp-about', 'install_sportspress' => 'true' ), 'index.php' ) ); ?>"><?php _e( "Get Started", 'sportspress' ); ?></a>
<a class="button-secondary" href="<?php echo add_query_arg('skip_install_sportspress', 'true' ); ?>"><?php _e( 'Hide this notice', 'sportspress' ); ?></a>
</p>
</div>

View File

@@ -50,34 +50,25 @@ class SP_Install {
if ( ! empty( $_GET['install_sportspress'] ) ) {
// We no longer need to install pages
delete_option( '_sp_needs_pages' );
delete_option( '_sp_needs_welcome' );
delete_transient( '_sp_activation_redirect' );
// What's new redirect
wp_redirect( admin_url( 'index.php?page=sp-about&sp-installed=true' ) );
exit;
//wp_redirect( admin_url( 'index.php?page=sp-about&sp-installed=true' ) );
//exit;
// Skip button
} elseif ( ! empty( $_GET['skip_install_sportspress'] ) ) {
// We no longer need to install pages
delete_option( '_sp_needs_pages' );
// We no longer need to install configs
delete_option( '_sp_needs_welcome' );
delete_transient( '_sp_activation_redirect' );
// What's new redirect
wp_redirect( admin_url( 'index.php?page=sp-about' ) );
exit;
//wp_redirect( admin_url( 'index.php?page=sp-about' ) );
//exit;
// Update button
} elseif ( ! empty( $_GET['do_update_sportspress'] ) ) {
// Update complete
delete_option( '_sp_needs_update' );
delete_transient( '_sp_activation_redirect' );
// What's new redirect
wp_redirect( admin_url( 'index.php?page=sp-about&sp-updated=true' ) );
exit;
}
}
@@ -85,7 +76,6 @@ class SP_Install {
* Install SP
*/
public function install() {
$this->create_options();
$this->create_roles();
// Register post types
@@ -93,6 +83,8 @@ class SP_Install {
SP_Post_types::register_post_types();
SP_Post_types::register_taxonomies();
$this->create_options();
// Queue upgrades
$current_version = get_option( 'sportspress_version', null );
@@ -101,7 +93,7 @@ class SP_Install {
// Check if pages are needed
if ( ! get_option( 'sportspress_sport' ) ) {
update_option( '_sp_needs_config', 1 );
update_option( '_sp_needs_welcome', 1 );
}
// Flush rules after install
@@ -132,6 +124,12 @@ class SP_Install {
}
}
}
// Configure default sport
$sport = 'soccer';
$options = sp_get_sport_presets();
SP_Settings_Config::configure_sport( $options[ $sport ] );
update_option( 'sportspress_sport', $sport );
}
/**

View File

@@ -22,7 +22,7 @@ class SP_Sports {
* @return void
*/
public function __construct() {
$this->data = sp_get_sport_options();
$this->data = sp_get_sport_presets();
}
public function __get( $key ) {

View File

@@ -2998,7 +2998,7 @@ if ( !function_exists( 'sp_highlight_admin_menu' ) ) {
* Get an array of sport options and settings.
* @return array
*/
function sp_get_sport_options() {
function sp_get_sport_presets() {
return apply_filters( 'sportspress_sports', array(
'baseball' => array(
'name' => __( 'Baseball', 'sportspress' ),
@@ -5240,6 +5240,15 @@ function sp_get_sport_options() {
));
}
function sp_get_sport_options() {
$sports = sp_get_sport_presets();
$options = array();
foreach ( $sports as $slug => $data ):
$options[ $slug ] = $data['name'];
endforeach;
return $options;
}
/**
* Get an array of text options per context.
* @return array

View File

@@ -49,7 +49,7 @@ function sportspress_admin_notices_styles() {
if ( $screen->id != 'settings_page_sportspress' ):
if ( isset( $_REQUEST['skip_install_sportspress'] ) ):
update_option( '_sp_needs_config', $_REQUEST['_sp_needs_config'] );
update_option( '_sp_needs_welcome', $_REQUEST['_sp_needs_welcome'] );
endif;
if ( ! get_option( 'sportspress_installed' ) ):

View File

@@ -78,15 +78,15 @@ Automatic updates should work like a charm; as always though, ensure you backup
If on the off-chance you do encounter issues with the event/team/player/staff pages after an update you simply need to flush the permalinks by going to WordPress > Settings > Permalinks and hitting 'save'. That should return things to normal.
= General Settings =
== Configuration ==
= Sport =
SportsPress comes with settings for some sports that you can apply by going to WordPress > Settings > SportsPress. By selecting a sport, presets will be applied to Events, League Tables, and Players.
= Event Settings =
= Results =
Manage the results and outcomes you would like to track for each event.
Main Result is the default result that will be displayed in the admin list.
Main Result is the default result that will be displayed in the admin list when an event has been played.
Results are the values that you want to keep track of and display on your event pages. In Association Football, for example, typical results are "1st half", "2nd half", and "Goals". For Baseball, you would have 9+ "Innings", "Hits", "Runs", and "Errors".
@@ -94,7 +94,11 @@ To add a new result, go to Settings > SportsPress > Results > Add New. Enter a n
The "Key" is the variable name used in league table calculations and will be automatically generated when you create a new result, but you can also change this. The Order Attribute is the order that your result will be displayed among your other results.
= League Table Settings =
= Outcomes =
Outcomes are very similar to results but you can only have one outcome per team per event. An outcome determines the ultimate result (win, draw, loss, etc.) of an event. Examples of outcomes are: W, D, L, and OT.
= Columns =
Manage the columns you would like to calculate and display in league tables.
@@ -113,15 +117,13 @@ Sort Order is for the way you want to sort your League Table. You can create and
As an example, in Association Football, Pts would be 1 descending, and GD would be 2 descending. This means that the leading team is the team with the most points, then the highest goal difference (GD).
Outcomes are very similar to results but you can only have one outcome per team per event. An outcome determines the ultimate result (win, draw, loss, etc.) of an event. Examples of outcomes are: W, D, L, and OT.
= Metrics =
= Player Settings =
Metrics are static values associated with players, and are useful for variables like height, weight, hobbies, etc. that will be displayed on player profile pages. When you create a new metric, remember to select the position(s) that the metric applies to or it will not show up in player profiles. Metrics are independent of leagues, seasons, and teams.
Manage the metrics and statistics you would like to track for each player.
= Performance =
Metrics are useful for variables like their height, weight, hobbies, etc. that will be displayed on player profile pages. When you create a new metric, remember to select the position(s) that the metric applies to or it will not show up in player profiles. Metrics are independent of leagues, seasons, and teams.
Statistics are for keeping track of the performance variables like goals, assists, yellow cards, and red cards. They are displayed on player profile pages, event pages, and player lists. Each player will have their own set of statistics for each event and league per season. You can choose whether to calculate the total or average of each variable by selecting from the “Calculate” dropdown menu. Be sure to select the position(s) that each statistic applies to so it shows up on the appropriate players' profile pages.
Performance is for keeping track of the performance variables like goals, assists, yellow cards, and red cards. They are displayed on player profile pages, event pages, and player lists. Each player will have their own set of statistics for each event and league per season. You can choose whether to calculate the total or average of each variable by selecting from the “Calculate” dropdown menu. Be sure to select the position(s) that each statistic applies to so it shows up on the appropriate players' profile pages.
== Frequently Asked Questions ==
@@ -154,6 +156,29 @@ SportsPress is currently in beta and is undergoing testing. We are still activel
== Changelog ==
= 0.7 =
* Feature - Welcome page to display on activation.
* Feature - Frontend color scheme selection.
* Feature - Custom CSS option.
* Feature - Add venue column to event list.
* Feature - Manual point adjustments added to league tables.
* Feature - Enable table pagination.
* Feature - Enable live countdown setting.
* Refactor - Only load required classes to improve performance.
* Refactor - Change statistic to performance.
* Refactor - Soft deprecate sportspress prefixed functions in favor of sp prefix.
* Tweak - Filter players in events by current team.
* Tweak - Separate admin styles to improve load times.
* Tweak - Add margin above view all link in widgets.
* Tweak - Group text options by context.
* Tweak - Display event details in standard table markup for style consistency.
* Tweak - Display venue as a table for style consistency.
* Tweak - Hide individual player performance when players not selected.
* Fix - Responsive league table glitch.
* Fix - Warning messages when adding new team, player, or event.
* Fix - Countdown widget when event is selected.
* Fix - Multiple select box height glitch in some browsers fixed.
= 0.6.2 =
* Feature - Add options to make tables responsive and sortable.
* Feature - Use consistent shortcode naming with backwards compatibility.