Prepare for individual mode

This commit is contained in:
Brian Miyaji
2015-01-21 23:51:39 +11:00
parent 1f7c5a35b8
commit a3d20cb72b
3 changed files with 77 additions and 63 deletions

View File

@@ -53,6 +53,7 @@ class SP_Meta_Box_Event_Teams {
sp_dropdown_taxonomies( $args );
?>
</p>
<?php if ( 'teams' == get_option( 'sportspress_mode', 'teams' ) ) { ?>
<p class="sp-tab-select sp-title-generator">
<?php
$args = array(
@@ -67,6 +68,9 @@ class SP_Meta_Box_Event_Teams {
sp_dropdown_pages( $args );
?>
</p>
<?php } else { ?>
<input type="hidden" name="sp_team[]" value="0">
<?php } ?>
<ul id="sp_team-tabs" class="wp-tab-bar sp-tab-bar">
<li class="wp-tab-active"><a href="#sp_player-all"><?php _e( 'Players', 'sportspress' ); ?></a></li>
<li class="wp-tab"><a href="#sp_staff-all"><?php _e( 'Staff', 'sportspress' ); ?></a></li>
@@ -84,7 +88,9 @@ class SP_Meta_Box_Event_Teams {
* Save meta box data
*/
public static function save( $post_id, $post ) {
if ( 'teams' == get_option( 'sportspress_mode', 'teams' ) ) {
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
}
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) );
sp_update_post_meta_recursive( $post_id, 'sp_staff', sp_array_value( $_POST, 'sp_staff', array() ) );
}

View File

@@ -97,8 +97,9 @@ class SP_Meta_Box_Player_Statistics {
<td>&nbsp;</td>
<?php else: ?>
<td>
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
<?php if ( 'teams' == get_option( 'sportspress_mode', 'teams' ) ) { ?>
<?php
$value = sp_array_value( $leagues, $div_id, '-1' );
$args = array(
'post_type' => 'sp_team',
'name' => 'sp_leagues[' . $league_id . '][' . $div_id . ']',
@@ -127,6 +128,9 @@ class SP_Meta_Box_Player_Statistics {
_e( '&mdash; None &mdash;', 'sportspress' );
endif;
?>
<?php } else { ?>
<input type="checkbox" name="sp_leagues[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" value="0" <?php checked( 0, $value ); ?>>
<?php } ?>
</td>
<?php endif; ?>
<?php endif; ?>

View File

@@ -46,7 +46,8 @@ $common[ __( 'Position', 'sportspress' ) ] = implode( ', ', $position_names );
$data = array_merge( $metrics_before, $common, $metrics_after );
if ( $current_teams ):
if ( 'teams' == get_option( 'sportspress_mode', 'teams' ) ) {
if ( $current_teams ):
$teams = array();
foreach ( $current_teams as $team ):
$team_name = get_the_title( $team );
@@ -55,9 +56,9 @@ if ( $current_teams ):
endforeach;
$label = _n( 'Current Team', 'Current Teams', count( $teams ), 'sportspress' );
$data[ $label ] = implode( ', ', $teams );
endif;
endif;
if ( $past_teams ):
if ( $past_teams ):
$teams = array();
foreach ( $past_teams as $team ):
$team_name = get_the_title( $team );
@@ -65,7 +66,10 @@ if ( $past_teams ):
$teams[] = $team_name;
endforeach;
$data[ __( 'Past Teams', 'sportspress' ) ] = implode( ', ', $teams );
endif;
endif;
}
$data = apply_filters( 'sportspress_player_details', $data, $id );
$output = '<div class="sp-template sp-template-player-details sp-template-details"><div class="sp-list-wrapper"><dl class="sp-player-details">';