SportsPress – Sports Club & League Manager - Version 2.6.2

Version Description

  • Fix - Newly added players from past and current team appearing in player lists.
  • Fix - Player lists appearing empty without league, season, and team selected.
Download this release

Release Info

Developer brianmiyaji
Plugin Icon 128x128 SportsPress – Sports Club & League Manager
Version 2.6.2
Comparing to
See all releases

Code changes from version 2.6 to 2.6.2

changelog.txt CHANGED
@@ -1,5 +1,14 @@
1
  == SportsPress Changelog ==
2
 
 
 
 
 
 
 
 
 
 
3
  = 2.6 =
4
  * Feature - Add custom details to events using event specs.
5
  * Feature - Conditional equations for variables.
1
  == SportsPress Changelog ==
2
 
3
+ = 2.6.2 =
4
+ * Fix - Newly added players from past and current team appearing in player lists.
5
+ * Fix - Player lists appearing empty without league, season, and team selected.
6
+
7
+ = 2.6.1 =
8
+ * Fix - Player lists with a team selected showing players from other teams.
9
+ * Fix - REST API endpoints not resolving for players.
10
+ * Fix - Empty system status page.
11
+
12
  = 2.6 =
13
  * Feature - Add custom details to events using event specs.
14
  * Feature - Conditional equations for variables.
includes/admin/class-sp-admin-settings.php CHANGED
@@ -2,10 +2,10 @@
2
  /**
3
  * SportsPress Admin Settings Class.
4
  *
5
- * @author ThemeBoy
6
- * @category Admin
7
- * @package SportsPress/Admin
8
- * @version 2.3
9
  */
10
 
11
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -50,9 +50,7 @@ class SP_Admin_Settings {
50
  $settings[] = include( 'settings/class-sp-settings-licenses.php' );
51
  }
52
 
53
- if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG && current_user_can( 'manage_options' ) ) {
54
- $settings[] = include( 'settings/class-sp-settings-status.php' );
55
- }
56
 
57
  self::$settings = apply_filters( 'sportspress_get_settings_config_pages', $settings );
58
  }
2
  /**
3
  * SportsPress Admin Settings Class.
4
  *
5
+ * @author ThemeBoy
6
+ * @category Admin
7
+ * @package SportsPress/Admin
8
+ * @version 2.6.1
9
  */
10
 
11
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
50
  $settings[] = include( 'settings/class-sp-settings-licenses.php' );
51
  }
52
 
53
+ $settings[] = include( 'settings/class-sp-settings-status.php' );
 
 
54
 
55
  self::$settings = apply_filters( 'sportspress_get_settings_config_pages', $settings );
56
  }
includes/admin/settings/class-sp-settings-status.php CHANGED
@@ -5,7 +5,7 @@
5
  * @author ThemeBoy
6
  * @category Admin
7
  * @package SportsPress/Admin
8
- * @version 2.5
9
  */
10
 
11
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -24,7 +24,10 @@ class SP_Settings_Status extends SP_Settings_Page {
24
  $this->id = 'status';
25
  $this->label = __( 'System Status', 'sportspress' );
26
 
27
- add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 99 );
 
 
 
28
  add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
29
  }
30
 
5
  * @author ThemeBoy
6
  * @category Admin
7
  * @package SportsPress/Admin
8
+ * @version 2.6.1
9
  */
10
 
11
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
24
  $this->id = 'status';
25
  $this->label = __( 'System Status', 'sportspress' );
26
 
27
+ if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG && current_user_can( 'manage_options' ) ) {
28
+ add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 99 );
29
+ }
30
+
31
  add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
32
  }
33
 
includes/api/class-sp-rest-api.php CHANGED
@@ -5,7 +5,7 @@
5
  * The SportsPress REST API class handles all API-related hooks.
6
  *
7
  * @class SP_REST_API
8
- * @version 2.5.5
9
  * @package SportsPress/Classes
10
  * @category Class
11
  * @package SportsPress/API
@@ -49,13 +49,6 @@ class SP_REST_API {
49
  if ( ! class_exists( 'SP_REST_Terms_Controller' ) ) {
50
  require_once dirname( __FILE__ ) . '/class-sp-rest-terms-controller.php';
51
  }
52
-
53
- // Create Player Controller
54
- if ( ! class_exists( 'SP_REST_Players_Controller' ) ) {
55
- require_once dirname( __FILE__ ) . '/class-sp-rest-players-controller.php';
56
- $player_controller = new SP_REST_Players_Controller();
57
- $player_controller->register_routes();
58
- }
59
 
60
  do_action( 'sportspress_create_rest_routes' );
61
  }
