From 4425cee4df401d2efdb9080a52bad109da578a66 Mon Sep 17 00:00:00 2001 From: Takumi Date: Sat, 27 Jul 2013 03:19:38 +1000 Subject: [PATCH] Add ability to select different checklist tabs --- event.php | 36 ++++++++++++++++++------ helpers.php | 66 +++++++++++++++++++++----------------------- sportspress-admin.js | 7 +++-- 3 files changed, 64 insertions(+), 45 deletions(-) diff --git a/event.php b/event.php index b99dc9cc..ad1549ea 100644 --- a/event.php +++ b/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); - $args = array( - 'post_type' => 'sp_team', - 'name' => 'sportspress[sp_team][]', - 'selected' => $selected[ $i ] - ); - wp_dropdown_pages( $args ); + ?> +
+

+ 'sp_team', + 'name' => 'sportspress[sp_team][]', + 'class' => 'sportspress-pages', + 'selected' => $teams[ $i ] + ); + wp_dropdown_pages( $args ); + ?> + +

+ + ID, 'sp_player', false ); + sp_post_checklist( $post->ID, 'sp_staff', $i == $limit - 1, 'none' ); + ?> +
+ ID, 'sp_player', true ); sp_nonce(); } diff --git a/helpers.php b/helpers.php index 4c54f1a5..4174100e 100644 --- a/helpers.php +++ b/helpers.php @@ -112,47 +112,45 @@ 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 ); ?> -
-
- -
    - $meta, 'number' => 0 ) ); - if ( empty( $posts ) ) - $posts = get_posts( array( 'post_type' => $meta, 'numberposts' => 0 ) ); - foreach ( $posts as $post ): - $parents = get_post_ancestors( $post ); - ?> -
  • -
  • ', sizeof( $parents ) ); ?> - -
', sizeof( $parents ) ); ?> - - -all" class="wp-tab-panel" style="display: ;"> + +
    + $meta, 'number' => 0 ) ); + if ( empty( $posts ) ) + $posts = get_posts( array( 'post_type' => $meta, 'numberposts' => 0 ) ); + foreach ( $posts as $post ): + $parents = get_post_ancestors( $post ); ?> -
-
- - - +
  • +
  • ', sizeof( $parents ) ); ?> + + ', sizeof( $parents ) ); ?> +
  • + +
    + +
    +

    + + + labels->singular_name ); ?> + +

    +
    \ No newline at end of file diff --git a/sportspress-admin.js b/sportspress-admin.js index dd211f45..096711eb 100644 --- a/sportspress-admin.js +++ b/sportspress-admin.js @@ -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; + }); }); \ No newline at end of file