diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-columns.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-columns.php index 9645b900..864b22f4 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-columns.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-columns.php @@ -48,6 +48,7 @@ class SP_Meta_Box_List_Columns { +

diff --git a/includes/class-sp-player-list.php b/includes/class-sp-player-list.php index 480864f5..5c3fadcf 100644 --- a/includes/class-sp-player-list.php +++ b/includes/class-sp-player-list.php @@ -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; diff --git a/modules/sportspress-birthdays.php b/modules/sportspress-birthdays.php index 96894a4c..9d048eb3 100644 --- a/modules/sportspress-birthdays.php +++ b/modules/sportspress-birthdays.php @@ -36,6 +36,7 @@ class SportsPress_Birthdays { add_filter( 'sportspress_staff_details', array( $this, 'add_staff_details' ), 20, 2 ); add_action( 'sportspress_widgets', array( $this, 'widgets' ) ); + add_action( 'sportspress_list_general_columns', array( $this, 'columns' ), 10, 1 ); } /** @@ -187,6 +188,28 @@ class SportsPress_Birthdays { public static function widgets() { include_once( SP()->plugin_path() . '/includes/widgets/class-sp-widget-birthdays.php' ); } + + /** + * Add more General Columns at Player Lists + */ + public static function columns( $selected ) { + if ( 'yes' == get_option( 'sportspress_player_show_birthday', 'no' ) ) { ?> +
  • + +
  • + + +
  • + +
  • +