Add events template to players

This commit is contained in:
Brian Miyaji
2016-12-08 21:12:30 +11:00
parent 5c1e454208
commit c4e73d4977
5 changed files with 97 additions and 5 deletions

View File

@@ -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 ********************************************************/

View File

@@ -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.
*

View File

@@ -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;

View File

@@ -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 '<div class="sp-fixtures-results">';
echo '<div class="sp-widget-align-left">';
ob_start();
sp_get_template( 'event-blocks.php', $args );
echo '</div>';
$fixtures = ob_get_clean();
$args['title'] = __( 'Results', 'sportspress' );
$args['status'] = 'publish';
$args['order'] = 'DESC';
echo '<div class="sp-widget-align-right">';
ob_start();
sp_get_template( 'event-blocks.php', $args );
$results = ob_get_clean();
if ( false == $fixtures || false == $results ) {
echo $fixtures;
echo $results;
} else {
echo '<div class="sp-widget-align-left">';
echo $fixtures;
echo '</div>';
echo '<div class="sp-widget-align-right">';
echo $results;
echo '</div>';
}
echo '</div>';

View File

@@ -0,0 +1,19 @@
<?php
/**
* Player Events
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 2.1.7
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) )
$id = get_the_ID();
$format = get_option( 'sportspress_player_events_format', 'blocks' );
if ( 'calendar' === $format )
sp_get_template( 'event-calendar.php', array( 'player' => $id ) );
else
sp_get_template( 'event-fixtures-results.php', array( 'player' => $id ) );