diff --git a/includes/class-sp-player.php b/includes/class-sp-player.php index 8f5af6d1..aa4a82c3 100644 --- a/includes/class-sp-player.php +++ b/includes/class-sp-player.php @@ -28,9 +28,9 @@ class SP_Player extends SP_Custom_Post { * @access public * @return array */ - public function metrics() { + public function metrics( $neg = null ) { $metrics = (array)get_post_meta( $this->ID, 'sp_metrics', true ); - $metric_labels = (array)sp_get_var_labels( 'sp_metric' ); + $metric_labels = (array)sp_get_var_labels( 'sp_metric', $neg ); $data = array(); foreach( $metric_labels as $key => $value ): $metric = sp_array_value( $metrics, $key, null ); diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index ee25e5b0..301a5a90 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -709,7 +709,7 @@ if ( !function_exists( 'sp_draft_or_post_title' ) ) { } if ( !function_exists( 'sp_get_var_labels' ) ) { - function sp_get_var_labels( $post_type ) { + function sp_get_var_labels( $post_type, $neg = null ) { $args = array( 'post_type' => $post_type, 'numberposts' => -1, @@ -722,7 +722,8 @@ if ( !function_exists( 'sp_get_var_labels' ) ) { $output = array(); foreach ( $vars as $var ): - $output[ $var->post_name ] = $var->post_title; + if ( $neg === null || ( $neg && $var->menu_order < 0 ) || ( ! $neg && $var->menu_order >= 0 ) ) + $output[ $var->post_name ] = $var->post_title; endforeach; return $output; diff --git a/templates/player-details.php b/templates/player-details.php index 8acf360f..01b1d1b1 100644 --- a/templates/player-details.php +++ b/templates/player-details.php @@ -25,7 +25,8 @@ $player = new SP_Player( $id ); $nationality = $player->nationality; $current_team = $player->current_team; $past_teams = $player->past_teams(); -$metrics = $player->metrics(); +$metrics_before = $player->metrics( true ); +$metrics_after = $player->metrics( false ); $common = array(); if ( $nationality ): @@ -33,7 +34,7 @@ if ( $nationality ): $common[ SP()->text->string('Nationality') ] = $country_name ? ( $show_nationality_flags ? '' . $nationality . ' ' : '' ) . $country_name : '—'; endif; -$data = array_merge( $common, $metrics ); +$data = array_merge( $metrics_before, $common, $metrics_after ); if ( $current_team ) $data[ SP()->text->string('Current Team') ] = '' . get_the_title( $current_team ) . '';