From dcec47abcf9ebf7921358a77aed321e8594d8db2 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Mon, 31 Mar 2014 01:42:56 +1100 Subject: [PATCH] Add activation welcome and notices close #21 --- assets/css/activation.css | 72 ++++- assets/css/admin.css | 2 +- assets/images/welcome/sp-badge.png | Bin 0 -> 8855 bytes includes/admin/class-sp-admin-notices.php | 8 +- includes/admin/class-sp-admin-settings.php | 89 +++++ includes/admin/class-sp-admin-welcome.php | 303 ++++++++++++++++++ includes/admin/class-sp-admin.php | 2 +- .../settings/class-sp-settings-config.php | 94 +----- .../settings/class-sp-settings-events.php | 12 - .../settings/class-sp-settings-general.php | 7 + includes/admin/sp-admin-functions.php | 1 + includes/admin/views/html-notice-install.php | 6 +- includes/class-sp-install.php | 34 +- includes/class-sp-sports.php | 2 +- includes/sp-core-functions.php | 11 +- includes/sp-template-hooks.php | 2 +- readme.txt | 49 ++- 17 files changed, 540 insertions(+), 154 deletions(-) create mode 100644 assets/images/welcome/sp-badge.png create mode 100644 includes/admin/class-sp-admin-welcome.php diff --git a/assets/css/activation.css b/assets/css/activation.css index ba609291..a12adb6c 100644 --- a/assets/css/activation.css +++ b/assets/css/activation.css @@ -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"; } \ No newline at end of file diff --git a/assets/css/admin.css b/assets/css/admin.css index fe277d49..9ad86436 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -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 { diff --git a/assets/images/welcome/sp-badge.png b/assets/images/welcome/sp-badge.png new file mode 100644 index 0000000000000000000000000000000000000000..4e532400b495d88e2eab3c46a0b940b66098a049 GIT binary patch literal 8855 zcmV;IB52)-P)K;^H0}Qy?XD}z2Ez{``>#N+qNME zC`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bE%H62K+^gx<-jS1gVmecl;tab8?E{%(YSaXh%O^Fh_`) zL&BQiRG-t5xu72{5f3&|7P%B3Zj}T}Vq`A|y%Px&ld^?`1Xq}^5?>*X=@7*i4G*&+ z2wRq<95^X$V#RFYPtw4qU$m{df*WzZHuTm>*lCioi6{4hg@h`_RL$c1{UAOo2asDL z87UQTY8@0pFp(Bg2&w3IX z;FQnhT#YIbzYlm@PN7w5L;Mt*Ld?E1|Bbn`B1_| zGNE@A$96sZibtTM_6a)MXz3DJwoDBBZ+bYwX=+Kos9R3KO$JW71#o5-WL=ST90g^7 zvn)?4mMoLtX0ih$rRE}_BxSm26K$pup@kL-u~xP#0yhWQ7ovC~Y7xbtNtuP-{HT`D zpOx^pd_(oHt0brxlwTRgpUjdcIY+K31D!E|(2!!-(2nrEddR>d7f}xK@o)*J$JMe$!=z zgPq6M1|g{MNo9~TW||U^I2&A%mix8vL8ImiMcSYOPCAL^yl8r9jyy1QZ6k>>BBhvH ztq`r%Zw^Kh-_8mdP-RgomWkHXWmk=t`4&s@g-xIqVqPn3gr5Z`xywY!D=iV!EmS z8D)VjiFHOwF|jKOln6vqA=;26C!$>ce9TEHe7C5kGOP*D#~`HiBgYu-h4>2)ZB0l~ zJ7>Vk+$Eg}8K%id != 'settings_page_sportspress' ) { + if ( get_option( '_sp_needs_welcome' ) == 1 && $screen->id != 'settings_page_sportspress' ) { include( 'views/html-notice-install.php' ); } } diff --git a/includes/admin/class-sp-admin-settings.php b/includes/admin/class-sp-admin-settings.php index f71818e2..5a83aed8 100644 --- a/includes/admin/class-sp-admin-settings.php +++ b/includes/admin/class-sp-admin-settings.php @@ -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; diff --git a/includes/admin/class-sp-admin-welcome.php b/includes/admin/class-sp-admin-welcome.php new file mode 100644 index 00000000..c65f4c4f --- /dev/null +++ b/includes/admin/class-sp-admin-welcome.php @@ -0,0 +1,303 @@ +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'; + ?> + + version, 0, 3 ); + ?> +

+ +
+ +
+ +
version ); ?>
+ +

+ + + +

+ + + + +
+ + intro(); ?> + + + +
+

+ + 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 ); + ?> +
+

+
+ +
+
+
+

+ countries->continents; + ?> +

+ +

+

+ 'sportspress_sport', + 'default' => 'soccer', + 'type' => 'select', + 'class' => $class, + 'options' => $sport_options, + )); + SP_Admin_Settings::output_fields( $settings ); + ?> +

+ + + +

+
+
+
+

+
    +
  • +
  • +
  • +
+
+
+

+

Translate SportsPress.', 'sportspress' ); ?>

+ ' . $handle . ''; + endforeach; + ?> +

+ +

+
+
+
+ +
+ +
+
+ $data ): - $sport_options[ $slug ] = $data['name']; - endforeach; - - if ( ! get_option( 'sportspress_sport' ) ) - $sport_options = array_merge( array( 0 => __( '— Select —', '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; diff --git a/includes/admin/settings/class-sp-settings-events.php b/includes/admin/settings/class-sp-settings-events.php index 993bb1f3..f9610250 100644 --- a/includes/admin/settings/class-sp-settings-events.php +++ b/includes/admin/settings/class-sp-settings-events.php @@ -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' ), diff --git a/includes/admin/settings/class-sp-settings-general.php b/includes/admin/settings/class-sp-settings-general.php index d7edf834..1561031b 100644 --- a/includes/admin/settings/class-sp-settings-general.php +++ b/includes/admin/settings/class-sp-settings-general.php @@ -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 ); diff --git a/includes/admin/sp-admin-functions.php b/includes/admin/sp-admin-functions.php index fcfeac95..6e39f3bc 100644 --- a/includes/admin/sp-admin-functions.php +++ b/includes/admin/sp-admin-functions.php @@ -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', diff --git a/includes/admin/views/html-notice-install.php b/includes/admin/views/html-notice-install.php index 2f5348c6..dde91010 100644 --- a/includes/admin/views/html-notice-install.php +++ b/includes/admin/views/html-notice-install.php @@ -2,9 +2,9 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
-

Welcome to SportsPress – Get Started', 'sportspress' ); ?>

+

version ); ?>

- - + +

\ No newline at end of file diff --git a/includes/class-sp-install.php b/includes/class-sp-install.php index a590bf23..40432bc8 100644 --- a/includes/class-sp-install.php +++ b/includes/class-sp-install.php @@ -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 ); } /** diff --git a/includes/class-sp-sports.php b/includes/class-sp-sports.php index 9806cff1..13774bd0 100644 --- a/includes/class-sp-sports.php +++ b/includes/class-sp-sports.php @@ -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 ) { diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index 2699a181..2199c4ff 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -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 diff --git a/includes/sp-template-hooks.php b/includes/sp-template-hooks.php index 01058baf..8a3cca67 100644 --- a/includes/sp-template-hooks.php +++ b/includes/sp-template-hooks.php @@ -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' ) ): diff --git a/readme.txt b/readme.txt index 23a3651e..5e9e1ec5 100644 --- a/readme.txt +++ b/readme.txt @@ -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.