Merge pull request #381 from ThemeBoy/feature-dob-age-player-lists

Feature dob age player lists
This commit is contained in:
Brian Miyaji
2020-04-09 22:07:28 +10:00
committed by GitHub
3 changed files with 45 additions and 0 deletions

View File

@@ -406,6 +406,8 @@ class SP_Player_List extends SP_Secondary_Post {
$team_performance = get_post_meta( $event->ID, 'sp_players', true );
$timeline = (array)get_post_meta( $event->ID, 'sp_timeline', true );
$minutes = get_post_meta( $event->ID, 'sp_minutes', true );
$showdob = get_option( 'sportspress_player_show_birthday', 'no' );
$showage = get_option( 'sportspress_player_show_age', 'no' );
if ( $minutes === '' ) $minutes = get_option( 'sportspress_event_minutes', 90 );
// Add all team performance
@@ -628,6 +630,15 @@ class SP_Player_List extends SP_Secondary_Post {
// Merge the data and placeholders arrays
foreach( $placeholders as $player_id => $player_data ):
if ( in_array( 'dob', $this->columns ) ):
$player_data['dob'] = get_the_date( get_option( 'date_format') , $player_id );
endif;
if ( in_array( 'age', $this->columns ) ):
$birthdayclass = new SportsPress_Birthdays();
$player_data['age'] = $birthdayclass->get_age( get_the_date( 'm-d-Y', $player_id ) );
endif;
$player_data = array_merge( $column_order, $player_data );
$placeholders[ $player_id ] = $player_data;
@@ -715,6 +726,10 @@ class SP_Player_List extends SP_Secondary_Post {
$labels[ $key ] = __( 'Team', 'sportspress' );
elseif ( $key == 'position' ):
$labels[ $key ] = __( 'Position', 'sportspress' );
elseif ( $key == 'dob' && $showdob ):
$labels[ $key ] = __( 'Date of Birth', 'sportspress' );
elseif ( $key == 'age' && $showage ):
$labels[ $key ] = __( 'Age', 'sportspress' );
elseif ( array_key_exists( $key, $columns ) ):
$labels[ $key ] = $columns[ $key ];
endif;
@@ -764,6 +779,12 @@ class SP_Player_List extends SP_Secondary_Post {
if ( in_array( 'position', $this->columns ) ) {
$labels['position'] = __( 'Position', 'sportspress' );
}
if ( in_array( 'dob', $this->columns ) && $showdob ) {
$labels['dob'] = __( 'Date of Birth', 'sportspress' );
}
if ( in_array( 'age', $this->columns ) && $showage ) {
$labels['age'] = __( 'Age', 'sportspress' );
}
$merged[0] = array_merge( $labels, $columns );
return $merged;