5
  * The SportsPress REST API class handles all API-related hooks.
6
  *
7
  * @class SP_REST_API
8
+ * @version 2.6.1
9
  * @package SportsPress/Classes
10
  * @category Class
11
  * @package SportsPress/API
49
  if ( ! class_exists( 'SP_REST_Terms_Controller' ) ) {
50
  require_once dirname( __FILE__ ) . '/class-sp-rest-terms-controller.php';
51
  }
 
 
 
 
 
 
 
52
 
53
  do_action( 'sportspress_create_rest_routes' );
54
  }
includes/api/class-sp-rest-players-controller.php DELETED
@@ -1,178 +0,0 @@
1
- <?php
2
- /**
3
- * REST API Players controller
4
- *
5
- * Handles requests to the /players endpoint.
6
- *
7
- * Adapted from code in WooCommerce (Copyright (c) 2017, Automattic).
8
- *
9
- * @class SP_REST_Players_Controller
10
- * @version 2.5.5
11
- * @package SportsPress/API
12
- * @category API
13
- * @author WooThemes
14
- */
15
-
16
- if ( ! defined( 'ABSPATH' ) ) {
17
- exit;
18
- }
19
-
20
- class SP_REST_Players_Controller extends SP_REST_Posts_Controller {
21
-
22
- /**
23
- * Route base.
24
- *
25
- * @var string
26
- */
27
- protected $rest_base = 'players';
28
-
29
- /**
30
- * Post type.
31
- *
32
- * @var string
33
- */
34
- protected $post_type = 'sp_player';
35
-
36
- public function __construct() {
37
- parent::__construct( $this->post_type );
38
- $this->namespace = 'sportspress/v2';
39
- }
40
-
41
- /**
42
- * Register the routes for players.
43
- */
44
- public function register_routes() {
45
- register_rest_route( $this->namespace, '/' . $this->rest_base, array(
46
- array(
47
- 'methods' => WP_REST_Server::READABLE,
48
- 'callback' => array( $this, 'get_items' ),
49
- 'args' => $this->get_collection_params(),
50
- )
51
- ) );
52
- }
53
-
54
- /**
55
- * Get a collection of posts.
56
- *
57
- * @param WP_REST_Request $request Full details about the request.
58
- * @return WP_Error|WP_REST_Response
59
- */
60
- public function get_items( $request ) {
61
- $query_args = $this->prepare_objects_query( $request );
62
- $query_results = $this->get_objects( $query_args );
63
-
64
- $objects = array();
65
- foreach ( $query_results['objects'] as $object ) {
66
- $data = $this->prepare_item_for_response( $object, $request );
67
- $objects[] = $this->prepare_response_for_collection( $data );
68
- }
69
-
70
- $page = (int) $query_args['paged'];
71
- $max_pages = $query_results['pages'];
72
-
73
- $response = rest_ensure_response( $objects );
74
- $response->header( 'X-WP-Total', $query_results['total'] );
75
- $response->header( 'X-WP-TotalPages', (int) $max_pages );
76
-
77
- $base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ) );
78
-
79
- if ( $page > 1 ) {
80
- $prev_page = $page - 1;
81
- if ( $prev_page > $max_pages ) {
82
- $prev_page = $max_pages;
83
- }
84
- $prev_link = add_query_arg( 'page', $prev_page, $base );
85
- $response->link_header( 'prev', $prev_link );
86
- }
87
- if ( $max_pages > $page ) {
88
- $next_page = $page + 1;
89
- $next_link = add_query_arg( 'page', $next_page, $base );
90
- $response->link_header( 'next', $next_link );
91
- }
92
-
93
- return $response;
94
- }
95
-
96
- /**
97
- * Prepare objects query.
98
- *
99
- * @since 2.5
100
- * @param WP_REST_Request $request Full details about the request.
101
- * @return array
102
- */
103
- protected function prepare_objects_query( $request ) {
104
- $args = parent::prepare_objects_query( $request );
105
-
106
- //Filter players by league
107
- if ( ! empty( $request['league'] ) ) {
108
- $args['tax_query'][] = array(
109
- 'taxonomy' => 'sp_league',
110
- 'field' => 'name',
111
- 'terms' => $request['league'],
112
- );
113
- }
114
-
115
- //Filter players by season
116
- if ( ! empty( $request['season'] ) ) {
117
- $args['tax_query'][] = array(
118
- 'taxonomy' => 'sp_season',
119
- 'field' => 'name',
120
- 'terms' => $request['season'],
121
- );
122
- }
123
-
124
- // Filter players by team id
125
- if ( ! empty( $request['team_id'] ) ) {
126
- $args['meta_query'][] = array(
127
- 'key' => 'sp_team',
128
- 'value' => $request['team_id']
129
- );
130
- }
131
-
132
- // Filter players by current team id
133
- if ( ! empty( $request['current_team_id'] ) ) {
134
- $args['meta_query'][] = array(
135
- 'key' => 'sp_current_team',
136
- 'value' => $request['current_team_id']
137
- );
138
- }
139
-
140
- // Filter players by past team id
141
- if ( ! empty( $request['past_team_id'] ) ) {
142
- $args['meta_query'][] = array(
143
- 'key' => 'sp_past_team',
144
- 'value' => $request['past_team_id']
145
- );
146
- }
147
-
148
- return $this->prepare_items_query( $args, $request );
149
- }
150
-
151
- /**
152
- * Get objects.
153
- *
154
- * @since 3.0.0
155
- * @param array $query_args Query args.
156
- * @return array
157
- */
158
- protected function get_objects( $query_args ) {
159
- $query = new WP_Query();
160
- $result = $query->query( $query_args );
161
-
162
- $total_posts = $query->found_posts;
163
- if ( $total_posts < 1 ) {
164
- // Out-of-bounds, run the query again without LIMIT for total count.
165
- unset( $query_args['paged'] );
166
- $count_query = new WP_Query();
167
- $count_query->query( $query_args );
168
- $total_posts = $count_query->found_posts;
169
- }
170
-
171
- return array(
172
- 'objects' => $result,
173
- 'total' => (int) $total_posts,
174
- 'pages' => (int) ceil( $total_posts / (int) $query->query_vars['posts_per_page'] ),
175
- );
176
- }
177
-
178
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/api/class-sp-rest-posts-controller.php CHANGED
@@ -6,58 +6,5 @@ if ( class_exists( 'WP_REST_Posts_Controller' ) ) {
6
  parent::__construct( $post_type );
7
  $this->namespace = 'sportspress/v2';
8
  }
