Display player metrics before and after common
This commit is contained in:
@@ -28,9 +28,9 @@ class SP_Player extends SP_Custom_Post {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function metrics() {
|
public function metrics( $neg = null ) {
|
||||||
$metrics = (array)get_post_meta( $this->ID, 'sp_metrics', true );
|
$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();
|
$data = array();
|
||||||
foreach( $metric_labels as $key => $value ):
|
foreach( $metric_labels as $key => $value ):
|
||||||
$metric = sp_array_value( $metrics, $key, null );
|
$metric = sp_array_value( $metrics, $key, null );
|
||||||
|
|||||||
@@ -709,7 +709,7 @@ if ( !function_exists( 'sp_draft_or_post_title' ) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( !function_exists( 'sp_get_var_labels' ) ) {
|
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(
|
$args = array(
|
||||||
'post_type' => $post_type,
|
'post_type' => $post_type,
|
||||||
'numberposts' => -1,
|
'numberposts' => -1,
|
||||||
@@ -722,6 +722,7 @@ if ( !function_exists( 'sp_get_var_labels' ) ) {
|
|||||||
|
|
||||||
$output = array();
|
$output = array();
|
||||||
foreach ( $vars as $var ):
|
foreach ( $vars as $var ):
|
||||||
|
if ( $neg === null || ( $neg && $var->menu_order < 0 ) || ( ! $neg && $var->menu_order >= 0 ) )
|
||||||
$output[ $var->post_name ] = $var->post_title;
|
$output[ $var->post_name ] = $var->post_title;
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ $player = new SP_Player( $id );
|
|||||||
$nationality = $player->nationality;
|
$nationality = $player->nationality;
|
||||||
$current_team = $player->current_team;
|
$current_team = $player->current_team;
|
||||||
$past_teams = $player->past_teams();
|
$past_teams = $player->past_teams();
|
||||||
$metrics = $player->metrics();
|
$metrics_before = $player->metrics( true );
|
||||||
|
$metrics_after = $player->metrics( false );
|
||||||
|
|
||||||
$common = array();
|
$common = array();
|
||||||
if ( $nationality ):
|
if ( $nationality ):
|
||||||
@@ -33,7 +34,7 @@ if ( $nationality ):
|
|||||||
$common[ SP()->text->string('Nationality') ] = $country_name ? ( $show_nationality_flags ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . '/assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '—';
|
$common[ SP()->text->string('Nationality') ] = $country_name ? ( $show_nationality_flags ? '<img src="' . plugin_dir_url( SP_PLUGIN_FILE ) . '/assets/images/flags/' . strtolower( $nationality ) . '.png" alt="' . $nationality . '"> ' : '' ) . $country_name : '—';
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$data = array_merge( $common, $metrics );
|
$data = array_merge( $metrics_before, $common, $metrics_after );
|
||||||
|
|
||||||
if ( $current_team )
|
if ( $current_team )
|
||||||
$data[ SP()->text->string('Current Team') ] = '<a href="' . get_post_permalink( $current_team ) . '">' . get_the_title( $current_team ) . '</a>';
|
$data[ SP()->text->string('Current Team') ] = '<a href="' . get_post_permalink( $current_team ) . '">' . get_the_title( $current_team ) . '</a>';
|
||||||
|
|||||||
Reference in New Issue
Block a user