Filter event players by league and season

This commit is contained in:
Brian Miyaji
2014-08-24 17:05:44 +10:00
parent 16fba6cfc4
commit d6f8a52106
5 changed files with 45 additions and 3 deletions

View File

@@ -23,6 +23,10 @@
content: "\f164";
}
.sp-dummy {
display: none;
}
#sp_videodiv .inside > fieldset > p:first-child {
margin-top: 7px !important;
}

View File

@@ -127,6 +127,14 @@ jQuery(document).ready(function($){
// Activate self-cloning
$(".sp-clone:last").find("select").change();
// Dummy controller
$(".sp-has-dummy").change(function() {
val = $(this).val();
if ( val == -1 ) val = 0;
name = $(this).attr("name");
$(".sp-dummy."+name+"-dummy").val(val).trigger("change");
});
// Custom value editor
$(".sp-data-table .sp-default-value").click(function() {
$(this).hide().siblings(".sp-custom-value").show().find(".sp-custom-value-input").focus();

View File

@@ -30,6 +30,7 @@ class SP_Meta_Box_Event_Details {
$args = array(
'taxonomy' => 'sp_league',
'name' => 'sp_league',
'class' => 'sp-has-dummy',
'selected' => $league_id,
'values' => 'term_id',
'show_option_none' => __( '-- Not set --', 'sportspress' ),
@@ -47,6 +48,7 @@ class SP_Meta_Box_Event_Details {
$args = array(
'taxonomy' => 'sp_season',
'name' => 'sp_season',
'class' => 'sp-has-dummy',
'selected' => $season_id,
'values' => 'term_id',
'show_option_none' => __( '-- Not set --', 'sportspress' ),

View File

@@ -21,10 +21,38 @@ class SP_Meta_Box_Event_Teams {
public static function output( $post ) {
$limit = get_option( 'sportspress_event_teams', 2 );
$teams = (array) get_post_meta( $post->ID, 'sp_team', false );
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
$season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 );
for ( $i = 0; $i < $limit; $i ++ ):
$team = array_shift( $teams );
?>
<div class="sp-instance">
<p class="sp-tab-select sp-tab-select-dummy">
<?php
$args = array(
'taxonomy' => 'sp_league',
'name' => 'sp_league_dummy',
'class' => 'sp-dummy sp_league-dummy',
'show_option_all' => __( 'All', 'sportspress' ),
'selected' => $league_id,
'values' => 'term_id',
);
sp_dropdown_taxonomies( $args );
?>
</p>
<p class="sp-tab-select sp-tab-select-dummy">
<?php
$args = array(
'taxonomy' => 'sp_season',
'name' => 'sp_season_dummy',
'class' => 'sp-dummy sp_season-dummy',
'show_option_all' => __( 'All', 'sportspress' ),
'selected' => $season_id,
'values' => 'term_id',
);
sp_dropdown_taxonomies( $args );
?>
</p>
<p class="sp-tab-select sp-title-generator">
<?php
$args = array(
@@ -42,8 +70,8 @@ class SP_Meta_Box_Event_Teams {
<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', $i );
sp_post_checklist( $post->ID, 'sp_staff', 'none', 'sp_current_team', $i );
sp_post_checklist( $post->ID, 'sp_player', 'block', array( 'sp_league', 'sp_season', 'sp_current_team' ), $i );
sp_post_checklist( $post->ID, 'sp_staff', 'none', array( 'sp_league', 'sp_season', 'sp_current_team' ), $i );
?>
</div>
<?php

View File

@@ -704,7 +704,7 @@ if ( !function_exists( 'sp_post_checklist' ) ) {
<?php
$selected = sp_array_between( (array)get_post_meta( $post_id, $meta, false ), 0, $index );
if ( empty( $posts ) ):
$query = array( 'post_type' => $meta, 'numberposts' => -1, 'post_per_page' => -1, 'tax_query' => array( 'relation' => 'AND' ) );
$query = array( 'post_type' => $meta, 'numberposts' => -1, 'post_per_page' => -1 );
if ( $meta == 'sp_player' ):
$query['meta_key'] = 'sp_number';
$query['orderby'] = 'meta_value_num';