9
-
10
- /**
11
- * Prepare objects query.
12
- *
13
- * @since 2.5.5
14
- * @param WP_REST_Request $request Full details about the request.
15
- * @return array
16
- */
17
- protected function prepare_objects_query( $request ) {
18
- $args = array();
19
- $args['offset'] = $request['offset'];
20
- $args['order'] = $request['order'];
21
- $args['orderby'] = $request['orderby'];
22
- $args['paged'] = $request['page'];
23
- $args['post__in'] = $request['include'];
24
- $args['post__not_in'] = $request['exclude'];
25
- $args['posts_per_page'] = $request['per_page'];
26
- $args['name'] = $request['slug'];
27
- $args['post_parent__in'] = $request['parent'];
28
- $args['post_parent__not_in'] = $request['parent_exclude'];
29
- $args['s'] = $request['search'];
30
-
31
- if ( 'date' === $args['orderby'] ) {
32
- $args['orderby'] = 'date ID';
33
- }
34
-
35
- $args['date_query'] = array();
36
- // Set before into date query. Date query must be specified as an array of an array.
37
- if ( isset( $request['before'] ) ) {
38
- $args['date_query'][0]['before'] = $request['before'];
39
- }
40
-
41
- // Set after into date query. Date query must be specified as an array of an array.
42
- if ( isset( $request['after'] ) ) {
43
- $args['date_query'][0]['after'] = $request['after'];
44
- }
45
-
46
- // Force the post_type argument, since it's not a user input variable.
47
- $args['post_type'] = $this->post_type;
48
-
49
- /**
50
- * Filter the query arguments for a request.
51
- *
52
- * Enables adding extra arguments or setting defaults for a post
53
- * collection request.
54
- *
55
- * @param array $args Key value array of query var to query value.
56
- * @param WP_REST_Request $request The request used.
57
- */
58
- $args = apply_filters( "sportspress_rest_{$this->post_type}_object_query", $args, $request );
59
-
60
- return $this->prepare_items_query( $args, $request );
61
- }
62
  }
