diff --git a/includes/sp-template-functions.php b/includes/sp-template-functions.php index cda122fa..24dab68e 100644 --- a/includes/sp-template-functions.php +++ b/includes/sp-template-functions.php @@ -387,6 +387,19 @@ if ( ! function_exists( 'sportspress_output_player_statistics' ) ) { sp_get_template( 'player-statistics.php' ); } } +if ( ! function_exists( 'sportspress_output_player_events' ) ) { + + /** + * Output the player events. + * + * @access public + * @subpackage Player/Events + * @return void + */ + function sportspress_output_player_events() { + sp_get_template( 'player-events.php' ); + } +} /** Single Player List ********************************************************/ diff --git a/modules/sportspress-calendars.php b/modules/sportspress-calendars.php index 3a2afda4..c4aee54f 100644 --- a/modules/sportspress-calendars.php +++ b/modules/sportspress-calendars.php @@ -42,6 +42,8 @@ class SportsPress_Calendars { add_filter( 'sportspress_event_settings', array( $this, 'add_event_settings' ) ); add_filter( 'sportspress_team_options', array( $this, 'add_team_options' ) ); add_filter( 'sportspress_after_team_template', array( $this, 'add_team_template' ), 40 ); + add_filter( 'sportspress_player_options', array( $this, 'add_player_options' ) ); + add_filter( 'sportspress_after_player_template', array( $this, 'add_player_template' ), 40 ); } /** @@ -395,6 +397,44 @@ class SportsPress_Calendars { ); } + /** + * Add player template. + * + * @return array + */ + public function add_player_template( $templates ) { + return array_merge( $templates, array( + 'events' => array( + 'title' => __( 'Events', 'sportspress' ), + 'option' => 'sportspress_player_show_events', + 'action' => 'sportspress_output_player_events', + 'default' => 'no', + ), + ) ); + } + + /** + * Add player options. + * + * @return array + */ + public function add_player_options( $options ) { + return array_merge( $options, + array( + array( + 'title' => __( 'Events', 'sportspress' ), + 'id' => 'sportspress_player_events_format', + 'default' => 'title', + 'type' => 'select', + 'options' => array( + 'blocks' => __( 'Blocks', 'sportspress' ), + 'calendar' => __( 'Calendar', 'sportspress' ), + ), + ), + ) + ); + } + /** * Add team template. * diff --git a/templates/event-blocks.php b/templates/event-blocks.php index 646828f4..ea3950e1 100644 --- a/templates/event-blocks.php +++ b/templates/event-blocks.php @@ -67,7 +67,7 @@ if ( $day != 'default' ) $calendar->day = $day; $data = $calendar->data(); -if ( $hide_if_empty && empty( $data ) ) return; +if ( $hide_if_empty && empty( $data ) ) return false; if ( $show_title && false === $title && $id ): $caption = $calendar->caption; diff --git a/templates/event-fixtures-results.php b/templates/event-fixtures-results.php index ddbdc0c7..8d5af2f9 100644 --- a/templates/event-fixtures-results.php +++ b/templates/event-fixtures-results.php @@ -17,6 +17,7 @@ $defaults = array( 'league' => null, 'season' => null, 'team' => null, + 'player' => null, 'number' => -1, 'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false, 'link_events' => get_option( 'sportspress_link_events', 'yes' ) == 'yes' ? true : false, @@ -42,6 +43,8 @@ if ( $season ) $calendar->season = $season; if ( $team ) $calendar->team = $team; +if ( $player ) + $calendar->player = $player; $args = array( 'id' => $id, @@ -53,6 +56,7 @@ $args = array( 'league' => $league, 'season' => $season, 'team' => $team, + 'player' => $player, 'number' => $number, 'link_teams' => $link_teams, 'link_events' => $link_events, @@ -69,16 +73,32 @@ $args = array( echo '
'; -echo '
'; +ob_start(); sp_get_template( 'event-blocks.php', $args ); -echo '
'; +$fixtures = ob_get_clean(); $args['title'] = __( 'Results', 'sportspress' ); $args['status'] = 'publish'; $args['order'] = 'DESC'; -echo '
'; +ob_start(); sp_get_template( 'event-blocks.php', $args ); -echo '
'; +$results = ob_get_clean(); + +if ( false == $fixtures || false == $results ) { + + echo $fixtures; + echo $results; + +} else { + + echo '
'; + echo $fixtures; + echo '
'; + + echo '
'; + echo $results; + echo '
'; +} echo '
'; \ No newline at end of file diff --git a/templates/player-events.php b/templates/player-events.php new file mode 100644 index 00000000..77888e33 --- /dev/null +++ b/templates/player-events.php @@ -0,0 +1,19 @@ + $id ) ); +else + sp_get_template( 'event-fixtures-results.php', array( 'player' => $id ) );