From 514e3d4da43dcfa8154e37d141b3d271b3080b28 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Mon, 24 Mar 2014 19:24:54 +1100 Subject: [PATCH] Change Statistic to Performance --- admin/hooks/admin-head.php | 2 +- admin/hooks/post-updated-messages.php | 2 +- admin/hooks/pre-get-posts.php | 2 +- admin/hooks/sanitize-title.php | 2 +- admin/hooks/save-post.php | 12 +- admin/hooks/the-content.php | 10 +- admin/post-types/calendar.php | 2 +- admin/post-types/column.php | 3 +- admin/post-types/directory.php | 4 +- admin/post-types/event.php | 10 +- admin/post-types/list.php | 4 +- admin/post-types/metric.php | 3 +- admin/post-types/outcome.php | 3 +- .../{statistic.php => performance.php} | 31 +-- admin/post-types/player.php | 10 +- admin/post-types/result.php | 3 +- admin/post-types/separator.php | 3 +- admin/post-types/staff.php | 2 +- admin/post-types/table.php | 2 +- admin/post-types/team.php | 4 +- admin/settings/options-event.php | 32 +-- admin/settings/options-player.php | 14 +- ...t-statistics.php => event-performance.php} | 22 +- admin/templates/player-gallery.php | 10 +- ...tics.php => player-league-performance.php} | 10 +- admin/templates/player-list.php | 14 +- admin/templates/player-performance.php | 22 ++ admin/templates/player-roster.php | 14 +- admin/templates/player-statistics.php | 22 -- admin/terms/position.php | 2 +- admin/tools/event-importer.php | 26 +-- admin/widgets/player-gallery.php | 2 +- admin/widgets/player-list.php | 28 +-- assets/js/admin.js | 2 +- assets/js/sportspress.js | 2 +- functions.php | 194 +++++++++--------- presets/sports/baseball.php | 2 +- presets/sports/basketball.php | 2 +- presets/sports/cricket.php | 2 +- presets/sports/football.php | 2 +- presets/sports/footy.php | 2 +- presets/sports/gaming.php | 2 +- presets/sports/golf.php | 2 +- presets/sports/hockey.php | 2 +- presets/sports/racing.php | 2 +- presets/sports/rugby.php | 2 +- presets/sports/soccer.php | 2 +- sportspress.php | 9 +- 48 files changed, 284 insertions(+), 277 deletions(-) rename admin/post-types/{statistic.php => performance.php} (55%) rename admin/templates/{event-statistics.php => event-performance.php} (81%) rename admin/templates/{player-league-statistics.php => player-league-performance.php} (71%) create mode 100644 admin/templates/player-performance.php delete mode 100644 admin/templates/player-statistics.php diff --git a/admin/hooks/admin-head.php b/admin/hooks/admin-head.php index edc49bdd..7c908c76 100644 --- a/admin/hooks/admin-head.php +++ b/admin/hooks/admin-head.php @@ -1,7 +1,7 @@ query['post_type']; - if ( in_array( $post_type, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic' ) ) ): + if ( in_array( $post_type, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance' ) ) ): $query->set( 'orderby', 'menu_order' ); $query->set( 'order', 'ASC' ); elseif ( $post_type == 'sp_event' ): diff --git a/admin/hooks/sanitize-title.php b/admin/hooks/sanitize-title.php index de2f641e..f18538e9 100644 --- a/admin/hooks/sanitize-title.php +++ b/admin/hooks/sanitize-title.php @@ -5,7 +5,7 @@ function sportspress_sanitize_title( $title ) { return $title; - elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic', 'sp_metric' ) ) ): + elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric' ) ) ): $key = isset( $_POST['sp_key'] ) ? $_POST['sp_key'] : null; diff --git a/admin/hooks/save-post.php b/admin/hooks/save-post.php index 47632c6f..53ff0c5a 100644 --- a/admin/hooks/save-post.php +++ b/admin/hooks/save-post.php @@ -11,7 +11,7 @@ function sportspress_save_post( $post_id ) { // Update leagues seasons to show update_post_meta( $post_id, 'sp_leagues_seasons', sportspress_array_value( $_POST, 'sp_leagues_seasons', array() ) ); - // Update player statistics array + // Update team columns array if ( current_user_can( 'edit_sp_tables' ) ) update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) ); @@ -25,7 +25,7 @@ function sportspress_save_post( $post_id ) { // Update results update_post_meta( $post_id, 'sp_results', $results ); - // Update player statistics + // Update player performance update_post_meta( $post_id, 'sp_players', sportspress_array_value( $_POST, 'sp_players', array() ) ); // Update team array @@ -109,7 +109,7 @@ function sportspress_save_post( $post_id ) { break; - case ( 'sp_statistic' ): + case ( 'sp_performance' ): // Delete posts with duplicate key sportspress_delete_duplicate_post( $_POST ); @@ -142,9 +142,9 @@ function sportspress_save_post( $post_id ) { // Update player metrics array update_post_meta( $post_id, 'sp_metrics', sportspress_array_value( $_POST, 'sp_metrics', array() ) ); - // Update player statistics array + // Update player performance array if ( current_user_can( 'edit_sp_teams' ) ) - update_post_meta( $post_id, 'sp_statistics', sportspress_array_value( $_POST, 'sp_statistics', array() ) ); + update_post_meta( $post_id, 'sp_performance', sportspress_array_value( $_POST, 'sp_performance', array() ) ); break; @@ -176,7 +176,7 @@ function sportspress_save_post( $post_id ) { case ( 'sp_list' ): - // Update statistics array + // Update performance array update_post_meta( $post_id, 'sp_columns', sportspress_array_value( $_POST, 'sp_columns', array() ) ); // Update players array diff --git a/admin/hooks/the-content.php b/admin/hooks/the-content.php index 3033d7fa..170f5f66 100644 --- a/admin/hooks/the-content.php +++ b/admin/hooks/the-content.php @@ -11,7 +11,7 @@ function sportspress_default_event_content( $content ) { if ( is_singular( 'sp_event' ) && in_the_loop() ): $details = sportspress_event_details(); $results = sportspress_event_results(); - $statistics = sportspress_event_statistics(); + $performance = sportspress_event_performance(); $staff = sportspress_event_staff(); $id = get_the_ID(); $video_url = get_post_meta( $id, 'sp_video', true ); @@ -22,10 +22,10 @@ function sportspress_default_event_content( $content ) { $video = ''; endif; if ( $results ): - $content = $video . $results . $details . $statistics . $staff . $content; + $content = $video . $results . $details . $performance . $staff . $content; else: $venue = sportspress_event_venue(); - $content = $video . $details . $venue . $statistics . $staff . $content; + $content = $video . $details . $venue . $performance . $staff . $content; endif; endif; return $content; @@ -87,8 +87,8 @@ add_filter( 'the_content', 'sportspress_default_table_content' ); function sportspress_default_player_content( $content ) { if ( is_singular( 'sp_player' ) && in_the_loop() ): $metrics = sportspress_player_metrics(); - $statistics = sportspress_player_statistics(); - $content .= $metrics . $statistics; + $performance = sportspress_player_performance(); + $content .= $metrics . $performance; endif; return $content; } diff --git a/admin/post-types/calendar.php b/admin/post-types/calendar.php index f6fb8abb..09623bc8 100644 --- a/admin/post-types/calendar.php +++ b/admin/post-types/calendar.php @@ -22,7 +22,7 @@ function sportspress_calendar_post_init() { 'rewrite' => array( 'slug' => get_option( 'sportspress_calendar_slug', 'calendar' ) ), 'show_in_menu' => 'edit.php?post_type=sp_event', 'show_in_admin_bar' => true, - 'capability_type' => 'sp_calendar' + 'capability_type' => 'sp_calendar', ); register_post_type( 'sp_calendar', $args ); } diff --git a/admin/post-types/column.php b/admin/post-types/column.php index c1af2edd..a351b944 100644 --- a/admin/post-types/column.php +++ b/admin/post-types/column.php @@ -19,9 +19,10 @@ function sportspress_column_post_init() { 'show_in_menu' => false, 'has_archive' => false, 'hierarchical' => false, + 'can_export' => false, 'supports' => array( 'title', 'page-attributes' ), 'register_meta_box_cb' => 'sportspress_column_meta_init', - 'capability_type' => 'sp_config' + 'capability_type' => 'sp_config', ); register_post_type( 'sp_column', $args ); } diff --git a/admin/post-types/directory.php b/admin/post-types/directory.php index b500cbd9..7496ac44 100644 --- a/admin/post-types/directory.php +++ b/admin/post-types/directory.php @@ -22,7 +22,7 @@ function sportspress_directory_post_init() { 'rewrite' => array( 'slug' => get_option( 'sportspress_directory_slug', 'directory' ) ), 'show_in_menu' => 'edit.php?post_type=sp_player', 'show_in_admin_bar' => true, - 'capability_type' => 'sp_directory' + 'capability_type' => 'sp_directory', ); register_post_type( 'sp_directory', $args ); } @@ -125,7 +125,7 @@ function sportspress_directory_details_meta( $post ) { 'name' => __( 'Name', 'sportspress' ), 'eventsplayed' => __( 'Played', 'sportspress' ) ), - 'post_type' => 'sp_statistic', + 'post_type' => 'sp_performance', 'name' => 'sp_orderby', 'selected' => $orderby, 'values' => 'slug', diff --git a/admin/post-types/event.php b/admin/post-types/event.php index e1a19328..37c657d5 100644 --- a/admin/post-types/event.php +++ b/admin/post-types/event.php @@ -22,7 +22,7 @@ function sportspress_event_post_init() { 'register_meta_box_cb' => 'sportspress_event_meta_init', 'rewrite' => array( 'slug' => get_option( 'sportspress_events_slug', 'events' ) ), 'menu_icon' => 'dashicons-calendar', - 'capability_type' => 'sp_event' + 'capability_type' => 'sp_event', ); register_post_type( 'sp_event', $args ); } @@ -74,7 +74,7 @@ function sportspress_event_meta_init( $post ) { do_action( 'sportspress_event_meta_init' ); if ( sizeof( $players ) > 0 ) - add_meta_box( 'sp_statisticsdiv', __( 'Statistics', 'sportspress' ), 'sportspress_event_statistics_meta', 'sp_event', 'normal', 'high' ); + add_meta_box( 'sp_performancediv', __( 'Performance', 'sportspress' ), 'sportspress_event_performance_meta', 'sp_event', 'normal', 'high' ); add_meta_box( 'sp_articlediv', __( 'Article', 'sportspress' ), 'sportspress_event_article_meta', 'sp_event', 'normal', 'high' ); } @@ -214,12 +214,12 @@ function sportspress_event_video_meta( $post ) { ID, 'sp_team', false ); $stats = (array)get_post_meta( $post->ID, 'sp_players', true ); - // Get columns from statistic variables - $columns = sportspress_get_var_labels( 'sp_statistic' ); + // Get columns from performance variables + $columns = sportspress_get_var_labels( 'sp_performance' ); foreach ( $teams as $key => $team_id ): if ( ! $team_id ) continue; diff --git a/admin/post-types/list.php b/admin/post-types/list.php index 94643a64..5a39f285 100644 --- a/admin/post-types/list.php +++ b/admin/post-types/list.php @@ -22,7 +22,7 @@ function sportspress_list_post_init() { 'rewrite' => array( 'slug' => get_option( 'sportspress_list_slug', 'list' ) ), 'show_in_menu' => 'edit.php?post_type=sp_player', 'show_in_admin_bar' => true, - 'capability_type' => 'sp_list' + 'capability_type' => 'sp_list', ); register_post_type( 'sp_list', $args ); } @@ -136,7 +136,7 @@ function sportspress_list_details_meta( $post ) { 'name' => __( 'Name', 'sportspress' ), 'eventsplayed' => __( 'Played', 'sportspress' ) ), - 'post_type' => 'sp_statistic', + 'post_type' => 'sp_performance', 'name' => 'sp_orderby', 'selected' => $orderby, 'values' => 'slug', diff --git a/admin/post-types/metric.php b/admin/post-types/metric.php index 71311a51..ee56e73f 100644 --- a/admin/post-types/metric.php +++ b/admin/post-types/metric.php @@ -19,8 +19,9 @@ function sportspress_metric_post_init() { 'show_in_menu' => false, 'has_archive' => false, 'hierarchical' => false, + 'can_export' => false, 'supports' => array( 'title', 'page-attributes' ), - 'capability_type' => 'sp_config' + 'capability_type' => 'sp_config', ); register_post_type( 'sp_metric', $args ); } diff --git a/admin/post-types/outcome.php b/admin/post-types/outcome.php index e20b8450..4b4644b7 100644 --- a/admin/post-types/outcome.php +++ b/admin/post-types/outcome.php @@ -19,9 +19,10 @@ function sportspress_outcome_post_init() { 'show_in_menu' => false, 'has_archive' => false, 'hierarchical' => false, + 'can_export' => false, 'supports' => array( 'title', 'page-attributes' ), 'register_meta_box_cb' => 'sportspress_outcome_meta_init', - 'capability_type' => 'sp_config' + 'capability_type' => 'sp_config', ); register_post_type( 'sp_outcome', $args ); } diff --git a/admin/post-types/statistic.php b/admin/post-types/performance.php similarity index 55% rename from admin/post-types/statistic.php rename to admin/post-types/performance.php index 5cff1933..0d446c3c 100644 --- a/admin/post-types/statistic.php +++ b/admin/post-types/performance.php @@ -1,10 +1,10 @@ __( 'Statistics', 'sportspress' ), - 'singular_name' => __( 'Statistic', 'sportspress' ), - 'add_new_item' => __( 'Add New Statistic', 'sportspress' ), - 'edit_item' => __( 'Edit Statistic', 'sportspress' ), + 'name' => __( 'Performance', 'sportspress' ), + 'singular_name' => __( 'Performance', 'sportspress' ), + 'add_new_item' => __( 'Add New Performance', 'sportspress' ), + 'edit_item' => __( 'Edit Performance', 'sportspress' ), 'new_item' => __( 'New', 'sportspress' ), 'view_item' => __( 'View', 'sportspress' ), 'search_items' => __( 'Search', 'sportspress' ), @@ -12,22 +12,23 @@ function sportspress_statistic_post_init() { 'not_found_in_trash' => __( 'No results found.', 'sportspress' ), ); $args = array( - 'label' => __( 'Statistics', 'sportspress' ), + 'label' => __( 'Performance', 'sportspress' ), 'labels' => $labels, 'public' => false, 'show_ui' => true, 'show_in_menu' => false, 'has_archive' => false, 'hierarchical' => false, + 'can_export' => false, 'supports' => array( 'title', 'page-attributes' ), - 'register_meta_box_cb' => 'sportspress_statistic_meta_init', - 'capability_type' => 'sp_config' + 'register_meta_box_cb' => 'sportspress_performance_meta_init', + 'capability_type' => 'sp_config', ); - register_post_type( 'sp_statistic', $args ); + register_post_type( 'sp_performance', $args ); } -add_action( 'init', 'sportspress_statistic_post_init' ); +add_action( 'init', 'sportspress_performance_post_init' ); -function sportspress_statistic_edit_columns() { +function sportspress_performance_edit_columns() { $columns = array( 'cb' => '', 'title' => __( 'Label', 'sportspress' ), @@ -36,13 +37,13 @@ function sportspress_statistic_edit_columns() { ); return $columns; } -add_filter( 'manage_edit-sp_statistic_columns', 'sportspress_statistic_edit_columns' ); +add_filter( 'manage_edit-sp_performance_columns', 'sportspress_performance_edit_columns' ); -function sportspress_statistic_meta_init() { - add_meta_box( 'sp_equationdiv', __( 'Details', 'sportspress' ), 'sportspress_statistic_equation_meta', 'sp_statistic', 'normal', 'high' ); +function sportspress_performance_meta_init() { + add_meta_box( 'sp_equationdiv', __( 'Details', 'sportspress' ), 'sportspress_performance_equation_meta', 'sp_performance', 'normal', 'high' ); } -function sportspress_statistic_equation_meta( $post ) { +function sportspress_performance_equation_meta( $post ) { $calculate = get_post_meta( $post->ID, 'sp_calculate', true ); ?>

diff --git a/admin/post-types/player.php b/admin/post-types/player.php index 44c94d6a..a73b3160 100644 --- a/admin/post-types/player.php +++ b/admin/post-types/player.php @@ -56,7 +56,7 @@ function sportspress_player_meta_init( $post ) { add_meta_box( 'sp_metricsdiv', __( 'Metrics', 'sportspress' ), 'sportspress_player_metrics_meta', 'sp_player', 'side', 'default' ); if ( $leagues && ! empty( $leagues ) && $seasons && ! empty( $seasons ) ): - add_meta_box( 'sp_statsdiv', __( 'Statistics', 'sportspress' ), 'sportspress_player_stats_meta', 'sp_player', 'normal', 'high' ); + add_meta_box( 'sp_performancediv', __( 'Performance', 'sportspress' ), 'sportspress_player_performance_meta', 'sp_player', 'normal', 'high' ); endif; } @@ -236,12 +236,12 @@ function sportspress_player_metrics_meta( $post ) { sportspress_nonce(); } -function sportspress_player_stats_meta( $post ) { +function sportspress_player_performance_meta( $post ) { $leagues = get_the_terms( $post->ID, 'sp_league' ); $league_num = sizeof( $leagues ); - // Loop through statistics for each league + // Loop through performance for each league foreach ( $leagues as $league ): if ( $league_num > 1 ): @@ -250,9 +250,9 @@ function sportspress_player_stats_meta( $post ) { ID, $league->term_id, true ); + list( $columns, $data, $placeholders, $merged, $seasons_teams ) = sportspress_get_player_performance_data( $post->ID, $league->term_id, true ); - sportspress_edit_player_statistics_table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) ); + sportspress_edit_player_performance_table( $post->ID, $league->term_id, $columns, $data, $placeholders, $merged, $seasons_teams, ! current_user_can( 'edit_sp_teams' ) ); endforeach; } diff --git a/admin/post-types/result.php b/admin/post-types/result.php index 32e3aa45..520e19e9 100644 --- a/admin/post-types/result.php +++ b/admin/post-types/result.php @@ -19,9 +19,10 @@ function sportspress_result_post_init() { 'show_in_menu' => false, 'has_archive' => false, 'hierarchical' => false, + 'can_export' => false, 'supports' => array( 'title', 'page-attributes' ), 'register_meta_box_cb' => 'sportspress_result_meta_init', - 'capability_type' => 'sp_config' + 'capability_type' => 'sp_config', ); register_post_type( 'sp_result', $args ); } diff --git a/admin/post-types/separator.php b/admin/post-types/separator.php index f8dc4dd1..ed455d2a 100644 --- a/admin/post-types/separator.php +++ b/admin/post-types/separator.php @@ -5,7 +5,8 @@ function sportspress_separator_post_init() { 'public' => false, 'show_ui' => true, 'show_in_nav_menus' => false, - 'show_in_admin_bar' => false + 'show_in_admin_bar' => false, + 'can_export' => false, ); register_post_type( 'sp_separator', $args ); } diff --git a/admin/post-types/staff.php b/admin/post-types/staff.php index 92b55aeb..87d5cb84 100644 --- a/admin/post-types/staff.php +++ b/admin/post-types/staff.php @@ -21,7 +21,7 @@ function sportspress_staff_post_init() { 'register_meta_box_cb' => 'sportspress_staff_meta_init', 'rewrite' => array( 'slug' => get_option( 'sportspress_staff_slug', 'staff' ) ), 'show_in_menu' => 'edit.php?post_type=sp_player', - 'capability_type' => 'sp_staff' + 'capability_type' => 'sp_staff', ); register_post_type( 'sp_staff', $args ); } diff --git a/admin/post-types/table.php b/admin/post-types/table.php index 054d3014..2ca8f11d 100644 --- a/admin/post-types/table.php +++ b/admin/post-types/table.php @@ -22,7 +22,7 @@ function sportspress_table_post_init() { 'rewrite' => array( 'slug' => get_option( 'sportspress_table_slug', 'table' ) ), 'show_in_menu' => 'edit.php?post_type=sp_team', 'show_in_admin_bar' => true, - 'capability_type' => 'sp_table' + 'capability_type' => 'sp_table', ); register_post_type( 'sp_table', $args ); } diff --git a/admin/post-types/team.php b/admin/post-types/team.php index bc57eda8..7e7ecc67 100644 --- a/admin/post-types/team.php +++ b/admin/post-types/team.php @@ -22,7 +22,7 @@ function sportspress_team_post_init() { 'register_meta_box_cb' => 'sportspress_team_meta_init', 'rewrite' => array( 'slug' => get_option( 'sportspress_teams_slug', 'teams' ) ), 'menu_icon' => 'dashicons-shield-alt', - 'capability_type' => 'sp_team' + 'capability_type' => 'sp_team', ); register_post_type( 'sp_team', $args ); } @@ -55,7 +55,7 @@ function sportspress_team_columns_meta( $post ) { $league_num = sizeof( $leagues ); - // Loop through statistics for each league + // Loop through columns for each league foreach ( $leagues as $league ): $league_id = $league->term_id; diff --git a/admin/settings/options-event.php b/admin/settings/options-event.php index f6cb5fe4..c46b8851 100644 --- a/admin/settings/options-event.php +++ b/admin/settings/options-event.php @@ -29,9 +29,9 @@ class SportsPressEventSettingsPage { ); add_settings_field( - 'statistics', - __( 'Statistics', 'sportspress' ), - array( $this, 'statistics_callback' ), + 'performance', + __( 'Performance', 'sportspress' ), + array( $this, 'performance_callback' ), 'sportspress_events', 'event' ); @@ -68,29 +68,29 @@ class SportsPressEventSettingsPage { options, 'event_statistics_responsive', true ); - $sortable = sportspress_array_value( $this->options, 'event_statistics_sortable', true ); - $link_posts = sportspress_array_value( $this->options, 'event_statistics_link_posts', true ); + function performance_callback() { + $responsive = sportspress_array_value( $this->options, 'event_performance_responsive', true ); + $sortable = sportspress_array_value( $this->options, 'event_performance_sortable', true ); + $link_posts = sportspress_array_value( $this->options, 'event_performance_link_posts', true ); ?>
-
-
-
diff --git a/admin/settings/options-player.php b/admin/settings/options-player.php index 981aa260..85ab262c 100644 --- a/admin/settings/options-player.php +++ b/admin/settings/options-player.php @@ -60,9 +60,9 @@ class SportsPressPlayerSettingsPage { ); add_settings_field( - 'statistics', - __( 'Statistics', 'sportspress' ), - array( $this, 'statistics_callback' ), + 'performance', + __( 'Performance', 'sportspress' ), + array( $this, 'performance_callback' ), 'sportspress_players', 'list' ); @@ -161,9 +161,9 @@ class SportsPressPlayerSettingsPage { 'sp_statistic', + 'post_type' => 'sp_performance', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', @@ -190,8 +190,8 @@ class SportsPressPlayerSettingsPage {
- - + +

diff --git a/admin/templates/event-statistics.php b/admin/templates/event-performance.php similarity index 81% rename from admin/templates/event-statistics.php rename to admin/templates/event-performance.php index 93c36e45..629f3f8c 100644 --- a/admin/templates/event-statistics.php +++ b/admin/templates/event-performance.php @@ -1,6 +1,6 @@ ' . get_the_title( $team_id ) . ''; $output .= '
' . - '' . '' . ''; + '
' . '' . ''; $output .= ''; $output .= ''; - foreach( $statistic_labels as $key => $label ): + foreach( $performance_labels as $key => $label ): $output .= ''; endforeach; @@ -65,7 +65,7 @@ if ( !function_exists( 'sportspress_event_statistics' ) ) { $output .= ''; - foreach( $statistic_labels as $key => $label ): + foreach( $performance_labels as $key => $label ): if ( $key == 'name' ) continue; if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ): @@ -100,7 +100,7 @@ if ( !function_exists( 'sportspress_event_statistics' ) ) { $row = $data[0]; - foreach( $statistic_labels as $key => $label ): + foreach( $performance_labels as $key => $label ): if ( $key == 'name' ): continue; endif; @@ -120,7 +120,7 @@ if ( !function_exists( 'sportspress_event_statistics' ) ) { endforeach; - return apply_filters( 'sportspress_event_statistics', $output ); + return apply_filters( 'sportspress_event_performance', $output ); } } diff --git a/admin/templates/player-gallery.php b/admin/templates/player-gallery.php index fa970460..3ff55692 100644 --- a/admin/templates/player-gallery.php +++ b/admin/templates/player-gallery.php @@ -48,16 +48,16 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) { // Remove the first row to leave us with the actual data unset( $data[0] ); - $statistics = sportspress_array_value( $r, 'statistics', null ); + $performance = sportspress_array_value( $r, 'performance', null ); if ( $r['orderby'] == 'default' ): $r['orderby'] = get_post_meta( $id, 'sp_orderby', true ); $r['order'] = get_post_meta( $id, 'sp_order', true ); else: - global $sportspress_statistic_priorities; - $sportspress_statistic_priorities = array( + global $sportspress_performance_priorities; + $sportspress_performance_priorities = array( array( - 'statistic' => $r['orderby'], + 'key' => $r['orderby'], 'order' => $r['order'], ), ); @@ -94,7 +94,7 @@ if ( !function_exists( 'sportspress_player_gallery' ) ) { if ( is_int( $r['number'] ) && $r['number'] > 0 ) $limit = $r['number']; - foreach( $data as $player_id => $statistics ): + foreach( $data as $player_id => $performance ): if ( $r['show_names_on_hover'] ): $caption = get_the_title( $player_id ); diff --git a/admin/templates/player-league-statistics.php b/admin/templates/player-league-performance.php similarity index 71% rename from admin/templates/player-league-statistics.php rename to admin/templates/player-league-performance.php index 46e0fdfb..2418c391 100644 --- a/admin/templates/player-league-statistics.php +++ b/admin/templates/player-league-performance.php @@ -1,6 +1,6 @@ term_id ); + $data = sportspress_get_player_performance_data( $id, $league->term_id ); // The first row should be column labels $labels = $data[0]; @@ -22,7 +22,7 @@ if ( !function_exists( 'sportspress_player_league_statistics' ) ) { $output = '

' . $league->name . '

' . '
' . - '
#' . __( 'Player', 'sportspress' ) . '' . $label . '' . $name . '
' . '' . ''; + '
' . '' . ''; foreach( $labels as $key => $label ): $output .= ''; @@ -48,7 +48,7 @@ if ( !function_exists( 'sportspress_player_league_statistics' ) ) { $output .= '' . '
' . $label . '
' . '
'; - return apply_filters( 'sportspress_player_league_statistics', $output ); + return apply_filters( 'sportspress_player_league_performance', $output ); } } diff --git a/admin/templates/player-list.php b/admin/templates/player-list.php index 468c99df..c3805563 100644 --- a/admin/templates/player-list.php +++ b/admin/templates/player-list.php @@ -9,7 +9,7 @@ if ( !function_exists( 'sportspress_player_list' ) ) { $defaults = array( 'number' => -1, - 'statistics' => null, + 'performance' => null, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => false, @@ -31,16 +31,16 @@ if ( !function_exists( 'sportspress_player_list' ) ) { // Remove the first row to leave us with the actual data unset( $data[0] ); - $statistics = sportspress_array_value( $r, 'statistics', null ); + $performance = sportspress_array_value( $r, 'performance', null ); if ( $r['orderby'] == 'default' ): $r['orderby'] = get_post_meta( $id, 'sp_orderby', true ); $r['order'] = get_post_meta( $id, 'sp_order', true ); else: - global $sportspress_statistic_priorities; - $sportspress_statistic_priorities = array( + global $sportspress_performance_priorities; + $sportspress_performance_priorities = array( array( - 'statistic' => $r['orderby'], + 'key' => $r['orderby'], 'order' => $r['order'], ), ); @@ -54,7 +54,7 @@ if ( !function_exists( 'sportspress_player_list' ) ) { endif; foreach( $labels as $key => $label ): - if ( ! is_array( $statistics ) || $key == 'name' || in_array( $key, $statistics ) ) + if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) ) $output .= ''. $label . ''; endforeach; @@ -91,7 +91,7 @@ if ( !function_exists( 'sportspress_player_list' ) ) { foreach( $labels as $key => $value ): if ( $key == 'name' ) continue; - if ( ! is_array( $statistics ) || in_array( $key, $statistics ) ) + if ( ! is_array( $performance ) || in_array( $key, $performance ) ) $output .= '' . sportspress_array_value( $row, $key, '—' ) . ''; endforeach; diff --git a/admin/templates/player-performance.php b/admin/templates/player-performance.php new file mode 100644 index 00000000..3483c94e --- /dev/null +++ b/admin/templates/player-performance.php @@ -0,0 +1,22 @@ + null, + 'performance' => null, 'orderby' => 'default', 'order' => 'ASC', ); @@ -23,16 +23,16 @@ if ( !function_exists( 'sportspress_player_roster' ) ) { // Remove the first row to leave us with the actual data unset( $data[0] ); - $statistics = sportspress_array_value( $r, 'statistics', null ); + $performance = sportspress_array_value( $r, 'performance', null ); if ( $r['orderby'] == 'default' ): $r['orderby'] = get_post_meta( $id, 'sp_orderby', true ); $r['order'] = get_post_meta( $id, 'sp_order', true ); else: - global $sportspress_statistic_priorities; - $sportspress_statistic_priorities = array( + global $sportspress_performance_priorities; + $sportspress_performance_priorities = array( array( - 'statistic' => $r['orderby'], + 'key' => $r['orderby'], 'order' => $r['order'], ), ); @@ -68,7 +68,7 @@ if ( !function_exists( 'sportspress_player_roster' ) ) { foreach( $labels as $key => $value ): if ( $key == 'name' ) continue; - if ( ! is_array( $statistics ) || in_array( $key, $statistics ) ) + if ( ! is_array( $performance ) || in_array( $key, $performance ) ) $rows .= '' . sportspress_array_value( $row, $key, '—' ) . ''; endforeach; @@ -89,7 +89,7 @@ if ( !function_exists( 'sportspress_player_roster' ) ) { endif; foreach( $labels as $key => $label ): - if ( ! is_array( $statistics ) || $key == 'name' || in_array( $key, $statistics ) ) + if ( ! is_array( $performance ) || $key == 'name' || in_array( $key, $performance ) ) $output .= ''. $label . ''; endforeach; $output .= '' . '' . '' . $rows . '' . '' . ''; diff --git a/admin/templates/player-statistics.php b/admin/templates/player-statistics.php deleted file mode 100644 index 24ff4cad..00000000 --- a/admin/templates/player-statistics.php +++ /dev/null @@ -1,22 +0,0 @@ - true, 'rewrite' => array( 'slug' => get_option( 'sportspress_position_slug', 'position' ) ), ); - $object_types = array( 'sp_player', 'sp_statistic', 'sp_metric', 'attachment' ); + $object_types = array( 'sp_player', 'sp_performance', 'sp_metric', 'attachment' ); register_taxonomy( 'sp_position', $object_types, $args ); foreach ( $object_types as $object_type ): register_taxonomy_for_object_type( 'sp_league', $object_type ); diff --git a/admin/tools/event-importer.php b/admin/tools/event-importer.php index 778b47bb..1486d7df 100644 --- a/admin/tools/event-importer.php +++ b/admin/tools/event-importer.php @@ -119,9 +119,9 @@ if ( class_exists( 'WP_Importer' ) ) { $league = ( empty( $_POST['sp_league'] ) ? false : $_POST['sp_league'] ); $season = ( empty( $_POST['sp_season'] ) ? false : $_POST['sp_season'] ); - // Get labels from result and statistic post types + // Get labels from result and performance post types $result_labels = sportspress_get_var_labels( 'sp_result' ); - $statistic_labels = sportspress_get_var_labels( 'sp_statistic' ); + $performance_labels = sportspress_get_var_labels( 'sp_performance' ); while ( ( $row = fgetcsv( $handle, 0, $this->delimiter ) ) !== FALSE ): @@ -133,7 +133,7 @@ if ( class_exists( 'WP_Importer' ) ) { // Add new event if date is given if ( sizeof( $event ) > 0 && ! empty( $event[0] ) ): - // Add player statistics to last event if available + // Add player performance to last event if available if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ): update_post_meta( $id, 'sp_players', $players ); endif; @@ -155,7 +155,7 @@ if ( class_exists( 'WP_Importer' ) ) { // Insert event $id = wp_insert_post( $args ); - // Initialize statistics array + // Initialize performance array $players = array(); // Flag as import @@ -331,7 +331,7 @@ if ( class_exists( 'WP_Importer' ) ) { // Add new player if player name is given if ( sizeof( $player ) > 0 && ! empty( $player[0] ) ): - // Get and unset player name leaving us with the statistics + // Get and unset player name leaving us with the performance $player_name = $player[0]; unset( $player[0] ); @@ -378,17 +378,17 @@ if ( class_exists( 'WP_Importer' ) ) { // Add player to event add_post_meta( $id, 'sp_player', $player_id ); - // Add player statistics to array if team is available + // Add player performance to array if team is available if ( isset( $team_id ) ): - // Initialize statistics array - $statistics = array(); + // Initialize performance array + $performance = array(); - // Map keys to player statistics - foreach ( $statistic_labels as $key => $label ): - $statistics[ $key ] = array_shift( $player ); + // Map keys to player performance + foreach ( $performance_labels as $key => $label ): + $performance[ $key ] = array_shift( $player ); endforeach; - $players[ $team_id ][ $player_id ] = $statistics; + $players[ $team_id ][ $player_id ] = $performance; // Get player teams $player_teams = get_post_meta( $player_id, 'sp_team', false ); @@ -415,7 +415,7 @@ if ( class_exists( 'WP_Importer' ) ) { endwhile; - // Add player statistics to last event if available + // Add player performance to last event if available if ( isset( $id ) && isset( $players ) && sizeof( $players ) > 0 ): update_post_meta( $id, 'sp_players', $players ); endif; diff --git a/admin/widgets/player-gallery.php b/admin/widgets/player-gallery.php index 6fe40fcf..9776ecfd 100644 --- a/admin/widgets/player-gallery.php +++ b/admin/widgets/player-gallery.php @@ -78,7 +78,7 @@ class SP_Widget_Player_Gallery extends WP_Widget { 'name' => __( 'Name', 'sportspress' ), 'eventsplayed' => __( 'Played', 'sportspress' ) ), - 'post_type' => 'sp_statistic', + 'post_type' => 'sp_performance', 'name' => $this->get_field_name('orderby'), 'id' => $this->get_field_id('orderby'), 'selected' => $orderby, diff --git a/admin/widgets/player-list.php b/admin/widgets/player-list.php index eb72dbe8..2acfd6c6 100644 --- a/admin/widgets/player-list.php +++ b/admin/widgets/player-list.php @@ -11,7 +11,7 @@ class SP_Widget_Player_list extends WP_Widget { $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $id = empty($instance['id']) ? null : $instance['id']; $number = empty($instance['number']) ? null : $instance['number']; - $statistics = $instance['statistics']; + $performance = $instance['performance']; $orderby = empty($instance['orderby']) ? 'default' : $instance['orderby']; $order = empty($instance['order']) ? 'ASC' : $instance['order']; $show_all_players_link = empty($instance['show_all_players_link']) ? false : $instance['show_all_players_link']; @@ -19,7 +19,7 @@ class SP_Widget_Player_list extends WP_Widget { if ( $title ) echo $before_title . $title . $after_title; echo '
'; - echo sportspress_player_list( $id, array( 'number' => $number, 'statistics' => $statistics, 'orderby' => $orderby , 'order' => $order, 'show_all_players_link' => $show_all_players_link ) ); + echo sportspress_player_list( $id, array( 'number' => $number, 'performance' => $performance, 'orderby' => $orderby , 'order' => $order, 'show_all_players_link' => $show_all_players_link ) ); echo '
'; echo $after_widget; } @@ -29,7 +29,7 @@ class SP_Widget_Player_list extends WP_Widget { $instance['title'] = strip_tags($new_instance['title']); $instance['id'] = intval($new_instance['id']); $instance['number'] = intval($new_instance['number']); - $instance['statistics'] = (array)$new_instance['statistics']; + $instance['performance'] = (array)$new_instance['performance']; $instance['orderby'] = strip_tags($new_instance['orderby']); $instance['order'] = strip_tags($new_instance['order']); $instance['show_all_players_link'] = $new_instance['show_all_players_link']; @@ -38,11 +38,11 @@ class SP_Widget_Player_list extends WP_Widget { } function form( $instance ) { - $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'number' => 5, 'statistics' => null, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true ) ); + $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => '', 'number' => 5, 'performance' => null, 'orderby' => 'default', 'order' => 'ASC', 'show_all_players_link' => true ) ); $title = strip_tags($instance['title']); $id = intval($instance['id']); $number = intval($instance['number']); - $statistics = $instance['statistics']; + $performance = $instance['performance']; $orderby = strip_tags($instance['orderby']); $order = strip_tags($instance['order']); $show_all_players_link = $instance['show_all_players_link']; @@ -70,23 +70,23 @@ class SP_Widget_Player_list extends WP_Widget {

-
+
'sp_statistic', + 'post_type' => 'sp_performance', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC' ); - $the_statistics = get_posts( $args ); + $the_performance = get_posts( $args ); - $field_name = $this->get_field_name('statistics') . '[]'; - $field_id = $this->get_field_id('statistics'); + $field_name = $this->get_field_name('performance') . '[]'; + $field_id = $this->get_field_id('performance'); ?> - - - + + +

@@ -99,7 +99,7 @@ class SP_Widget_Player_list extends WP_Widget { 'name' => __( 'Name', 'sportspress' ), 'eventsplayed' => __( 'Played', 'sportspress' ) ), - 'post_type' => 'sp_statistic', + 'post_type' => 'sp_performance', 'name' => $this->get_field_name('orderby'), 'id' => $this->get_field_id('orderby'), 'selected' => $orderby, diff --git a/assets/js/admin.js b/assets/js/admin.js index 1c04e842..a63a4c85 100644 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -326,7 +326,7 @@ jQuery(document).ready(function($){ }); // Remove slug editor in quick edit for slug-sensitive post types - $(".inline-edit-sp_result, .inline-edit-sp_outcome, .inline-edit-sp_column, .inline-edit-sp_statistic").find("input[name=post_name]").closest("label").remove(); + $(".inline-edit-sp_result, .inline-edit-sp_outcome, .inline-edit-sp_column, .inline-edit-sp_performance").find("input[name=post_name]").closest("label").remove(); // Prevent address input from submitting form $(".sp-address").keypress(function(event) { diff --git a/assets/js/sportspress.js b/assets/js/sportspress.js index 60d11574..5ecf36cf 100644 --- a/assets/js/sportspress.js +++ b/assets/js/sportspress.js @@ -24,7 +24,7 @@ function viewport() { /* Data Tables */ if (viewport().width > 640) { - $(".sp-league-table, .sp-event-statistics, .sp-player-list").each(function() { + $(".sp-league-table, .sp-event-performance, .sp-player-list").each(function() { sort = $(this).hasClass("sp-sortable-table"); $(this).dataTable({ "aaSorting": [], diff --git a/functions.php b/functions.php index 23004232..749a7576 100644 --- a/functions.php +++ b/functions.php @@ -95,7 +95,7 @@ if ( !function_exists( 'sportspress_flush_rewrite_rules' ) ) { sportspress_result_post_init(); sportspress_outcome_post_init(); sportspress_column_post_init(); - sportspress_statistic_post_init(); + sportspress_performance_post_init(); sportspress_event_post_init(); sportspress_calendar_post_init(); sportspress_team_post_init(); @@ -648,8 +648,8 @@ if ( !function_exists( 'sportspress_equation_selector' ) ) { case 'column': $options[ __( 'Columns', 'sportspress' ) ] = sportspress_get_equation_optgroup_array( $postid, 'sp_column' ); break; - case 'statistic': - $options[ __( 'Player Statistics', 'sportspress' ) ] = sportspress_get_equation_optgroup_array( $postid, 'sp_statistic' ); + case 'performance': + $options[ __( 'Performance', 'sportspress' ) ] = sportspress_get_equation_optgroup_array( $postid, 'sp_performance' ); break; endswitch; endforeach; @@ -1074,8 +1074,8 @@ if ( !function_exists( 'sportspress_edit_team_columns_table' ) ) { } } -if ( !function_exists( 'sportspress_edit_player_statistics_table' ) ) { - function sportspress_edit_player_statistics_table( $id = null, $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $seasons_teams = array(), $readonly = true ) { +if ( !function_exists( 'sportspress_edit_player_performance_table' ) ) { + function sportspress_edit_player_performance_table( $id = null, $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $seasons_teams = array(), $readonly = true ) { if ( ! $id ) $id = get_the_ID(); @@ -1096,7 +1096,7 @@ if ( !function_exists( 'sportspress_edit_player_statistics_table' ) ) { $div_stats ): - if ( !$div_id || $div_id == 'statistics' ) continue; + if ( !$div_id || $div_id == 'performance' ) continue; $div = get_term( $div_id, 'sp_season' ); ?> @@ -1139,7 +1139,7 @@ if ( !function_exists( 'sportspress_edit_player_statistics_table' ) ) { '; + echo ''; ?> @@ -1250,7 +1250,7 @@ if ( !function_exists( 'sportspress_event_player_sub_selector' ) ) { $output .= ''; // Add players as selectable options - foreach( $data as $id => $statistics ): + foreach( $data as $id => $performance ): if ( ! $id || $id == $player_id ) continue; $number = get_post_meta( $id, 'sp_number', true ); $output .= ''; @@ -1267,7 +1267,7 @@ if ( !function_exists( 'sportspress_edit_event_players_table' ) ) { function sportspress_edit_event_players_table( $columns = array(), $data = array(), $team_id ) { ?>
- +
@@ -1281,7 +1281,7 @@ if ( !function_exists( 'sportspress_edit_event_players_table' ) ) { $player_statistics ): + foreach ( $data as $player_id => $player_performance ): if ( !$player_id ) continue; $number = get_post_meta( $player_id, 'sp_number', true ); ?> @@ -1289,15 +1289,15 @@ if ( !function_exists( 'sportspress_edit_event_players_table' ) ) { $label ): - $value = sportspress_array_value( $player_statistics, $column, '' ); + $value = sportspress_array_value( $player_performance, $column, '' ); ?> $label ): $player_id = 0; - $player_statistics = sportspress_array_value( $data, 0, array() ); - $value = sportspress_array_value( $player_statistics, $column, '' ); + $player_performance = sportspress_array_value( $data, 0, array() ); + $value = sportspress_array_value( $player_performance, $column, '' ); ?> @@ -2085,7 +2085,7 @@ if ( !function_exists( 'sportspress_get_league_table_data' ) ) { uasort( $merged, 'sportspress_sort_table_teams' ); - // Rearrange data array to reflect statistics + // Rearrange data array to reflect values $data = array(); foreach( $merged as $key => $value ): $data[ $key ] = $tempdata[ $key ]; @@ -2155,7 +2155,7 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) { $usecolumns = get_post_meta( $post_id, 'sp_columns', true ); // Get labels from result variables - $columns = (array)sportspress_get_var_labels( 'sp_statistic' ); + $columns = (array)sportspress_get_var_labels( 'sp_performance' ); // Get all leagues populated with stats where available $tempdata = sportspress_array_combine( $player_ids, $stats ); @@ -2174,13 +2174,13 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) { $totals[ $player_id ][ $key ] = 0; endforeach; - // Get static statistics - $static = get_post_meta( $player_id, 'sp_statistics', true ); + // Get static performance + $static = get_post_meta( $player_id, 'sp_performance', true ); // Create placeholders entry for the player $placeholders[ $player_id ] = array( 'eventsplayed' => 0 ); - // Add static statistics to placeholders + // Add static performance to placeholders if ( is_array( $static ) && array_key_exists( $league_id, $static ) && array_key_exists( $div_id, $static[ $league_id ] ) ): $placeholders[ $player_id ] = array_merge( $placeholders[ $player_id ], $static[ $league_id ][ $div_id ] ); endif; @@ -2235,17 +2235,17 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) { $players = sportspress_array_value( $teams, $team_id, array() ); - foreach ( $players as $player_id => $player_statistics ): + foreach ( $players as $player_id => $player_performance ): if ( ! $player_id || ! in_array( $player_id, $player_ids ) ) continue; // Increment events played - if ( sportspress_array_value( $player_statistics, 'status' ) != 'sub' || sportspress_array_value( $player_statistics, 'sub', 0 ) ): + if ( sportspress_array_value( $player_performance, 'status' ) != 'sub' || sportspress_array_value( $player_performance, 'sub', 0 ) ): $totals[ $player_id ]['eventsplayed']++; endif; - foreach ( $player_statistics as $key => $value ): + foreach ( $player_performance as $key => $value ): if ( array_key_exists( $key, $totals[ $player_id ] ) ): $totals[ $player_id ][ $key ] += $value; @@ -2259,17 +2259,17 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) { foreach ( $teams as $players ): - foreach ( $players as $player_id => $player_statistics ): + foreach ( $players as $player_id => $player_performance ): if ( ! $player_id || ! in_array( $player_id, $player_ids ) ) continue; // Increment events played - if ( sportspress_array_value( $player_statistics, 'status' ) != 'sub' || sportspress_array_value( $player_statistics, 'sub', 0 ) ): + if ( sportspress_array_value( $player_performance, 'status' ) != 'sub' || sportspress_array_value( $player_performance, 'sub', 0 ) ): $totals[ $player_id ]['eventsplayed']++; endif; - foreach ( $player_statistics as $key => $value ): + foreach ( $player_performance as $key => $value ): if ( array_key_exists( $key, $totals[ $player_id ] ) ): $totals[ $player_id ][ $key ] += $value; @@ -2286,26 +2286,26 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) { endforeach; $args = array( - 'post_type' => 'sp_statistic', + 'post_type' => 'sp_performance', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', ); - $statistics = get_posts( $args ); + $performances = get_posts( $args ); $columns = array( 'eventsplayed' => __( 'Played', 'sportspress' ) ); - foreach ( $statistics as $statistic ): + foreach ( $performances as $performance ): // Get post meta - $meta = get_post_meta( $statistic->ID ); + $meta = get_post_meta( $performance->ID ); // Add equation to object - $statistic->equation = sportspress_array_value( sportspress_array_value( $meta, 'sp_equation', array() ), 0, 0 ); + $performance->equation = sportspress_array_value( sportspress_array_value( $meta, 'sp_equation', array() ), 0, 0 ); // Add column name to columns - $columns[ $statistic->post_name ] = $statistic->post_title; + $columns[ $performance->post_name ] = $performance->post_title; endforeach; @@ -2315,18 +2315,18 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) { if ( ! $player_id ) continue; - // Add events played as an object to statistics for placeholder calculations + // Add events played as an object to performance for placeholder calculations $epstat = new stdClass(); $epstat->post_name = 'eventsplayed'; - array_unshift( $statistics, $epstat ); + array_unshift( $performances, $epstat ); - foreach ( $statistics as $statistic ): - if ( sportspress_array_value( $placeholders[ $player_id ], $statistic->post_name, '' ) == '' ): + foreach ( $performances as $performance ): + if ( sportspress_array_value( $placeholders[ $player_id ], $performance->post_name, '' ) == '' ): - if ( $statistic->post_name == 'eventsplayed' ): + if ( $performance->post_name == 'eventsplayed' ): $calculate = 'total'; else: - $calculate = get_post_meta( $statistic->ID, 'sp_calculate', true ); + $calculate = get_post_meta( $performance->ID, 'sp_calculate', true ); endif; if ( $calculate && $calculate == 'average' ): @@ -2334,15 +2334,15 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) { // Reflect average $eventsplayed = (int)sportspress_array_value( $totals[ $player_id ], 'eventsplayed', 0 ); if ( ! $eventsplayed ): - $placeholders[ $player_id ][ $statistic->post_name ] = 0; + $placeholders[ $player_id ][ $performance->post_name ] = 0; else: - $placeholders[ $player_id ][ $statistic->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $statistic->post_name, 0 ) / $eventsplayed; + $placeholders[ $player_id ][ $performance->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $performance->post_name, 0 ) / $eventsplayed; endif; else: // Reflect total - $placeholders[ $player_id ][ $statistic->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $statistic->post_name, 0 ); + $placeholders[ $player_id ][ $performance->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $performance->post_name, 0 ); endif; @@ -2371,17 +2371,17 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) { endforeach; if ( $orderby != 'number' || $order != 'ASC' ): - global $sportspress_statistic_priorities; - $sportspress_statistic_priorities = array( + global $sportspress_performance_priorities; + $sportspress_performance_priorities = array( array( - 'statistic' => $orderby, + 'key' => $orderby, 'order' => $order, ), ); uasort( $merged, 'sportspress_sort_list_players' ); endif; - // Rearrange data array to reflect statistics + // Rearrange data array to reflect performance $data = array(); foreach( $merged as $key => $value ): $data[ $key ] = $tempdata[ $key ]; @@ -2415,7 +2415,7 @@ if ( !function_exists( 'sportspress_get_player_roster_data' ) ) { $order = get_post_meta( $post_id, 'sp_order', true ); // Get labels from result variables - $columns = (array)sportspress_get_var_labels( 'sp_statistic' ); + $columns = (array)sportspress_get_var_labels( 'sp_performance' ); // Get all leagues populated with stats where available $tempdata = sportspress_array_combine( $player_ids, $stats ); @@ -2440,13 +2440,13 @@ if ( !function_exists( 'sportspress_get_player_roster_data' ) ) { $totals[ $player_id ][ $key ] = 0; endforeach; - // Get static statistics - $static = get_post_meta( $player_id, 'sp_statistics', true ); + // Get static performance + $static = get_post_meta( $player_id, 'sp_performance', true ); // Create placeholders entry for the player $placeholders[ $player_id ] = array( 'eventsplayed' => 0, 'positions' => $position_ids ); - // Add static statistics to placeholders + // Add static performance to placeholders if ( is_array( $static ) && array_key_exists( $league_id, $static ) && array_key_exists( $div_id, $static[ $league_id ] ) ): $placeholders[ $player_id ] = array_merge( $placeholders[ $player_id ], $static[ $league_id ][ $div_id ] ); endif; @@ -2501,17 +2501,17 @@ if ( !function_exists( 'sportspress_get_player_roster_data' ) ) { $players = sportspress_array_value( $teams, $team_id, array() ); - foreach ( $players as $player_id => $player_statistics ): + foreach ( $players as $player_id => $player_performance ): if ( ! $player_id || ! in_array( $player_id, $player_ids ) ) continue; // Increment events played - if ( sportspress_array_value( $player_statistics, 'status' ) != 'sub' || sportspress_array_value( $player_statistics, 'sub', 0 ) ): + if ( sportspress_array_value( $player_performance, 'status' ) != 'sub' || sportspress_array_value( $player_performance, 'sub', 0 ) ): $totals[ $player_id ]['eventsplayed']++; endif; - foreach ( $player_statistics as $key => $value ): + foreach ( $player_performance as $key => $value ): if ( array_key_exists( $key, $totals[ $player_id ] ) ): $totals[ $player_id ][ $key ] += $value; @@ -2525,17 +2525,17 @@ if ( !function_exists( 'sportspress_get_player_roster_data' ) ) { foreach ( $teams as $players ): - foreach ( $players as $player_id => $player_statistics ): + foreach ( $players as $player_id => $player_performance ): if ( ! $player_id || ! in_array( $player_id, $player_ids ) ) continue; // Increment events played - if ( sportspress_array_value( $player_statistics, 'status' ) != 'sub' || sportspress_array_value( $player_statistics, 'sub', 0 ) ): + if ( sportspress_array_value( $player_performance, 'status' ) != 'sub' || sportspress_array_value( $player_performance, 'sub', 0 ) ): $totals[ $player_id ]['eventsplayed']++; endif; - foreach ( $player_statistics as $key => $value ): + foreach ( $player_performance as $key => $value ): if ( array_key_exists( $key, $totals[ $player_id ] ) ): $totals[ $player_id ][ $key ] += $value; @@ -2552,26 +2552,26 @@ if ( !function_exists( 'sportspress_get_player_roster_data' ) ) { endforeach; $args = array( - 'post_type' => 'sp_statistic', + 'post_type' => 'sp_performance', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', ); - $statistics = get_posts( $args ); + $performances = get_posts( $args ); $columns = array( 'eventsplayed' => __( 'Played', 'sportspress' ) ); - foreach ( $statistics as $statistic ): + foreach ( $performances as $performance ): // Get post meta - $meta = get_post_meta( $statistic->ID ); + $meta = get_post_meta( $performance->ID ); // Add equation to object - $statistic->equation = sportspress_array_value( sportspress_array_value( $meta, 'sp_equation', array() ), 0, 0 ); + $performance->equation = sportspress_array_value( sportspress_array_value( $meta, 'sp_equation', array() ), 0, 0 ); // Add column name to columns - $columns[ $statistic->post_name ] = $statistic->post_title; + $columns[ $performance->post_name ] = $performance->post_title; endforeach; @@ -2581,18 +2581,18 @@ if ( !function_exists( 'sportspress_get_player_roster_data' ) ) { if ( ! $player_id ) continue; - // Add events played as an object to statistics for placeholder calculations + // Add events played as an object to performance for placeholder calculations $epstat = new stdClass(); $epstat->post_name = 'eventsplayed'; - array_unshift( $statistics, $epstat ); + array_unshift( $performances, $epstat ); - foreach ( $statistics as $statistic ): - if ( sportspress_array_value( $placeholders[ $player_id ], $statistic->post_name, '' ) == '' ): + foreach ( $performances as $performance ): + if ( sportspress_array_value( $placeholders[ $player_id ], $performance->post_name, '' ) == '' ): - if ( $statistic->post_name == 'eventsplayed' ): + if ( $performance->post_name == 'eventsplayed' ): $calculate = 'total'; else: - $calculate = get_post_meta( $statistic->ID, 'sp_calculate', true ); + $calculate = get_post_meta( $performance->ID, 'sp_calculate', true ); endif; if ( $calculate && $calculate == 'average' ): @@ -2600,15 +2600,15 @@ if ( !function_exists( 'sportspress_get_player_roster_data' ) ) { // Reflect average $eventsplayed = (int)sportspress_array_value( $totals[ $player_id ], 'eventsplayed', 0 ); if ( ! $eventsplayed ): - $placeholders[ $player_id ][ $statistic->post_name ] = 0; + $placeholders[ $player_id ][ $performance->post_name ] = 0; else: - $placeholders[ $player_id ][ $statistic->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $statistic->post_name, 0 ) / $eventsplayed; + $placeholders[ $player_id ][ $performance->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $performance->post_name, 0 ) / $eventsplayed; endif; else: // Reflect total - $placeholders[ $player_id ][ $statistic->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $statistic->post_name, 0 ); + $placeholders[ $player_id ][ $performance->post_name ] = sportspress_array_value( sportspress_array_value( $totals, $player_id, array() ), $performance->post_name, 0 ); endif; @@ -2637,17 +2637,17 @@ if ( !function_exists( 'sportspress_get_player_roster_data' ) ) { endforeach; if ( $orderby != 'number' || $order != 'ASC' ): - global $sportspress_statistic_priorities; - $sportspress_statistic_priorities = array( + global $sportspress_performance_priorities; + $sportspress_performance_priorities = array( array( - 'statistic' => $orderby, + 'key' => $orderby, 'order' => $order, ), ); uasort( $merged, 'sportspress_sort_list_players' ); endif; - // Rearrange data array to reflect statistics + // Rearrange data array to reflect performance $data = array(); foreach( $merged as $key => $value ): $data[ $key ] = $tempdata[ $key ]; @@ -2666,22 +2666,22 @@ if ( !function_exists( 'sportspress_get_player_roster_data' ) ) { if ( !function_exists( 'sportspress_sort_list_players' ) ) { function sportspress_sort_list_players ( $a, $b ) { - global $sportspress_statistic_priorities; + global $sportspress_performance_priorities; // Loop through priorities - foreach( $sportspress_statistic_priorities as $priority ): + foreach( $sportspress_performance_priorities as $priority ): // Proceed if columns are not equal - if ( sportspress_array_value( $a, $priority['statistic'], 0 ) != sportspress_array_value( $b, $priority['statistic'], 0 ) ): + if ( sportspress_array_value( $a, $priority['key'], 0 ) != sportspress_array_value( $b, $priority['key'], 0 ) ): - if ( $priority['statistic'] == 'name' ): + if ( $priority['key'] == 'name' ): $output = strcmp( sportspress_array_value( $a, 'name', null ), sportspress_array_value( $b, 'name', null ) ); else: - // Compare statistic values - $output = sportspress_array_value( $a, $priority['statistic'], 0 ) - sportspress_array_value( $b, $priority['statistic'], 0 ); + // Compare performance values + $output = sportspress_array_value( $a, $priority['key'], 0 ) - sportspress_array_value( $b, $priority['key'], 0 ); endif; @@ -2724,16 +2724,16 @@ if ( !function_exists( 'sportspress_get_player_metrics_data' ) ) { } } -if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) { - function sportspress_get_player_statistics_data( $post_id, $league_id, $admin = false ) { +if ( !function_exists( 'sportspress_get_player_performance_data' ) ) { + function sportspress_get_player_performance_data( $post_id, $league_id, $admin = false ) { $seasons = (array)get_the_terms( $post_id, 'sp_season' ); $positions = get_the_terms( $post_id, 'sp_position' ); - $stats = (array)get_post_meta( $post_id, 'sp_statistics', true ); + $stats = (array)get_post_meta( $post_id, 'sp_performance', true ); $seasons_teams = sportspress_array_value( (array)get_post_meta( $post_id, 'sp_leagues', true ), $league_id, array() ); $args = array( - 'post_type' => 'sp_statistic', + 'post_type' => 'sp_performance', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', @@ -2754,15 +2754,15 @@ if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) { ); endif; - $statistics = get_posts( $args ); + $performances = get_posts( $args ); - $statistic_labels = array(); + $performance_labels = array(); $equations = array( 'eventsplayed' => 'total' ); - foreach ( $statistics as $statistic ): - $statistic_labels[ $statistic->post_name ] = $statistic->post_title; - $equations[ $statistic->post_name ] = get_post_meta( $statistic->ID, 'sp_calculate', true ); + foreach ( $performances as $performance ): + $performance_labels[ $performance->post_name ] = $performance->post_title; + $equations[ $performance->post_name ] = get_post_meta( $performance->ID, 'sp_calculate', true ); endforeach; - $columns = array_merge( array( 'eventsplayed' => __( 'Played', 'sportspress' ) ), $statistic_labels ); + $columns = array_merge( array( 'eventsplayed' => __( 'Played', 'sportspress' ) ), $performance_labels ); // Generate array of all season ids and season names $div_ids = array(); @@ -2785,7 +2785,7 @@ if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) { $totals = array( 'eventsattended' => 0, 'eventsplayed' => 0 ); - foreach ( $statistic_labels as $key => $value ): + foreach ( $performance_labels as $key => $value ): $totals[ $key ] = 0; endforeach; @@ -2817,16 +2817,16 @@ if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) { foreach( $events as $event ): $totals['eventsattended']++; - $team_statistics = (array)get_post_meta( $event->ID, 'sp_players', true ); + $team_performance = (array)get_post_meta( $event->ID, 'sp_players', true ); - // Add all team statistics - foreach ( $team_statistics as $players ): + // Add all team performance + foreach ( $team_performance as $players ): if ( array_key_exists( $post_id, $players ) ): - $player_statistics = sportspress_array_value( $players, $post_id, array() ); - if ( sportspress_array_value( $player_statistics, 'status' ) != 'sub' || sportspress_array_value( $player_statistics, 'sub', 0 ) ): + $player_performance = sportspress_array_value( $players, $post_id, array() ); + if ( sportspress_array_value( $player_performance, 'status' ) != 'sub' || sportspress_array_value( $player_performance, 'sub', 0 ) ): $totals['eventsplayed']++; endif; - foreach ( $player_statistics as $key => $value ): + foreach ( $player_performance as $key => $value ): if ( array_key_exists( $key, $totals ) ): $totals[ $key ] += $value; endif; diff --git a/presets/sports/baseball.php b/presets/sports/baseball.php index d1291678..caab5c14 100644 --- a/presets/sports/baseball.php +++ b/presets/sports/baseball.php @@ -68,7 +68,7 @@ $sportspress_sports['baseball'] = array( ), ), // Statistics - 'sp_statistic' => array( + 'sp_performance' => array( ), // Results 'sp_result' => array( diff --git a/presets/sports/basketball.php b/presets/sports/basketball.php index 800d6872..8ada3729 100644 --- a/presets/sports/basketball.php +++ b/presets/sports/basketball.php @@ -149,7 +149,7 @@ $sportspress_sports['basketball'] = array( ), ), // Player Statistics - 'sp_statistic' => array( + 'sp_performance' => array( array( 'post_title' => 'MIN', 'post_name' => 'min', diff --git a/presets/sports/cricket.php b/presets/sports/cricket.php index c60dc6e4..91aa3bf0 100644 --- a/presets/sports/cricket.php +++ b/presets/sports/cricket.php @@ -59,7 +59,7 @@ $sportspress_sports['cricket'] = array( ), ), // Statistics - 'sp_statistic' => array( + 'sp_performance' => array( ), // Results 'sp_result' => array( diff --git a/presets/sports/football.php b/presets/sports/football.php index 21b861fd..88978d70 100644 --- a/presets/sports/football.php +++ b/presets/sports/football.php @@ -184,7 +184,7 @@ $sportspress_sports['football'] = array( ), ), // Player Statistics - 'sp_statistic' => array( + 'sp_performance' => array( array( 'post_title' => 'Comp', 'post_name' => 'comp', diff --git a/presets/sports/footy.php b/presets/sports/footy.php index 5404469c..30fe72de 100644 --- a/presets/sports/footy.php +++ b/presets/sports/footy.php @@ -64,7 +64,7 @@ $sportspress_sports['footy'] = array( ) ), // Statistics - 'sp_statistic' => array( + 'sp_performance' => array( ), // Results 'sp_result' => array( diff --git a/presets/sports/gaming.php b/presets/sports/gaming.php index 0cb91539..3fb4bb3b 100644 --- a/presets/sports/gaming.php +++ b/presets/sports/gaming.php @@ -57,7 +57,7 @@ $sportspress_sports['gaming'] = array( ), ), // Statistics - 'sp_statistic' => array( + 'sp_performance' => array( ), // Results 'sp_result' => array( diff --git a/presets/sports/golf.php b/presets/sports/golf.php index c036a59f..4cd5d768 100644 --- a/presets/sports/golf.php +++ b/presets/sports/golf.php @@ -8,7 +8,7 @@ $sportspress_sports['golf'] = array( 'sp_column' => array( ), // Statistics - 'sp_statistic' => array( + 'sp_performance' => array( array( 'post_title' => 'Events', 'post_name' => 'events', diff --git a/presets/sports/hockey.php b/presets/sports/hockey.php index 3928a3ed..26e6139f 100644 --- a/presets/sports/hockey.php +++ b/presets/sports/hockey.php @@ -64,7 +64,7 @@ $sportspress_sports['hockey'] = array( ), ), // Statistics - 'sp_statistic' => array( + 'sp_performance' => array( ), // Results 'sp_result' => array( diff --git a/presets/sports/racing.php b/presets/sports/racing.php index ef9438d9..ef607a6d 100644 --- a/presets/sports/racing.php +++ b/presets/sports/racing.php @@ -8,7 +8,7 @@ $sportspress_sports['racing'] = array( 'sp_column' => array( ), // Statistics - 'sp_statistic' => array( + 'sp_performance' => array( array( 'post_title' => 'Pts', 'post_name' => 'pts', diff --git a/presets/sports/rugby.php b/presets/sports/rugby.php index ec63eb4b..fc9d99b4 100644 --- a/presets/sports/rugby.php +++ b/presets/sports/rugby.php @@ -119,7 +119,7 @@ $sportspress_sports['rugby'] = array( ), ), // Player Statistics - 'sp_statistic' => array( + 'sp_performance' => array( array( 'post_title' => 'Points', 'post_name' => 'points', diff --git a/presets/sports/soccer.php b/presets/sports/soccer.php index 85bc2cdc..91dbac34 100644 --- a/presets/sports/soccer.php +++ b/presets/sports/soccer.php @@ -156,7 +156,7 @@ $sportspress_sports['soccer'] = array( ), ), // Player Statistics - 'sp_statistic' => array( + 'sp_performance' => array( array( 'post_title' => 'Goals', 'post_name' => 'goals', diff --git a/sportspress.php b/sportspress.php index 39a9a26f..cbe9e785 100644 --- a/sportspress.php +++ b/sportspress.php @@ -35,19 +35,19 @@ require_once dirname( __FILE__ ) . '/functions.php'; // Templates require_once dirname( __FILE__ ) . '/admin/templates/countdown.php'; require_once dirname( __FILE__ ) . '/admin/templates/event-details.php'; -require_once dirname( __FILE__ ) . '/admin/templates/event-statistics.php'; +require_once dirname( __FILE__ ) . '/admin/templates/event-performance.php'; require_once dirname( __FILE__ ) . '/admin/templates/event-results.php'; require_once dirname( __FILE__ ) . '/admin/templates/event-staff.php'; require_once dirname( __FILE__ ) . '/admin/templates/event-venue.php'; require_once dirname( __FILE__ ) . '/admin/templates/event-calendar.php'; require_once dirname( __FILE__ ) . '/admin/templates/event-list.php'; require_once dirname( __FILE__ ) . '/admin/templates/league-table.php'; -require_once dirname( __FILE__ ) . '/admin/templates/player-league-statistics.php'; +require_once dirname( __FILE__ ) . '/admin/templates/player-league-performance.php'; require_once dirname( __FILE__ ) . '/admin/templates/player-list.php'; //require_once dirname( __FILE__ ) . '/admin/templates/player-roster.php'; require_once dirname( __FILE__ ) . '/admin/templates/player-gallery.php'; require_once dirname( __FILE__ ) . '/admin/templates/player-metrics.php'; -require_once dirname( __FILE__ ) . '/admin/templates/player-statistics.php'; +require_once dirname( __FILE__ ) . '/admin/templates/player-performance.php'; require_once dirname( __FILE__ ) . '/admin/templates/team-columns.php'; // Options @@ -62,7 +62,8 @@ require_once dirname( __FILE__ ) . '/admin/settings/options-permalink.php'; // Custom post types require_once dirname( __FILE__ ) . '/admin/post-types/separator.php'; require_once dirname( __FILE__ ) . '/admin/post-types/column.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/statistic.php'; +require_once dirname( __FILE__ ) . '/admin/post-types/performance.php'; +//require_once dirname( __FILE__ ) . '/admin/post-types/statistic.php'; require_once dirname( __FILE__ ) . '/admin/post-types/metric.php'; require_once dirname( __FILE__ ) . '/admin/post-types/result.php'; require_once dirname( __FILE__ ) . '/admin/post-types/outcome.php';
#
- - + +