Add ability to select different checklist tabs
This commit is contained in:
26
event.php
26
event.php
@@ -28,22 +28,40 @@ add_filter( 'the_posts', 'sp_event_display_scheduled' );
|
||||
function sp_event_meta_init() {
|
||||
remove_meta_box( 'submitdiv', 'sp_event', 'side' );
|
||||
add_meta_box( 'submitdiv', __( 'Event', 'sportspress' ), 'post_submit_meta_box', 'sp_event', 'side', 'high' );
|
||||
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sp_event_team_meta', 'sp_event', 'normal', 'high' );
|
||||
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sp_event_team_meta', 'sp_event', 'side', 'high' );
|
||||
add_meta_box( 'sp_articlediv', __( 'Article', 'sportspress' ), 'sp_event_article_meta', 'sp_event', 'normal', 'high' );
|
||||
}
|
||||
|
||||
function sp_event_team_meta( $post ) {
|
||||
$limit = get_option( 'sp_event_team_count' );
|
||||
$teams = array_pad( array_slice( (array)get_post_meta( $post->ID, 'sp_team', false ), 0, $limit ), $limit, 0);
|
||||
$scores = array_pad( array_slice( (array)get_post_meta( $post->ID, 'sp_score', false ), 0, $limit ), $limit, 0);
|
||||
for ( $i = 0; $i < $limit; $i++ ):
|
||||
$selected = array_pad( array_slice( (array)get_post_meta( $post->ID, 'sp_team', false ), 0, $limit ), $limit, 0);
|
||||
?>
|
||||
<div>
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sportspress[sp_team][]',
|
||||
'selected' => $selected[ $i ]
|
||||
'class' => 'sportspress-pages',
|
||||
'selected' => $teams[ $i ]
|
||||
);
|
||||
wp_dropdown_pages( $args );
|
||||
?>
|
||||
<input name="sportspress[sp_score][]" type="text" placeholder="<?php _e( 'Score', 'sportspress' ); ?>" size="4" value="<?php echo $scores[ $i ]; ?>" />
|
||||
</p>
|
||||
<ul id="sportspress-tabs" class="wp-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', false );
|
||||
sp_post_checklist( $post->ID, 'sp_staff', $i == $limit - 1, 'none' );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
endfor;
|
||||
sp_post_checklist( $post->ID, 'sp_player', true );
|
||||
sp_nonce();
|
||||
}
|
||||
|
||||
|
||||
@@ -112,13 +112,12 @@ if ( ! function_exists( 'sp_team_logo' ) ) {
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'sp_post_checklist' ) ) {
|
||||
function sp_post_checklist( $post_id = null, $meta = 'post', $add_new_item = true ) {
|
||||
function sp_post_checklist( $post_id = null, $meta = 'post', $add_new_item = true, $display = 'block' ) {
|
||||
if ( ! isset( $post_id ) )
|
||||
global $post_id;
|
||||
$obj = get_post_type_object( $meta );
|
||||
?>
|
||||
<div id="posttype-<?php echo $meta; ?>" class="posttypediv">
|
||||
<div id="<?php echo $meta; ?>-all" class="wp-tab-panel">
|
||||
<div id="<?php echo $meta; ?>-all" class="wp-tab-panel" style="display: <?php echo $display; ?>;">
|
||||
<input type="hidden" value="0" name="sportspress[<?php echo $meta; ?>]" />
|
||||
<ul class="categorychecklist form-no-clear">
|
||||
<?php
|
||||
@@ -150,9 +149,8 @@ if ( ! function_exists( 'sp_post_checklist' ) ) {
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,3 +1,6 @@
|
||||
jQuery(document).ready(function(){
|
||||
jQuery('.sp_datepicker').datepicker();
|
||||
jQuery(document).ready(function($){
|
||||
$('#sportspress-tabs a').click(function() {
|
||||
$(this).closest('li').removeClass('wp-tab').addClass('wp-tab-active').siblings().removeClass('wp-tab-active').addClass('wp-tab').closest('.wp-tab-bar').siblings($(this).attr('href')).show().siblings('.wp-tab-panel').hide();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user