Fix event team limit issue, update to 0.8.6

This commit is contained in:
Brian Miyaji
2014-05-08 13:52:25 +10:00
parent dc88aff65d
commit ba579cfb9e
4 changed files with 28 additions and 23 deletions

View File

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin/Meta Boxes
* @version 0.8.4
* @version 0.8.6
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -19,39 +19,41 @@ class SP_Meta_Box_Event_Teams {
* Output the metabox
*/
public static function output( $post ) {
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
foreach ( $teams as $key => $value ):
?>
$limit = get_option( 'sportspress_event_teams', 2 );
$teams = (array) get_post_meta( $post->ID, 'sp_team', false );
for ( $i = 0; $i < $limit; $i ++ ):
$team = array_shift( $teams );
?>
<div class="sp-instance">
<p class="sp-tab-select sp-title-generator">
<?php
$args = array(
'post_type' => 'sp_team',
'name' => 'sp_team[]',
'class' => 'sportspress-pages',
'show_option_none' => sprintf( __( '&mdash; None &mdash;', 'sportspress' ), 'Team' ),
'selected' => $value
);
wp_dropdown_pages( $args );
?>
<?php
$args = array(
'post_type' => 'sp_team',
'name' => 'sp_team[]',
'class' => 'sportspress-pages',
'show_option_none' => sprintf( __( '&mdash; None &mdash;', 'sportspress' ), 'Team' ),
'selected' => $team
);
wp_dropdown_pages( $args );
?>
</p>
<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>
</ul>
<?php
sp_post_checklist( $post->ID, 'sp_player', 'block', 'sp_current_team', $key );
sp_post_checklist( $post->ID, 'sp_staff', 'none', 'sp_current_team', $key );
sp_post_checklist( $post->ID, 'sp_player', 'block', 'sp_current_team', $i );
sp_post_checklist( $post->ID, 'sp_staff', 'none', 'sp_current_team', $i );
?>
</div>
<?php endforeach;
<?php
endfor;
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
sp_update_post_meta( $post_id, 'sp_limit', sp_array_value( $_POST, 'sp_limit', 2 ) );
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

@@ -5,7 +5,7 @@
* @author ThemeBoy
* @category Admin
* @package SportsPress/Admin
* @version 0.8
* @version 0.8.6
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly