diff --git a/admin/post-types/event.php b/admin/post-types/event.php index a39adcc4..3500286d 100644 --- a/admin/post-types/event.php +++ b/admin/post-types/event.php @@ -83,7 +83,7 @@ function sp_event_players_meta( $post ) { $stats = (array)get_post_meta( $post->ID, 'sp_players', true ); // Get columns from result variables - $columns = sp_get_var_labels( 'sp_metric', true ); + $columns = sp_get_var_labels( 'sp_statistic', true ); foreach ( $teams as $key => $team_id ): if ( ! $team_id ) continue; diff --git a/admin/post-types/player.php b/admin/post-types/player.php index c26c47b6..5bd80a6e 100644 --- a/admin/post-types/player.php +++ b/admin/post-types/player.php @@ -44,13 +44,13 @@ function sp_player_team_meta( $post ) { function sp_player_stats_meta( $post ) { $team_ids = (array)get_post_meta( $post->ID, 'sp_team', false ); $leagues = (array)get_the_terms( $post->ID, 'sp_league' ); - $stats = (array)get_post_meta( $post->ID, 'sp_metrics', true ); + $stats = (array)get_post_meta( $post->ID, 'sp_statistics', true ); // Equation Operating System $eos = new eqEOS(); - // Get labels from metric variables - $metric_labels = (array)sp_get_var_labels( 'sp_metric' ); + // Get labels from statistic variables + $statistic_labels = (array)sp_get_var_labels( 'sp_statistic' ); // Generate array of all league ids $div_ids = array(); @@ -82,13 +82,13 @@ function sp_player_stats_meta( $post ) { $data[ $team_id ] = sp_array_combine( $div_ids, $stats[ $team_id ] ); // Get equations from statistics variables - $equations = sp_get_var_equations( 'sp_metric' ); + $equations = sp_get_var_equations( 'sp_statistic' ); foreach ( $div_ids as $div_id ): $totals = array( 'eventsattended' => 0, 'eventsplayed' => 0 ); - foreach ( $metric_labels as $key => $value ): + foreach ( $statistic_labels as $key => $value ): $totals[ $key ] = 0; endforeach; @@ -119,12 +119,12 @@ function sp_player_stats_meta( $post ) { foreach( $events as $event ): $totals['eventsattended']++; $totals['eventsplayed']++; // TODO: create tab for substitutes in sidebar - $team_metrics = (array)get_post_meta( $event->ID, 'sp_players', true ); - if ( array_key_exists( $team_id, $team_metrics ) ): - $players = sp_array_value( $team_metrics, $team_id, array() ); + $team_statistics = (array)get_post_meta( $event->ID, 'sp_players', true ); + if ( array_key_exists( $team_id, $team_statistics ) ): + $players = sp_array_value( $team_statistics, $team_id, array() ); if ( array_key_exists( $post->ID, $players ) ): - $player_metrics = sp_array_value( $players, $post->ID, array() ); - foreach ( $player_metrics as $key => $value ): + $player_statistics = sp_array_value( $players, $post->ID, array() ); + foreach ( $player_statistics as $key => $value ): if ( array_key_exists( $key, $totals ) ): $totals[ $key ] += $value; endif; @@ -154,7 +154,7 @@ function sp_player_stats_meta( $post ) { endforeach; // Get columns from statistics variables - $columns = sp_get_var_labels( 'sp_metric' ); + $columns = sp_get_var_labels( 'sp_statistic' ); if ( $team_num > 1 ): ?> @@ -162,7 +162,7 @@ function sp_player_stats_meta( $post ) { $name, @@ -12,14 +12,14 @@ function sp_metric_cpt_init() { 'show_in_nav_menus' => false, 'hierarchical' => false, 'supports' => array( 'title', 'page-attributes' ), - 'register_meta_box_cb' => 'sp_metric_meta_init', + 'register_meta_box_cb' => 'sp_statistic_meta_init', 'show_in_menu' => 'edit.php?post_type=sp_event' ); - register_post_type( 'sp_metric', $args ); + register_post_type( 'sp_statistic', $args ); } -add_action( 'init', 'sp_metric_cpt_init' ); +add_action( 'init', 'sp_statistic_cpt_init' ); -function sp_metric_edit_columns() { +function sp_statistic_edit_columns() { $columns = array( 'cb' => '', 'title' => __( 'Label', 'sportspress' ), @@ -27,13 +27,13 @@ function sp_metric_edit_columns() { ); return $columns; } -add_filter( 'manage_edit-sp_metric_columns', 'sp_metric_edit_columns' ); +add_filter( 'manage_edit-sp_statistic_columns', 'sp_statistic_edit_columns' ); -function sp_metric_meta_init() { - add_meta_box( 'sp_equationdiv', __( 'Equation', 'sportspress' ), 'sp_metric_equation_meta', 'sp_metric', 'normal', 'high' ); +function sp_statistic_meta_init() { + add_meta_box( 'sp_equationdiv', __( 'Equation', 'sportspress' ), 'sp_statistic_equation_meta', 'sp_statistic', 'normal', 'high' ); } -function sp_metric_equation_meta( $post ) { +function sp_statistic_equation_meta( $post ) { $equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) ); ?>
| + | $player_metrics ): + foreach ( $data as $player_id => $player_statistics ): if ( !$player_id ) continue; ?> | |
| @@ -706,8 +706,8 @@ if ( !function_exists( 'sp_event_players_table' ) ) { | $label ): $player_id = 0; - $player_metrics = $data[0]; - $value = sp_array_value( $player_metrics, $column, '' ); + $player_statistics = $data[0]; + $value = sp_array_value( $player_statistics, $column, '' ); ?> | @@ -812,7 +812,7 @@ if ( !function_exists( 'sp_get_table' ) ) { $totals[ $team_id ][ $key ] = 0; endforeach; - // Get statis stats + // Get static stats $static = get_post_meta( $team_id, 'sp_columns', true ); // Create placeholders entry for the team @@ -987,13 +987,13 @@ if ( !function_exists( 'sp_get_list' ) ) { $eos = new eqEOS(); // Get labels from result variables - $columns = (array)sp_get_var_labels( 'sp_metric' ); + $columns = (array)sp_get_var_labels( 'sp_statistic' ); // Get all leagues populated with stats where available $tempdata = sp_array_combine( $player_ids, $stats ); // Get equations from statistics variables - $equations = sp_get_var_equations( 'sp_metric' ); + $equations = sp_get_var_equations( 'sp_statistic' ); // Create entry for each player in totals $totals = array(); @@ -1009,13 +1009,13 @@ if ( !function_exists( 'sp_get_list' ) ) { $totals[ $player_id ][ $key ] = 0; endforeach; - // Get static metrics - $static = get_post_meta( $player_id, 'sp_metrics', true ); + // Get static statistics + $static = get_post_meta( $player_id, 'sp_statistics', true ); // Create placeholders entry for the player $placeholders[ $player_id ] = array(); - // Add static metrics to placeholders + // Add static statistics to placeholders if ( array_key_exists( $team_id, $static ) && array_key_exists( $div_id, $static[ $team_id ] ) ): $placeholders[ $player_id ] = $static[ $team_id ][ $div_id ]; endif; @@ -1051,12 +1051,12 @@ if ( !function_exists( 'sp_get_list' ) ) { $players = sp_array_value( $teams, $team_id, array() ); - foreach ( $players as $player_id => $player_metrics ): + foreach ( $players as $player_id => $player_statistics ): // Increment events played $totals[ $player_id ]['eventsplayed']++; - foreach ( $player_metrics as $key => $value ): + foreach ( $player_statistics as $key => $value ): if ( array_key_exists( $key, $totals[ $player_id ] ) ): $totals[ $player_id ][ $key ] += $value; @@ -1069,33 +1069,33 @@ if ( !function_exists( 'sp_get_list' ) ) { endforeach; $args = array( - 'post_type' => 'sp_metric', + 'post_type' => 'sp_statistic', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC' ); - $metrics = get_posts( $args ); + $statistics = get_posts( $args ); $columns = array(); $priorities = array(); - foreach ( $metrics as $metric ): + foreach ( $statistics as $statistic ): // Get post meta - $meta = get_post_meta( $metric->ID ); + $meta = get_post_meta( $statistic->ID ); // Add equation to object - $metric->equation = sp_array_value( sp_array_value( $meta, 'sp_equation', array() ), 0, 0 ); + $statistic->equation = sp_array_value( sp_array_value( $meta, 'sp_equation', array() ), 0, 0 ); // Add column name to columns - $columns[ $metric->post_name ] = $metric->post_title; + $columns[ $statistic->post_name ] = $statistic->post_title; // Add order to priorities if priority is set and does not exist in array already $priority = sp_array_value( sp_array_value( $meta, 'sp_priority', array() ), 0, 0 ); if ( $priority && ! array_key_exists( $priorities, $priority ) ): $priorities[ $priority ] = array( - 'column' => $metric->post_name, + 'column' => $statistic->post_name, 'order' => sp_array_value( sp_array_value( $meta, 'sp_order', array() ), 0, 'DESC' ) ); endif; @@ -1111,18 +1111,18 @@ if ( !function_exists( 'sp_get_list' ) ) { if ( ! $player_id ) continue; - foreach ( $metrics as $metric ): - if ( sp_array_value( $placeholders[ $player_id ], $metric->post_name, '' ) == '' ): + foreach ( $statistics as $statistic ): + if ( sp_array_value( $placeholders[ $player_id ], $statistic->post_name, '' ) == '' ): - if ( empty( $metric->equation ) ): + if ( empty( $statistic->equation ) ): // Reflect totals - $placeholders[ $player_id ][ $metric->post_name ] = sp_array_value( sp_array_value( $totals, $player_id, array() ), $key, 0 ); + $placeholders[ $player_id ][ $statistic->post_name ] = sp_array_value( sp_array_value( $totals, $player_id, array() ), $key, 0 ); else: // Calculate value - $placeholders[ $player_id ][ $metric->post_name ] = $eos->solveIF( str_replace( ' ', '', $metric->equation ), sp_array_value( $totals, $player_id, array() ) ); + $placeholders[ $player_id ][ $statistic->post_name ] = $eos->solveIF( str_replace( ' ', '', $statistic->equation ), sp_array_value( $totals, $player_id, array() ) ); endif; endif; diff --git a/sportspress.php b/sportspress.php index 10751d26..cf0140c6 100644 --- a/sportspress.php +++ b/sportspress.php @@ -38,7 +38,7 @@ require_once dirname( __FILE__ ) . '/admin/post-types/event.php'; require_once dirname( __FILE__ ) . '/admin/post-types/result.php'; require_once dirname( __FILE__ ) . '/admin/post-types/outcome.php'; require_once dirname( __FILE__ ) . '/admin/post-types/column.php'; -require_once dirname( __FILE__ ) . '/admin/post-types/metric.php'; +require_once dirname( __FILE__ ) . '/admin/post-types/statistic.php'; require_once dirname( __FILE__ ) . '/admin/post-types/team.php'; require_once dirname( __FILE__ ) . '/admin/post-types/table.php'; require_once dirname( __FILE__ ) . '/admin/post-types/player.php'; |