diff --git a/assets/js/admin/sportspress-admin.js b/assets/js/admin/sportspress-admin.js index 0a35e301..192b47c0 100644 --- a/assets/js/admin/sportspress-admin.js +++ b/assets/js/admin/sportspress-admin.js @@ -386,6 +386,23 @@ jQuery(document).ready(function($){ // Trigger format selector $(".sp-format-selector select:first").change(); + // Team era selector + $(".sp-team-era-selector select:first-child").change(function() { + + $subselector = $(this).siblings(); + + // Sub settings + if($(this).val() == 0) { + $subselector.hide(); + } else { + $subselector.show(); + } + + }); + + // Trigger team era selector + $(".sp-team-era-selector select:first-child").change(); + // Status selector $(".sp-status-selector select:first-child").change(function() { diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php index 4beb1332..0ec169fa 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-details.php @@ -22,6 +22,7 @@ class SP_Meta_Box_List_Details { $taxonomies = get_object_taxonomies( 'sp_list' ); $caption = get_post_meta( $post->ID, 'sp_caption', true ); $team_id = get_post_meta( $post->ID, 'sp_team', true ); + $era = get_post_meta( $post->ID, 'sp_era', true ); $grouping = get_post_meta( $post->ID, 'sp_grouping', true ); $orderby = get_post_meta( $post->ID, 'sp_orderby', true ); $order = get_post_meta( $post->ID, 'sp_order', true ); @@ -42,7 +43,7 @@ class SP_Meta_Box_List_Details { ?>

-

+

'sp_team', @@ -55,6 +56,11 @@ class SP_Meta_Box_List_Details { sp_post_adder( 'sp_team', __( 'Add New', 'sportspress' ) ); endif; ?> +

@@ -110,6 +116,7 @@ class SP_Meta_Box_List_Details { public static function save( $post_id, $post ) { update_post_meta( $post_id, 'sp_caption', esc_attr( sp_array_value( $_POST, 'sp_caption', 0 ) ) ); update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); + update_post_meta( $post_id, 'sp_era', sp_array_value( $_POST, 'sp_era', array() ) ); update_post_meta( $post_id, 'sp_grouping', sp_array_value( $_POST, 'sp_grouping', array() ) ); update_post_meta( $post_id, 'sp_orderby', sp_array_value( $_POST, 'sp_orderby', array() ) ); update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) ); diff --git a/includes/class-sp-player-list.php b/includes/class-sp-player-list.php index 4136f6d6..10428584 100644 --- a/includes/class-sp-player-list.php +++ b/includes/class-sp-player-list.php @@ -39,6 +39,7 @@ class SP_Player_List extends SP_Custom_Post { $season_ids = sp_get_the_term_ids( $this->ID, 'sp_season' ); $position_ids = sp_get_the_term_ids( $this->ID, 'sp_position' ); $team = get_post_meta( $this->ID, 'sp_team', true ); + $era = get_post_meta( $this->ID, 'sp_era', true ); $list_stats = (array)get_post_meta( $this->ID, 'sp_players', true ); $adjustments = get_post_meta( $this->ID, 'sp_adjustments', true ); $orderby = get_post_meta( $this->ID, 'sp_orderby', true ); @@ -95,9 +96,18 @@ class SP_Player_List extends SP_Custom_Post { endif; if ( $team && apply_filters( 'sportspress_has_teams', true ) ): + $team_key = 'sp_team'; + switch ( $era ): + case 'current': + $team_key = 'sp_current_team'; + break; + case 'past': + $team_key = 'sp_past_team'; + break; + endswitch; $args['meta_query'] = array( array( - 'key' => 'sp_current_team', + 'key' => $team_key, 'value' => $team ), );