From 52e8c866a19018c02a92d0f7f9b8beedcb5d7a31 Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Fri, 11 May 2018 09:49:41 +1000 Subject: [PATCH] Preserve team meta key in additional players query --- includes/class-sp-player-list.php | 2 +- modules/sportspress-player-assignments.php | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/includes/class-sp-player-list.php b/includes/class-sp-player-list.php index f4c1478b..c897c688 100644 --- a/includes/class-sp-player-list.php +++ b/includes/class-sp-player-list.php @@ -146,7 +146,7 @@ class SP_Player_List extends SP_Secondary_Post { $players = (array) get_posts( $args ); - $players = apply_filters( 'sportspress_player_list_players', $players, $args, $team ); + $players = apply_filters( 'sportspress_player_list_players', $players, $args, $team, $team_key ); if ( $players && is_array( $players ) ) { foreach ( $players as $player ) { diff --git a/modules/sportspress-player-assignments.php b/modules/sportspress-player-assignments.php index a19c919a..05e9d149 100644 --- a/modules/sportspress-player-assignments.php +++ b/modules/sportspress-player-assignments.php @@ -5,7 +5,7 @@ Plugin URI: http://themeboy.com/ Description: Add player assignments support to SportsPress. Author: Savvas Author URI: http://themeboy.com/ -Version: 2.6.1 +Version: 2.6.2 */ // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; @@ -14,7 +14,7 @@ if ( ! class_exists( 'SportsPress_Player_Assignments' ) ) : * Main SportsPress Player Assignments Class * * @class SportsPress_Player_Assignments - * @version 2.6.1 + * @version 2.6.2 */ class SportsPress_Player_Assignments { /** @@ -29,14 +29,14 @@ class SportsPress_Player_Assignments { // Filters add_filter( 'sportspress_player_list_args', array( $this, 'add_args' ), 10, 2 ); - add_filter( 'sportspress_player_list_players', array( $this, 'add_players' ), 10, 3 ); + add_filter( 'sportspress_player_list_players', array( $this, 'add_players' ), 10, 4 ); } /** * Define constants. */ private function define_constants() { if ( !defined( 'SP_PLAYER_ASSIGNMENTS_VERSION' ) ) - define( 'SP_PLAYER_ASSIGNMENTS_VERSION', '2.6.1' ); + define( 'SP_PLAYER_ASSIGNMENTS_VERSION', '2.6.2' ); if ( !defined( 'SP_PLAYER_ASSIGNMENTS_URL' ) ) define( 'SP_PLAYER_ASSIGNMENTS_URL', plugin_dir_url( __FILE__ ) ); if ( !defined( 'SP_PLAYER_ASSIGNMENTS_DIR' ) ) @@ -94,7 +94,7 @@ class SportsPress_Player_Assignments { /** * Add assigned players to player list */ - public function add_players( $players = array(), $args = array(), $team = false ) { + public function add_players( $players = array(), $args = array(), $team = false, $team_key = 'sp_team' ) { if ( ! $team ) return $players; $tax_query = (array) sp_array_value( $args, 'tax_query', array() ); @@ -119,10 +119,17 @@ class SportsPress_Player_Assignments { if ( sizeof( $assignments ) ) { $args['meta_query'] = array( + 'relation' => 'AND', + array( 'key' => 'sp_assignments', 'value' => $assignments, - 'compare' => 'IN' + 'compare' => 'IN', + ), + + array( + 'key' => $team_key, + 'value' => $team, ), ); }