63
  }
6
  parent::__construct( $post_type );
7
  $this->namespace = 'sportspress/v2';
8
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
10
  }
includes/class-sp-player-list.php CHANGED
@@ -5,7 +5,7 @@
5
  * The SportsPress player list class handles individual player list data.
6
  *
7
  * @class SP_Player_List
8
- * @version 2.6
9
  * @package SportsPress/Classes
10
  * @category Class
11
  * @author ThemeBoy
@@ -146,7 +146,7 @@ class SP_Player_List extends SP_Secondary_Post {
146
 
147
  $players = (array) get_posts( $args );
148
 
149
- $players = apply_filters( 'sportspress_player_list_players', $players, $args, $team );
150
 
151
  if ( $players && is_array( $players ) ) {
152
  foreach ( $players as $player ) {
5
  * The SportsPress player list class handles individual player list data.
6
  *
7
  * @class SP_Player_List
8
+ * @version 2.6.2
9
  * @package SportsPress/Classes
10
  * @category Class
11
  * @author ThemeBoy
146
 
147
  $players = (array) get_posts( $args );
148
 
149
+ $players = apply_filters( 'sportspress_player_list_players', $players, $args, $team, $team_key );
150
 
151
  if ( $players && is_array( $players ) ) {
152
  foreach ( $players as $player ) {
includes/class-sp-player.php CHANGED
@@ -5,7 +5,7 @@
5
  * The SportsPress player class handles individual player data.
6
  *
7
  * @class SP_Player
8
- * @version 2.6
9
  * @package SportsPress/Classes
10
  * @category Class
11
  * @author ThemeBoy
@@ -126,10 +126,10 @@ class SP_Player extends SP_Custom_Post {
126
  $seasons = (array)get_the_terms( $this->ID, 'sp_season', $args );
127
  $metrics = (array)get_post_meta( $this->ID, 'sp_metrics', true );
128
  $stats = (array)get_post_meta( $this->ID, 'sp_statistics', true );
129
- $leagues = sp_array_value( (array)get_post_meta( $this->ID, 'sp_leagues', true ), $league_id, array() );
130
  $manual_columns = 'manual' == get_option( 'sportspress_player_columns', 'auto' ) ? true : false;
131
 
132
- $season_ids = wp_list_pluck( $seasons, 'term_id' );
133
  $season_order = array_flip( $season_ids );
134
  foreach ( $season_order as $season_id => $val ) {
135
  $season_order[ $season_id ] = null;
5
  * The SportsPress player class handles individual player data.
6
  *
7
  * @class SP_Player
8
+ * @version 2.6.1
9
  * @package SportsPress/Classes
10
  * @category Class
11
  * @author ThemeBoy
126
  $seasons = (array)get_the_terms( $this->ID, 'sp_season', $args );
127
  $metrics = (array)get_post_meta( $this->ID, 'sp_metrics', true );
128
  $stats = (array)get_post_meta( $this->ID, 'sp_statistics', true );
129
+ $leagues = (array) sp_array_value( (array)get_post_meta( $this->ID, 'sp_leagues', true ), $league_id );
130
  $manual_columns = 'manual' == get_option( 'sportspress_player_columns', 'auto' ) ? true : false;
131
 
132
+ $season_ids = array_filter(wp_list_pluck( $seasons, 'term_id' ));
133
  $season_order = array_flip( $season_ids );
134
  foreach ( $season_order as $season_id => $val ) {
135
  $season_order[ $season_id ] = null;
includes/class-sp-post-types.php CHANGED
@@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
9
  * Registers post types and taxonomies
10
  *
11
  * @class SP_Post_types
12
- * @version 2.6
13
  * @package SportsPress/Classes
14
  * @category Class
15
  * @author ThemeBoy
@@ -512,7 +512,7 @@ class SP_Post_types {
512
  'show_in_nav_menus' => true,
513
  'menu_icon' => 'dashicons-groups',
514
  'show_in_rest' => true,
515
- 'rest_controller_class' => 'SP_REST_Players_Controller',
516
  'rest_base' => 'players',
517
  )
518
  )
9
  * Registers post types and taxonomies
10
  *
11
  * @class SP_Post_types
12
+ * @version 2.6.1
13
  * @package SportsPress/Classes
14
  * @category Class
15
  * @author ThemeBoy
512
  'show_in_nav_menus' => true,
513
  'menu_icon' => 'dashicons-groups',
514
  'show_in_rest' => true,
515
+ 'rest_controller_class' => 'SP_REST_Posts_Controller',
516
  'rest_base' => 'players',
517
  )
518
  )
modules/sportspress-player-assignments.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://themeboy.com/
5
  Description: Add player assignments support to SportsPress.
6
  Author: Savvas
7
  Author URI: http://themeboy.com/
8
- Version: 2.6
9
  */
10
  // Exit if accessed directly
11
  if ( ! defined( 'ABSPATH' ) ) exit;
@@ -14,7 +14,7 @@ if ( ! class_exists( 'SportsPress_Player_Assignments' ) ) :
14
  * Main SportsPress Player Assignments Class
15
  *
16
  * @class SportsPress_Player_Assignments
17
- * @version 2.6
18
  */
19
  class SportsPress_Player_Assignments {
20
  /**
@@ -28,15 +28,15 @@ class SportsPress_Player_Assignments {
28
  add_action( 'sportspress_process_sp_player_meta', array( $this, 'save' ) );
29
 
30
  // Filters
31
- add_filter( 'sportspress_player_list_args', array( $this, 'add_args' ), 10 );
32
- add_filter( 'sportspress_player_list_players', array( $this, 'add_players' ), 10, 3 );
33
  }
34
  /**
35
  * Define constants.
36
  */
37
  private function define_constants() {
38
  if ( !defined( 'SP_PLAYER_ASSIGNMENTS_VERSION' ) )
39
- define( 'SP_PLAYER_ASSIGNMENTS_VERSION', '2.6' );
40
  if ( !defined( 'SP_PLAYER_ASSIGNMENTS_URL' ) )
41
  define( 'SP_PLAYER_ASSIGNMENTS_URL', plugin_dir_url( __FILE__ ) );
42
  if ( !defined( 'SP_PLAYER_ASSIGNMENTS_DIR' ) )
@@ -66,16 +66,27 @@ class SportsPress_Player_Assignments {
66
  /**
67
  * Add args to filter out assigned players
68
  */
69
- public function add_args( $args = array() ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  $args['meta_query'][] = array(
71
  'key' => 'sp_assignments',
72
  'value' => '',
73
  'compare' => 'NOT EXISTS',
74
  );
75
 
76
- $args['meta_query'][] = array(
77
- 'relation' => 'OR',
78
- );
79
 
80
  return $args;
81
  }
@@ -83,7 +94,9 @@ class SportsPress_Player_Assignments {
83
  /**
84
  * Add assigned players to player list
85
  */
86
- public function add_players( $players = array(), $args = array(), $team = false ) {
 
 
87
  $tax_query = (array) sp_array_value( $args, 'tax_query', array() );
88
  $league_ids = array();
89
  $season_ids = array();
@@ -93,6 +106,8 @@ class SportsPress_Player_Assignments {
93
  if ( 'sp_season' === sp_array_value( $param, 'taxonomy' ) ) $season_ids = sp_array_value( $param, 'terms', array() );
94
  }
95
 
 
 
96
  $assignments = array();
97
  foreach ( $league_ids as $l_id ) {
98
  foreach ( $season_ids as $s_id ) {
@@ -102,13 +117,22 @@ class SportsPress_Player_Assignments {
102
  }
103
  }
104
 
105
- $args['meta_query'] = array(
106
- array(
107
- 'key' => 'sp_assignments',
108
- 'value' => $assignments,
109
- 'compare' => 'IN'
110
- ),
111
- );
 
 
 
 
 
 
 
 
 
112
 
113
  $assigned_players = (array) get_posts( $args );
114
 
@@ -132,4 +156,4 @@ class SportsPress_Player_Assignments {
132
  }
133
  endif;
134
 
135
- new SportsPress_Player_Assignments();
5
  Description: Add player assignments support to SportsPress.
6
  Author: Savvas
7
  Author URI: http://themeboy.com/
8
+ Version: 2.6.2
9
  */
10
  // Exit if accessed directly
11
  if ( ! defined( 'ABSPATH' ) ) exit;
14
  * Main SportsPress Player Assignments Class
15
  *
16
  * @class SportsPress_Player_Assignments
17
+ * @version 2.6.2
18
  */
19
  class SportsPress_Player_Assignments {
20
  /**
28
  add_action( 'sportspress_process_sp_player_meta', array( $this, 'save' ) );
29
 
30
  // Filters
31
+ add_filter( 'sportspress_player_list_args', array( $this, 'add_args' ), 10, 2 );
32
+ add_filter( 'sportspress_player_list_players', array( $this, 'add_players' ), 10, 4 );
33
  }
34
  /**
35
  * Define constants.
36
  */
37
  private function define_constants() {
38
  if ( !defined( 'SP_PLAYER_ASSIGNMENTS_VERSION' ) )
39
+ define( 'SP_PLAYER_ASSIGNMENTS_VERSION', '2.6.2' );
40
  if ( !defined( 'SP_PLAYER_ASSIGNMENTS_URL' ) )
41
  define( 'SP_PLAYER_ASSIGNMENTS_URL', plugin_dir_url( __FILE__ ) );
42
  if ( !defined( 'SP_PLAYER_ASSIGNMENTS_DIR' ) )
66
  /**
67
  * Add args to filter out assigned players
68
  */
69
+ public function add_args( $args = array(), $team = false ) {
70
+ if ( ! $team ) return $args;
71
+
72
+ $tax_query = (array) sp_array_value( $args, 'tax_query', array() );
73
+ $league_ids = array();
74
+ $season_ids = array();
75
+
76
+ foreach ( $tax_query as $param ) {
77
+ if ( 'sp_league' === sp_array_value( $param, 'taxonomy' ) ) $league_ids = sp_array_value( $param, 'terms', array() );
78
+ if ( 'sp_season' === sp_array_value( $param, 'taxonomy' ) ) $season_ids = sp_array_value( $param, 'terms', array() );
79
+ }
80
+
81
+ if ( empty( $league_ids ) || empty( $season_ids ) ) return $args;
82
+
83
  $args['meta_query'][] = array(
84
  'key' => 'sp_assignments',
85
  'value' => '',
86
  'compare' => 'NOT EXISTS',
87
  );
88
 
89
+ $args['meta_query']['relation'] = 'AND';
 
 
90
 
91
  return $args;
92
  }
94
  /**
95
  * Add assigned players to player list
96
  */
97
+ public function add_players( $players = array(), $args = array(), $team = false, $team_key = 'sp_team' ) {
98
+ if ( ! $team ) return $players;
99
+
100
  $tax_query = (array) sp_array_value( $args, 'tax_query', array() );
101
  $league_ids = array();
102
  $season_ids = array();
106
  if ( 'sp_season' === sp_array_value( $param, 'taxonomy' ) ) $season_ids = sp_array_value( $param, 'terms', array() );
107
  }
108
 
109
+ if ( empty( $league_ids ) || empty( $season_ids ) ) return $players;
110
+
111
  $assignments = array();
112
  foreach ( $league_ids as $l_id ) {
113
  foreach ( $season_ids as $s_id ) {
117
  }
118
  }
119
 
120
+ if ( sizeof( $assignments ) ) {
121
+ $args['meta_query'] = array(
122
+ 'relation' => 'AND',
123
+
124
+ array(
125
+ 'key' => 'sp_assignments',
126
+ 'value' => $assignments,
127
+ 'compare' => 'IN',
128
+ ),
129
+
130
+ array(
131
+ 'key' => $team_key,
132
+ 'value' => $team,
133
+ ),
134
+ );
135
+ }
136
 
137
  $assigned_players = (array) get_posts( $args );
138
 
156
  }
157
  endif;
158
 
159
+ new SportsPress_Player_Assignments();
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: calendars, club, club management, esports, events, fixtures, leagues, leag
4
  Donate link: http://tboy.co/donate
5
  Requires at least: 3.8
6
  Tested up to: 4.9
7
- Stable tag: 2.6
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -237,6 +237,15 @@ When you upgrade to one of the SportsPress Pro licenses, you can simply activate
237
 
238
  == Changelog ==
239
 
 
 
 
 
 
 
 
 
 
240
  = 2.6 =
241
  * Feature - Add custom details to events using event specs.
242
  * Feature - Conditional equations for variables.
4
  Donate link: http://tboy.co/donate
5
  Requires at least: 3.8
6
  Tested up to: 4.9
7
+ Stable tag: 2.6.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
237
 
238
  == Changelog ==
239
 
240
+ = 2.6.2 =
241
+ * Fix - Newly added players from past and current team appearing in player lists.
242
+ * Fix - Player lists appearing empty without league, season, and team selected.
243
+
244
+ = 2.6.1 =
245
+ * Fix - Player lists with a team selected showing players from other teams.
246
+ * Fix - REST API endpoints not resolving for players.
247
+ * Fix - Empty system status page.
248
+
249
  = 2.6 =
250
  * Feature - Add custom details to events using event specs.
251
  * Feature - Conditional equations for variables.
sportspress.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: SportsPress
4
  * Plugin URI: http://themeboy.com/sportspress/
5
  * Description: Manage your club and its players, staff, events, league tables, and player lists.
6
- * Version: 2.6
7
  * Author: ThemeBoy
8
  * Author URI: http://themeboy.com
9
  * Requires at least: 3.8
@@ -26,14 +26,14 @@ if ( ! class_exists( 'SportsPress' ) ) :
26
  * Main SportsPress Class
27
  *
28
  * @class SportsPress
29
- * @version 2.6
30
  */
31
  final class SportsPress {
32
 
33
  /**
34
  * @var string
35
  */
36
- public $version = '2.6';
37
 
38
  /**
39
  * @var SportsPress The single instance of the class
3
  * Plugin Name: SportsPress
4
  * Plugin URI: http://themeboy.com/sportspress/
5
  * Description: Manage your club and its players, staff, events, league tables, and player lists.
6
+ * Version: 2.6.2
7
  * Author: ThemeBoy
8
  * Author URI: http://themeboy.com
9
  * Requires at least: 3.8
26
  * Main SportsPress Class
27
  *
28
  * @class SportsPress
29
+ * @version 2.6.2
30
  */
31
  final class SportsPress {
32
 
33
  /**
34
  * @var string
35
  */
36
+ public $version = '2.6.2';
37
 
38
  /**
39
  * @var SportsPress The single instance of the class
templates/player-statistics.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @author ThemeBoy
6
  * @package SportsPress/Templates
7
- * @version 2.6
8
  */
9
 
10
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -19,14 +19,16 @@ $scrollable = get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'ye
19
  $show_career_totals = 'yes' === get_option( 'sportspress_player_show_career_total', 'no' ) ? true : false;
20
  $sections = get_option( 'sportspress_player_performance_sections', -1 );
21
  $show_teams = apply_filters( 'sportspress_player_team_statistics', true );
22
- $leagues = get_the_terms( $id, 'sp_league' );
23
 
24
  // Sort Leagues by User Defined Order (PHP5.2 supported)
25
  foreach ( $leagues as $key => $league ) {
26
  $leagues[ $key ]->sp_order = get_term_meta ( $league->term_id , 'sp_order', true );
27
  }
28
- function sortByOrder($a, $b) {
29
- return (int) $a->sp_order - (int) $b->sp_order;
 
 
30
  }
31
  usort($leagues, 'sortByOrder');
32
 
4
  *
5
  * @author ThemeBoy
6
  * @package SportsPress/Templates
7
+ * @version 2.6.1
8
  */
9
 
10
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
19
  $show_career_totals = 'yes' === get_option( 'sportspress_player_show_career_total', 'no' ) ? true : false;
20
  $sections = get_option( 'sportspress_player_performance_sections', -1 );
21
  $show_teams = apply_filters( 'sportspress_player_team_statistics', true );
22
+ $leagues = array_filter( ( array ) get_the_terms( $id, 'sp_league' ) );
23
 
24
  // Sort Leagues by User Defined Order (PHP5.2 supported)
25
  foreach ( $leagues as $key => $league ) {
26
  $leagues[ $key ]->sp_order = get_term_meta ( $league->term_id , 'sp_order', true );
27
  }
28
+ if ( ! function_exists( 'sortByOrder' ) ) {
29
+ function sortByOrder($a, $b) {
30
+ return (int) $a->sp_order - (int) $b->sp_order;
31
+ }
32
  }
33
  usort($leagues, 'sortByOrder');
34