From 9f6508c649fad77d42eb71c04b4eb341089e4d80 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Thu, 25 Feb 2016 20:27:14 +1100 Subject: [PATCH] Apply filters to players in events --- modules/sportspress-lazy-loading.php | 30 +++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/modules/sportspress-lazy-loading.php b/modules/sportspress-lazy-loading.php index 373d5a84..b5ee47b3 100644 --- a/modules/sportspress-lazy-loading.php +++ b/modules/sportspress-lazy-loading.php @@ -37,8 +37,19 @@ class SportsPress_Lazy_Loading { check_ajax_referer( 'sp-get-players', 'nonce' ); $team = sp_array_value( $_POST, 'team' ); - $league = sp_array_value( $_POST, 'league' ); - $season = sp_array_value( $_POST, 'season' ); + + if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_league', 'no' ) ) { + $league = sp_array_value( $_POST, 'league' ); + } else { + $league = false; + } + + if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_season', 'no' ) ) { + $season = sp_array_value( $_POST, 'season' ); + } else { + $season = false; + } + $index = sp_array_value( $_POST, 'index', 1 ); $selected = sp_array_value( $_POST, 'selected', array() ); @@ -109,9 +120,18 @@ class SportsPress_Lazy_Loading { } else { $selected = sp_array_between( (array)get_post_meta( $post_id, $post_type, false ), 0, $index ); } - - $leagues = get_the_terms( $post_id, 'sp_league' ); - $seasons = get_the_terms( $post_id, 'sp_season' ); + + if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_league', 'no' ) ) { + $leagues = get_the_terms( $post_id, 'sp_league' ); + } else { + $leagues = false; + } + + if ( 'yes' == get_option( 'sportspress_event_filter_teams_by_season', 'no' ) ) { + $seasons = get_the_terms( $post_id, 'sp_season' ); + } else { + $seasons = false; + } $args = array( 'orderby' => 'menu_order',