Add events to team pages

This commit is contained in:
Brian Miyaji
2016-04-08 15:26:59 +10:00
parent 36bc9bc622
commit 35ed9962d4
12 changed files with 227 additions and 38 deletions

View File

@@ -100,6 +100,7 @@ class SP_Settings_Page {
<ul class="sp-layout sp-sortable-list ui-sortable">
<?php foreach ( $templates as $template => $details ) {
if ( ! is_array( $details ) ) continue;
$option = sp_array_value( $details, 'option', 'sportspress_' . $this->template . '_show_' . $template );
$visibility = get_option( $option, sp_array_value( $details, 'default', 'yes' ) );
?>

View File

@@ -34,6 +34,9 @@ class SP_Calendar extends SP_Custom_Post {
/** @var int The season ID. */
public $season;
/** @var int The team ID. */
public $team;
/**
* __construct function.
*
@@ -111,6 +114,16 @@ class SP_Calendar extends SP_Custom_Post {
$season_ids = array( $this->season );
endif;
if ( $this->team ):
$args['meta_query'] = array(
array(
'key' => 'sp_team',
'value' => array( $this->team ),
'compare' => 'IN',
),
);
endif;
if ( $pagenow != 'post-new.php' ):
if ( $this->ID ):
$leagues = get_the_terms( $this->ID, 'sp_league' );

View File

@@ -394,8 +394,17 @@ class SP_Team extends SP_Custom_Post {
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
'meta_key' => 'sp_team',
'meta_value' => $this->ID,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'sp_team',
'value' => $this->ID,
),
array(
'key' => 'sp_team',
'value' => '0',
),
),
);
$lists = get_posts( $args );

View File

@@ -303,6 +303,19 @@ if ( ! function_exists( 'sportspress_output_team_lists' ) ) {
sp_get_template( 'team-lists.php' );
}
}
if ( ! function_exists( 'sportspress_output_team_events' ) ) {
/**
* Output the team events.
*
* @access public
* @subpackage Team/Events
* @return void
*/
function sportspress_output_team_events() {
sp_get_template( 'team-events.php' );
}
}
/** Single League Table ********************************************************/