Add support of Player Performance and Player statistic icons to Player Profile template and simplify the loop logic
This commit is contained in:
@@ -224,8 +224,6 @@ class SP_Player_List extends SP_Secondary_Post {
|
||||
}else{
|
||||
$columns[ $stat->post_name ] = $stat->post_title;
|
||||
}
|
||||
// Add columns titles for using with data-label
|
||||
$columns_title[ $stat->post_name ] = $stat->post_title;
|
||||
|
||||
// Add format
|
||||
$format = get_post_meta( $stat->ID, 'sp_format', true );
|
||||
@@ -677,24 +675,19 @@ class SP_Player_List extends SP_Secondary_Post {
|
||||
endif;
|
||||
|
||||
$labels = array();
|
||||
$labels_title = array();
|
||||
foreach( $this->columns as $key ):
|
||||
if ( $key == 'number' ):
|
||||
$labels[ $key ] = '#';
|
||||
$labels_title[ $key ] = '#';
|
||||
elseif ( $key == 'team' ):
|
||||
$labels[ $key ] = __( 'Team', 'sportspress' );
|
||||
$labels_title[ $key ] = __( 'Team', 'sportspress' );
|
||||
elseif ( $key == 'position' ):
|
||||
$labels[ $key ] = __( 'Position', 'sportspress' );
|
||||
$labels_title[ $key ] = __( 'Position', 'sportspress' );
|
||||
elseif ( array_key_exists( $key, $columns ) ):
|
||||
$labels[ $key ] = $columns[ $key ];
|
||||
$labels_title[ $key ] = $columns_title[ $key ];
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
return array( $labels, $labels_title, $data, $placeholders, $merged, $orderby );
|
||||
return array( $labels, $data, $placeholders, $merged, $orderby );
|
||||
else:
|
||||
|
||||
// Convert to time notation
|
||||
@@ -726,7 +719,6 @@ class SP_Player_List extends SP_Secondary_Post {
|
||||
foreach ( $columns as $key => $label ):
|
||||
if ( ! in_array( $key, $this->columns ) ):
|
||||
unset( $columns[ $key ] );
|
||||
unset( $columns_title[ $key ] );
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
@@ -740,8 +732,7 @@ class SP_Player_List extends SP_Secondary_Post {
|
||||
$labels['position'] = __( 'Position', 'sportspress' );
|
||||
}
|
||||
|
||||
$merged['head'] = array_merge( $labels, $columns );
|
||||
$merged[0] = array_merge( $labels, $columns_title );
|
||||
$merged[0] = array_merge( $labels, $columns );
|
||||
return $merged;
|
||||
endif;
|
||||
}
|
||||
|
||||
@@ -184,8 +184,17 @@ class SP_Player extends SP_Custom_Post {
|
||||
|
||||
foreach ( $posts as $post ):
|
||||
if ( -1 === $section ) {
|
||||
$performance_labels[ $post->post_name ] = $post->post_title;
|
||||
} else {
|
||||
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' ) {
|
||||
$icon = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
|
||||
if ( $icon != '' ) {
|
||||
$performance_labels[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
|
||||
}else{
|
||||
$performance_labels[ $post->post_name ] = $post->post_title;
|
||||
}
|
||||
}else{
|
||||
$performance_labels[ $post->post_name ] = $post->post_title;
|
||||
}
|
||||
}else{
|
||||
$post_section = get_post_meta( $post->ID, 'sp_section', true );
|
||||
|
||||
if ( '' === $post_section ) {
|
||||
@@ -193,7 +202,16 @@ class SP_Player extends SP_Custom_Post {
|
||||
}
|
||||
|
||||
if ( $section == $post_section || -1 == $post_section ) {
|
||||
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' ) {
|
||||
$icon = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
|
||||
if ( $icon != '' ) {
|
||||
$performance_labels[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
|
||||
}else{
|
||||
$performance_labels[ $post->post_name ] = $post->post_title;
|
||||
}
|
||||
}else{
|
||||
$performance_labels[ $post->post_name ] = $post->post_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,7 +584,16 @@ class SP_Player extends SP_Custom_Post {
|
||||
|
||||
foreach ( $posts as $post ):
|
||||
if ( -1 === $section ) {
|
||||
$stats[ $post->post_name ] = $post->post_title;
|
||||
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' ) {
|
||||
$icon = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
|
||||
if ( $icon != '' ) {
|
||||
$stats[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
|
||||
}else{
|
||||
$stats[ $post->post_name ] = $post->post_title;
|
||||
}
|
||||
}else{
|
||||
$stats[ $post->post_name ] = $post->post_title;
|
||||
}
|
||||
} else {
|
||||
$post_section = get_post_meta( $post->ID, 'sp_section', true );
|
||||
|
||||
@@ -577,16 +604,43 @@ class SP_Player extends SP_Custom_Post {
|
||||
if ( $admin ) {
|
||||
if ( 1 == $section ) {
|
||||
if ( 1 == $post_section ) {
|
||||
$stats[ $post->post_name ] = $post->post_title;
|
||||
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' ) {
|
||||
$icon = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
|
||||
if ( $icon != '' ) {
|
||||
$stats[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
|
||||
} else {
|
||||
$stats[ $post->post_name ] = $post->post_title;
|
||||
}
|
||||
} else {
|
||||
$stats[ $post->post_name ] = $post->post_title;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( 1 != $post_section ) {
|
||||
$stats[ $post->post_name ] = $post->post_title;
|
||||
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' ) {
|
||||
$icon = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
|
||||
if ( $icon != '' ) {
|
||||
$stats[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
|
||||
} else {
|
||||
$stats[ $post->post_name ] = $post->post_title;
|
||||
}
|
||||
} else {
|
||||
$stats[ $post->post_name ] = $post->post_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ( $section == $post_section || -1 == $post_section ) {
|
||||
if ( get_option( 'sportspress_player_statistics_mode', 'values' ) == 'icons' ) {
|
||||
$icon = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
|
||||
if ( $icon != '' ) {
|
||||
$stats[ $post->post_name ] = apply_filters( 'sportspress_event_performance_icons', '', $post->ID, 1 );
|
||||
}else{
|
||||
$stats[ $post->post_name ] = $post->post_title;
|
||||
}
|
||||
}else{
|
||||
$stats[ $post->post_name ] = $post->post_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
endforeach;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user