Add home venue option to teams

This commit is contained in:
Brian Miyaji
2014-06-26 17:59:16 +10:00
parent 2f6c8a6b8d
commit 2fccc4ec04
4 changed files with 79 additions and 1 deletions

View File

@@ -186,6 +186,11 @@ class SP_Admin_Meta_Boxes {
remove_meta_box( 'sp_leaguediv', 'sp_calendar', 'side' );
remove_meta_box( 'sp_venuediv', 'sp_calendar', 'side' );
// Teams
remove_meta_box( 'sp_leaguediv', 'sp_team', 'side' );
remove_meta_box( 'sp_seasondiv', 'sp_team', 'side' );
remove_meta_box( 'sp_venuediv', 'sp_team', 'side' );
// Tables
remove_meta_box( 'sp_seasondiv', 'sp_table', 'side' );
remove_meta_box( 'sp_leaguediv', 'sp_table', 'side' );

View File

@@ -19,9 +19,78 @@ class SP_Meta_Box_Team_Details {
* Output the metabox
*/
public static function output( $post ) {
$leagues = get_the_terms( $post->ID, 'sp_league' );
$league_ids = array();
if ( $leagues ):
foreach ( $leagues as $league ):
$league_ids[] = $league->term_id;
endforeach;
endif;
$seasons = get_the_terms( $post->ID, 'sp_season' );
$season_ids = array();
if ( $seasons ):
foreach ( $seasons as $season ):
$season_ids[] = $season->term_id;
endforeach;
endif;
$venues = get_the_terms( $post->ID, 'sp_venue' );
$venue_ids = array();
if ( $venues ):
foreach ( $venues as $venue ):
$venue_ids[] = $venue->term_id;
endforeach;
endif;
$abbreviation = get_post_meta( $post->ID, 'sp_abbreviation', true );
$url = get_post_meta( $post->ID, 'sp_url', true );
?>
<p><strong><?php _e( 'Leagues', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'taxonomy' => 'sp_league',
'name' => 'tax_input[sp_league][]',
'selected' => $league_ids,
'values' => 'term_id',
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ),
'class' => 'widefat',
'property' => 'multiple',
'chosen' => true,
);
sp_dropdown_taxonomies( $args );
?></p>
<p><strong><?php _e( 'Seasons', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'taxonomy' => 'sp_season',
'name' => 'tax_input[sp_season][]',
'selected' => $season_ids,
'values' => 'term_id',
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ),
'class' => 'widefat',
'property' => 'multiple',
'chosen' => true,
);
sp_dropdown_taxonomies( $args );
?></p>
<p><strong><?php _e( 'Home', 'sportspress' ); ?></strong></p>
<p><?php
$args = array(
'taxonomy' => 'sp_venue',
'name' => 'tax_input[sp_venue][]',
'selected' => $venue_ids,
'values' => 'term_id',
'placeholder' => sprintf( __( 'Select %s', 'sportspress' ), __( 'Venue', 'sportspress' ) ),
'class' => 'widefat',
'property' => 'multiple',
'chosen' => true,
);
sp_dropdown_taxonomies( $args );
?></p>
<p><strong><?php _e( 'Site URL', 'sportspress' ); ?></strong></p>
<p><input type="text" class="widefat" id="sp_url" name="sp_url" value="<?php echo $url; ?>"></p>
<?php if ( $url ): ?>