From e50265a5cd1dcc9888c33f1abd883ecc63ab0008 Mon Sep 17 00:00:00 2001 From: savvasha Date: Sun, 30 Aug 2020 11:06:45 +0300 Subject: [PATCH] 1) Fix warning for unknown variable $groups 2) Show DoB or Age based on Settings --- templates/birthdays.php | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/templates/birthdays.php b/templates/birthdays.php index 7c52b5a9..a348df40 100644 --- a/templates/birthdays.php +++ b/templates/birthdays.php @@ -17,7 +17,9 @@ $defaults = array( 'captiontag' => 'dd', 'size' => 'sportspress-fit-medium', 'show_player_birthday' => get_option( 'sportspress_player_show_birthday', 'no' ) == 'yes' ? true : false, + 'show_player_age' => get_option( 'sportspress_player_show_age', 'no' ) == 'yes' ? true : false, 'show_staff_birthday' => get_option( 'sportspress_staff_show_birthday', 'no' ) == 'yes' ? true : false, + 'sportspress_staff_show_age' => get_option( 'sportspress_staff_show_age', 'no' ) == 'yes' ? true : false, 'link_players' => get_option( 'sportspress_link_players', 'yes' ) == 'yes' ? true : false, 'link_staff' => get_option( 'sportspress_link_staff', 'yes' ) == 'yes' ? true : false, ); @@ -84,31 +86,40 @@ foreach ( $posts as $post ) { if ( 'sp_staff' == $post->post_type ) { $link_posts = $link_staff; $show_birthday = $show_staff_birthday; + $show_age = $sportspress_staff_show_age; } else { $link_posts = $link_players; $show_birthday = $show_player_birthday; + $show_age = $show_player_age; } $birthday = get_the_date( get_option( 'date_format') , $post->ID ); - if ( $show_birthday && $birthday && $group !== $birthday ) { - echo '

' . $birthday . '

'; + $heading = null; + if ( $show_birthday && $birthday ) { + $heading = '

' . $birthday . '

'; } - + if ( $show_birthday && $show_age && $birthday ) { + $sp_birthdays = new SportsPress_Birthdays(); + $age = $sp_birthdays->get_age( get_the_date( 'm-d-Y', $post->ID ) ); + $heading = '

' . $age . __( ' years old', 'sportspress' ) . '

'; + } + echo $heading; + echo '\n";