davvalent commited on 2022-08-17 05:20:30
Showing 2 changed files, with 924 additions and 0 deletions.
| ... | ... |
@@ -15,3 +15,4 @@ |
| 15 | 15 |
!wp-content/themes/rookie/framework.css |
| 16 | 16 |
!wp-content/plugins/sportspress/templates/event-fixtures-results.php |
| 17 | 17 |
!wp-content/plugins/sportspress/templates/player-list.php |
| 18 |
+!wp-content/plugins/sportspress/includes/api/class-sp-rest-api.php |
|
| 18 | 19 |
\ No newline at end of file |
| ... | ... |
@@ -0,0 +1,923 @@ |
| 1 |
+<?php |
|
| 2 |
+/** |
|
| 3 |
+ * REST API Class |
|
| 4 |
+ * |
|
| 5 |
+ * The SportsPress REST API class handles all API-related hooks. |
|
| 6 |
+ * |
|
| 7 |
+ * @class SP_REST_API |
|
| 8 |
+ * @version 2.7.9 |
|
| 9 |
+ * @package SportsPress/Classes |
|
| 10 |
+ * @category Class |
|
| 11 |
+ * @package SportsPress/API |
|
| 12 |
+ * @author ThemeBoy |
|
| 13 |
+ */ |
|
| 14 |
+ |
|
| 15 |
+if ( ! defined( 'ABSPATH' ) ) {
|
|
| 16 |
+ exit; // Exit if accessed directly |
|
| 17 |
+} |
|
| 18 |
+ |
|
| 19 |
+if ( ! class_exists( 'SP_REST_API' ) ) : |
|
| 20 |
+ |
|
| 21 |
+ /** |
|
| 22 |
+ * SP_REST_API Class |
|
| 23 |
+ */ |
|
| 24 |
+ class SP_REST_API {
|
|
| 25 |
+ |
|
| 26 |
+ /** |
|
| 27 |
+ * Constructor. |
|
| 28 |
+ */ |
|
| 29 |
+ public function __construct() {
|
|
| 30 |
+ // Create REST routes |
|
| 31 |
+ add_action( 'rest_api_init', array( $this, 'create_routes' ) ); |
|
| 32 |
+ add_action( 'rest_api_init', array( $this, 'register_fields' ), 0 ); |
|
| 33 |
+ |
|
| 34 |
+ // Add filter for post meta query |
|
| 35 |
+ add_filter( 'rest_query_vars', array( $this, 'meta_query' ) ); |
|
| 36 |
+ |
|
| 37 |
+ // Add filters to query scheduled events |
|
| 38 |
+ add_filter( 'rest_sp_event_query', array( $this, 'event_query' ) ); |
|
| 39 |
+ add_filter( 'rest_query_vars', array( $this, 'query_vars' ) ); |
|
| 40 |
+ } |
|
| 41 |
+ |
|
| 42 |
+ /** |
|
| 43 |
+ * Create REST routes. |
|
| 44 |
+ */ |
|
| 45 |
+ public static function create_routes() {
|
|
| 46 |
+ |
|
| 47 |
+ if ( ! class_exists( 'SP_REST_Posts_Controller' ) ) {
|
|
| 48 |
+ require_once dirname( __FILE__ ) . '/class-sp-rest-posts-controller.php'; |
|
| 49 |
+ } |
|
| 50 |
+ |
|
| 51 |
+ if ( ! class_exists( 'SP_REST_Terms_Controller' ) ) {
|
|
| 52 |
+ require_once dirname( __FILE__ ) . '/class-sp-rest-terms-controller.php'; |
|
| 53 |
+ } |
|
| 54 |
+ |
|
| 55 |
+ do_action( 'sportspress_create_rest_routes' ); |
|
| 56 |
+ } |
|
| 57 |
+ |
|
| 58 |
+ /** |
|
| 59 |
+ * Register REST fields. |
|
| 60 |
+ */ |
|
| 61 |
+ public static function register_fields() {
|
|
| 62 |
+ if ( ! function_exists( 'register_rest_field' ) ) {
|
|
| 63 |
+ return; |
|
| 64 |
+ } |
|
| 65 |
+ |
|
| 66 |
+ register_rest_field( |
|
| 67 |
+ 'sp_event', |
|
| 68 |
+ 'teams', |
|
| 69 |
+ array( |
|
| 70 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 71 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 72 |
+ 'schema' => array( |
|
| 73 |
+ 'description' => esc_attr__( 'Teams', 'sportspress' ), |
|
| 74 |
+ 'type' => 'array', |
|
| 75 |
+ 'context' => array( 'view', 'edit', 'embed' ), |
|
| 76 |
+ 'arg_options' => array( |
|
| 77 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 78 |
+ ), |
|
| 79 |
+ ), |
|
| 80 |
+ ) |
|
| 81 |
+ ); |
|
| 82 |
+ |
|
| 83 |
+ register_rest_field( |
|
| 84 |
+ 'sp_event', |
|
| 85 |
+ 'main_results', |
|
| 86 |
+ array( |
|
| 87 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 88 |
+ 'schema' => array( |
|
| 89 |
+ 'description' => esc_attr__( 'Main Results', 'sportspress' ), |
|
| 90 |
+ 'type' => 'array', |
|
| 91 |
+ 'context' => array( 'view', 'embed' ), |
|
| 92 |
+ 'arg_options' => array( |
|
| 93 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 94 |
+ ), |
|
| 95 |
+ ), |
|
| 96 |
+ ) |
|
| 97 |
+ ); |
|
| 98 |
+ |
|
| 99 |
+ register_rest_field( |
|
| 100 |
+ 'sp_event', |
|
| 101 |
+ 'outcome', |
|
| 102 |
+ array( |
|
| 103 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 104 |
+ 'schema' => array( |
|
| 105 |
+ 'description' => esc_attr__( 'Outcome', 'sportspress' ), |
|
| 106 |
+ 'type' => 'array', |
|
| 107 |
+ 'context' => array( 'view', 'embed' ), |
|
| 108 |
+ 'arg_options' => array( |
|
| 109 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 110 |
+ ), |
|
| 111 |
+ ), |
|
| 112 |
+ ) |
|
| 113 |
+ ); |
|
| 114 |
+ |
|
| 115 |
+ register_rest_field( |
|
| 116 |
+ 'sp_event', |
|
| 117 |
+ 'winner', |
|
| 118 |
+ array( |
|
| 119 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 120 |
+ 'schema' => array( |
|
| 121 |
+ 'description' => esc_attr__( 'Winner', 'sportspress' ), |
|
| 122 |
+ 'type' => 'integer', |
|
| 123 |
+ 'context' => array( 'view', 'embed' ), |
|
| 124 |
+ 'arg_options' => array( |
|
| 125 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 126 |
+ ), |
|
| 127 |
+ ), |
|
| 128 |
+ ) |
|
| 129 |
+ ); |
|
| 130 |
+ |
|
| 131 |
+ register_rest_field( |
|
| 132 |
+ 'sp_event', |
|
| 133 |
+ 'format', |
|
| 134 |
+ array( |
|
| 135 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 136 |
+ 'update_callback' => 'SP_REST_API::update_post_meta', |
|
| 137 |
+ 'schema' => array( |
|
| 138 |
+ 'description' => esc_attr__( 'Format', 'sportspress' ), |
|
| 139 |
+ 'type' => 'string', |
|
| 140 |
+ 'context' => array( 'view', 'edit', 'embed' ), |
|
| 141 |
+ 'arg_options' => array( |
|
| 142 |
+ 'sanitize_callback' => 'sanitize_text_field', |
|
| 143 |
+ ), |
|
| 144 |
+ ), |
|
| 145 |
+ ) |
|
| 146 |
+ ); |
|
| 147 |
+ |
|
| 148 |
+ register_rest_field( |
|
| 149 |
+ 'sp_event', |
|
| 150 |
+ 'mode', |
|
| 151 |
+ array( |
|
| 152 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 153 |
+ 'update_callback' => 'SP_REST_API::update_post_meta', |
|
| 154 |
+ 'schema' => array( |
|
| 155 |
+ 'description' => esc_attr__( 'Mode', 'sportspress' ), |
|
| 156 |
+ 'type' => 'string', |
|
| 157 |
+ 'context' => array( 'view', 'edit', 'embed' ), |
|
| 158 |
+ 'arg_options' => array( |
|
| 159 |
+ 'sanitize_callback' => 'sanitize_text_field', |
|
| 160 |
+ ), |
|
| 161 |
+ ), |
|
| 162 |
+ ) |
|
| 163 |
+ ); |
|
| 164 |
+ |
|
| 165 |
+ register_rest_field( |
|
| 166 |
+ 'sp_event', |
|
| 167 |
+ 'day', |
|
| 168 |
+ array( |
|
| 169 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 170 |
+ 'update_callback' => 'SP_REST_API::update_post_meta', |
|
| 171 |
+ 'schema' => array( |
|
| 172 |
+ 'description' => esc_attr__( 'Match Day', 'sportspress' ), |
|
| 173 |
+ 'type' => 'string', |
|
| 174 |
+ 'context' => array( 'view', 'edit', 'embed' ), |
|
| 175 |
+ 'arg_options' => array( |
|
| 176 |
+ 'sanitize_callback' => 'sanitize_text_field', |
|
| 177 |
+ ), |
|
| 178 |
+ ), |
|
| 179 |
+ ) |
|
| 180 |
+ ); |
|
| 181 |
+ |
|
| 182 |
+ register_rest_field( |
|
| 183 |
+ 'sp_event', |
|
| 184 |
+ 'minutes', |
|
| 185 |
+ array( |
|
| 186 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 187 |
+ 'update_callback' => 'SP_REST_API::update_post_meta', |
|
| 188 |
+ 'schema' => array( |
|
| 189 |
+ 'description' => esc_attr__( 'Full Time', 'sportspress' ), |
|
| 190 |
+ 'type' => 'integer', |
|
| 191 |
+ 'context' => array( 'view', 'edit', 'embed' ), |
|
| 192 |
+ 'arg_options' => array( |
|
| 193 |
+ 'sanitize_callback' => 'absint', |
|
| 194 |
+ ), |
|
| 195 |
+ ), |
|
| 196 |
+ ) |
|
| 197 |
+ ); |
|
| 198 |
+ |
|
| 199 |
+ register_rest_field( |
|
| 200 |
+ 'sp_event', |
|
| 201 |
+ 'players', |
|
| 202 |
+ array( |
|
| 203 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 204 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 205 |
+ 'schema' => array( |
|
| 206 |
+ 'description' => esc_attr__( 'Players', 'sportspress' ), |
|
| 207 |
+ 'type' => 'array', |
|
| 208 |
+ 'context' => array( 'view', 'edit' ), |
|
| 209 |
+ 'arg_options' => array( |
|
| 210 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 211 |
+ ), |
|
| 212 |
+ ), |
|
| 213 |
+ ) |
|
| 214 |
+ ); |
|
| 215 |
+ |
|
| 216 |
+ register_rest_field( |
|
| 217 |
+ 'sp_event', |
|
| 218 |
+ 'offense', |
|
| 219 |
+ array( |
|
| 220 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 221 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 222 |
+ 'schema' => array( |
|
| 223 |
+ 'description' => esc_attr__( 'Offense', 'sportspress' ), |
|
| 224 |
+ 'type' => 'array', |
|
| 225 |
+ 'context' => array( 'view', 'edit' ), |
|
| 226 |
+ 'arg_options' => array( |
|
| 227 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 228 |
+ ), |
|
| 229 |
+ ), |
|
| 230 |
+ ) |
|
| 231 |
+ ); |
|
| 232 |
+ |
|
| 233 |
+ register_rest_field( |
|
| 234 |
+ 'sp_event', |
|
| 235 |
+ 'defense', |
|
| 236 |
+ array( |
|
| 237 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 238 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 239 |
+ 'schema' => array( |
|
| 240 |
+ 'description' => esc_attr__( 'Defense', 'sportspress' ), |
|
| 241 |
+ 'type' => 'array', |
|
| 242 |
+ 'context' => array( 'view', 'edit' ), |
|
| 243 |
+ 'arg_options' => array( |
|
| 244 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 245 |
+ ), |
|
| 246 |
+ ), |
|
| 247 |
+ ) |
|
| 248 |
+ ); |
|
| 249 |
+ |
|
| 250 |
+ register_rest_field( |
|
| 251 |
+ 'sp_event', |
|
| 252 |
+ 'staff', |
|
| 253 |
+ array( |
|
| 254 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 255 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 256 |
+ 'schema' => array( |
|
| 257 |
+ 'description' => esc_attr__( 'Staff', 'sportspress' ), |
|
| 258 |
+ 'type' => 'array', |
|
| 259 |
+ 'context' => array( 'view', 'edit' ), |
|
| 260 |
+ 'arg_options' => array( |
|
| 261 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 262 |
+ ), |
|
| 263 |
+ ), |
|
| 264 |
+ ) |
|
| 265 |
+ ); |
|
| 266 |
+ |
|
| 267 |
+ register_rest_field( |
|
| 268 |
+ 'sp_event', |
|
| 269 |
+ 'results', |
|
| 270 |
+ array( |
|
| 271 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 272 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_arrays', |
|
| 273 |
+ 'schema' => array( |
|
| 274 |
+ 'description' => esc_attr__( 'Results', 'sportspress' ), |
|
| 275 |
+ 'type' => 'object', |
|
| 276 |
+ 'context' => array( 'view', 'edit' ), |
|
| 277 |
+ 'arg_options' => array( |
|
| 278 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 279 |
+ ), |
|
| 280 |
+ ), |
|
| 281 |
+ ) |
|
| 282 |
+ ); |
|
| 283 |
+ |
|
| 284 |
+ register_rest_field( |
|
| 285 |
+ 'sp_event', |
|
| 286 |
+ 'performance', |
|
| 287 |
+ array( |
|
| 288 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 289 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_arrays_multi', |
|
| 290 |
+ 'schema' => array( |
|
| 291 |
+ 'description' => esc_attr__( 'Box Score', 'sportspress' ), |
|
| 292 |
+ 'type' => 'object', |
|
| 293 |
+ 'context' => array( 'view', 'edit' ), |
|
| 294 |
+ 'arg_options' => array( |
|
| 295 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 296 |
+ ), |
|
| 297 |
+ ), |
|
| 298 |
+ ) |
|
| 299 |
+ ); |
|
| 300 |
+ |
|
| 301 |
+ register_rest_field( |
|
| 302 |
+ 'sp_team', |
|
| 303 |
+ 'staff', |
|
| 304 |
+ array( |
|
| 305 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 306 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 307 |
+ 'schema' => array( |
|
| 308 |
+ 'description' => esc_attr__( 'Staff', 'sportspress' ), |
|
| 309 |
+ 'type' => 'array', |
|
| 310 |
+ 'context' => array( 'view', 'edit' ), |
|
| 311 |
+ 'arg_options' => array( |
|
| 312 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 313 |
+ ), |
|
| 314 |
+ ), |
|
| 315 |
+ ) |
|
| 316 |
+ ); |
|
| 317 |
+ |
|
| 318 |
+ register_rest_field( |
|
| 319 |
+ 'sp_team', |
|
| 320 |
+ 'tables', |
|
| 321 |
+ array( |
|
| 322 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 323 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 324 |
+ 'schema' => array( |
|
| 325 |
+ 'description' => esc_attr__( 'League Tables', 'sportspress' ), |
|
| 326 |
+ 'type' => 'array', |
|
| 327 |
+ 'context' => array( 'view', 'edit' ), |
|
| 328 |
+ 'arg_options' => array( |
|
| 329 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 330 |
+ ), |
|
| 331 |
+ ), |
|
| 332 |
+ ) |
|
| 333 |
+ ); |
|
| 334 |
+ |
|
| 335 |
+ register_rest_field( |
|
| 336 |
+ 'sp_team', |
|
| 337 |
+ 'lists', |
|
| 338 |
+ array( |
|
| 339 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 340 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 341 |
+ 'schema' => array( |
|
| 342 |
+ 'description' => esc_attr__( 'Player Lists', 'sportspress' ), |
|
| 343 |
+ 'type' => 'array', |
|
| 344 |
+ 'context' => array( 'view', 'edit' ), |
|
| 345 |
+ 'arg_options' => array( |
|
| 346 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 347 |
+ ), |
|
| 348 |
+ ), |
|
| 349 |
+ ) |
|
| 350 |
+ ); |
|
| 351 |
+ |
|
| 352 |
+ register_rest_field( |
|
| 353 |
+ 'sp_team', |
|
| 354 |
+ 'events', |
|
| 355 |
+ array( |
|
| 356 |
+ 'get_callback' => 'SP_REST_API::get_post_ids_with_meta', |
|
| 357 |
+ 'schema' => array( |
|
| 358 |
+ 'description' => esc_attr__( 'Events', 'sportspress' ), |
|
| 359 |
+ 'type' => 'array', |
|
| 360 |
+ 'context' => array( 'view' ), |
|
| 361 |
+ 'arg_options' => array( |
|
| 362 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 363 |
+ ), |
|
| 364 |
+ ), |
|
| 365 |
+ ) |
|
| 366 |
+ ); |
|
| 367 |
+ |
|
| 368 |
+ register_rest_field( |
|
| 369 |
+ 'sp_team', |
|
| 370 |
+ 'abbreviation', |
|
| 371 |
+ array( |
|
| 372 |
+ 'get_callback' => 'SP_REST_API::get_post_meta', |
|
| 373 |
+ 'update_callback' => 'SP_REST_API::update_post_meta', |
|
| 374 |
+ 'schema' => array( |
|
| 375 |
+ 'description' => esc_attr__( 'Abbreviation', 'sportspress' ), |
|
| 376 |
+ 'type' => 'string', |
|
| 377 |
+ 'context' => array( 'view', 'edit', 'embed' ), |
|
| 378 |
+ 'arg_options' => array( |
|
| 379 |
+ 'sanitize_callback' => 'sanitize_text_field', |
|
| 380 |
+ ), |
|
| 381 |
+ ), |
|
| 382 |
+ ) |
|
| 383 |
+ ); |
|
| 384 |
+ |
|
| 385 |
+ register_rest_field( |
|
| 386 |
+ 'sp_team', |
|
| 387 |
+ 'url', |
|
| 388 |
+ array( |
|
| 389 |
+ 'get_callback' => 'SP_REST_API::get_post_meta', |
|
| 390 |
+ 'update_callback' => 'SP_REST_API::update_post_meta', |
|
| 391 |
+ 'schema' => array( |
|
| 392 |
+ 'description' => esc_attr__( 'Site URL', 'sportspress' ), |
|
| 393 |
+ 'type' => 'string', |
|
| 394 |
+ 'context' => array( 'view', 'edit', 'embed' ), |
|
| 395 |
+ 'arg_options' => array( |
|
| 396 |
+ 'sanitize_callback' => 'sanitize_text_field', |
|
| 397 |
+ ), |
|
| 398 |
+ ), |
|
| 399 |
+ ) |
|
| 400 |
+ ); |
|
| 401 |
+ |
|
| 402 |
+ register_rest_field( |
|
| 403 |
+ 'sp_player', |
|
| 404 |
+ 'number', |
|
| 405 |
+ array( |
|
| 406 |
+ 'get_callback' => 'SP_REST_API::get_post_meta', |
|
| 407 |
+ 'update_callback' => 'SP_REST_API::update_post_meta', |
|
| 408 |
+ 'schema' => array( |
|
| 409 |
+ 'description' => esc_attr__( 'Squad Number', 'sportspress' ), |
|
| 410 |
+ 'type' => 'integer', |
|
| 411 |
+ 'context' => array( 'view', 'edit', 'embed' ), |
|
| 412 |
+ 'arg_options' => array( |
|
| 413 |
+ 'sanitize_callback' => 'absint', |
|
| 414 |
+ ), |
|
| 415 |
+ ), |
|
| 416 |
+ ) |
|
| 417 |
+ ); |
|
| 418 |
+ |
|
| 419 |
+ register_rest_field( |
|
| 420 |
+ 'sp_player', |
|
| 421 |
+ 'teams', |
|
| 422 |
+ array( |
|
| 423 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 424 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 425 |
+ 'schema' => array( |
|
| 426 |
+ 'description' => esc_attr__( 'Teams', 'sportspress' ), |
|
| 427 |
+ 'type' => 'array', |
|
| 428 |
+ 'context' => array( 'view', 'edit' ), |
|
| 429 |
+ 'arg_options' => array( |
|
| 430 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 431 |
+ ), |
|
| 432 |
+ ), |
|
| 433 |
+ ) |
|
| 434 |
+ ); |
|
| 435 |
+ |
|
| 436 |
+ register_rest_field( |
|
| 437 |
+ 'sp_player', |
|
| 438 |
+ 'current_teams', |
|
| 439 |
+ array( |
|
| 440 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 441 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 442 |
+ 'schema' => array( |
|
| 443 |
+ 'description' => esc_attr__( 'Current Teams', 'sportspress' ), |
|
| 444 |
+ 'type' => 'array', |
|
| 445 |
+ 'context' => array( 'view', 'edit' ), |
|
| 446 |
+ 'arg_options' => array( |
|
| 447 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 448 |
+ ), |
|
| 449 |
+ ), |
|
| 450 |
+ ) |
|
| 451 |
+ ); |
|
| 452 |
+ |
|
| 453 |
+ register_rest_field( |
|
| 454 |
+ 'sp_player', |
|
| 455 |
+ 'past_teams', |
|
| 456 |
+ array( |
|
| 457 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 458 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 459 |
+ 'schema' => array( |
|
| 460 |
+ 'description' => esc_attr__( 'Past Teams', 'sportspress' ), |
|
| 461 |
+ 'type' => 'array', |
|
| 462 |
+ 'context' => array( 'view', 'edit' ), |
|
| 463 |
+ 'arg_options' => array( |
|
| 464 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 465 |
+ ), |
|
| 466 |
+ ), |
|
| 467 |
+ ) |
|
| 468 |
+ ); |
|
| 469 |
+ |
|
| 470 |
+ register_rest_field( |
|
| 471 |
+ 'sp_player', |
|
| 472 |
+ 'nationalities', |
|
| 473 |
+ array( |
|
| 474 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 475 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 476 |
+ 'schema' => array( |
|
| 477 |
+ 'description' => esc_attr__( 'Nationalities', 'sportspress' ), |
|
| 478 |
+ 'type' => 'array', |
|
| 479 |
+ 'context' => array( 'view', 'embed' ), |
|
| 480 |
+ 'arg_options' => array( |
|
| 481 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 482 |
+ ), |
|
| 483 |
+ ), |
|
| 484 |
+ ) |
|
| 485 |
+ ); |
|
| 486 |
+ |
|
| 487 |
+ register_rest_field( |
|
| 488 |
+ 'sp_player', |
|
| 489 |
+ 'metrics', |
|
| 490 |
+ array( |
|
| 491 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 492 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_array', |
|
| 493 |
+ 'schema' => array( |
|
| 494 |
+ 'description' => esc_attr__( 'Metrics', 'sportspress' ), |
|
| 495 |
+ 'context' => array( 'view', 'edit' ), |
|
| 496 |
+ 'arg_options' => array( |
|
| 497 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 498 |
+ ), |
|
| 499 |
+ ), |
|
| 500 |
+ ) |
|
| 501 |
+ ); |
|
| 502 |
+ |
|
| 503 |
+ register_rest_field( |
|
| 504 |
+ 'sp_player', |
|
| 505 |
+ 'statistics', |
|
| 506 |
+ array( |
|
| 507 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 508 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_arrays_multi', |
|
| 509 |
+ 'schema' => array( |
|
| 510 |
+ 'description' => esc_attr__( 'Statistics', 'sportspress' ), |
|
| 511 |
+ 'type' => 'object', |
|
| 512 |
+ 'context' => array( 'view', 'edit' ), |
|
| 513 |
+ 'arg_options' => array( |
|
| 514 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 515 |
+ ), |
|
| 516 |
+ ), |
|
| 517 |
+ ) |
|
| 518 |
+ ); |
|
| 519 |
+ |
|
| 520 |
+ register_rest_field( |
|
| 521 |
+ 'sp_staff', |
|
| 522 |
+ 'teams', |
|
| 523 |
+ array( |
|
| 524 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 525 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 526 |
+ 'schema' => array( |
|
| 527 |
+ 'description' => esc_attr__( 'Teams', 'sportspress' ), |
|
| 528 |
+ 'type' => 'array', |
|
| 529 |
+ 'context' => array( 'view', 'edit' ), |
|
| 530 |
+ 'arg_options' => array( |
|
| 531 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 532 |
+ ), |
|
| 533 |
+ ), |
|
| 534 |
+ ) |
|
| 535 |
+ ); |
|
| 536 |
+ |
|
| 537 |
+ register_rest_field( |
|
| 538 |
+ 'sp_staff', |
|
| 539 |
+ 'current_teams', |
|
| 540 |
+ array( |
|
| 541 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 542 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 543 |
+ 'schema' => array( |
|
| 544 |
+ 'description' => esc_attr__( 'Current Teams', 'sportspress' ), |
|
| 545 |
+ 'type' => 'array', |
|
| 546 |
+ 'context' => array( 'view', 'edit' ), |
|
| 547 |
+ 'arg_options' => array( |
|
| 548 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 549 |
+ ), |
|
| 550 |
+ ), |
|
| 551 |
+ ) |
|
| 552 |
+ ); |
|
| 553 |
+ |
|
| 554 |
+ register_rest_field( |
|
| 555 |
+ 'sp_staff', |
|
| 556 |
+ 'past_teams', |
|
| 557 |
+ array( |
|
| 558 |
+ 'get_callback' => 'SP_REST_API::get_post_meta_recursive', |
|
| 559 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 560 |
+ 'schema' => array( |
|
| 561 |
+ 'description' => esc_attr__( 'Past Teams', 'sportspress' ), |
|
| 562 |
+ 'type' => 'array', |
|
| 563 |
+ 'context' => array( 'view', 'edit' ), |
|
| 564 |
+ 'arg_options' => array( |
|
| 565 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 566 |
+ ), |
|
| 567 |
+ ), |
|
| 568 |
+ ) |
|
| 569 |
+ ); |
|
| 570 |
+ |
|
| 571 |
+ register_rest_field( |
|
| 572 |
+ 'sp_staff', |
|
| 573 |
+ 'nationalities', |
|
| 574 |
+ array( |
|
| 575 |
+ 'get_callback' => 'SP_REST_API::get_post_data', |
|
| 576 |
+ 'update_callback' => 'SP_REST_API::update_post_meta_recursive', |
|
| 577 |
+ 'schema' => array( |
|
| 578 |
+ 'description' => esc_attr__( 'Nationalities', 'sportspress' ), |
|
| 579 |
+ 'type' => 'array', |
|
| 580 |
+ 'context' => array( 'view', 'embed' ), |
|
| 581 |
+ 'arg_options' => array( |
|
| 582 |
+ 'sanitize_callback' => 'rest_sanitize_request_arg', |
|
| 583 |
+ ), |
|
| 584 |
+ ), |
|
| 585 |
+ ) |
|
| 586 |
+ ); |
|
| 587 |
+ |
|
| 588 |
+ do_action( 'sportspress_register_rest_fields' ); |
|
| 589 |
+ } |
|
| 590 |
+ |
|
| 591 |
+ /** |
|
| 592 |
+ * Get the value of a single SportsPress meta field. |
|
| 593 |
+ * |
|
| 594 |
+ * @param array $object Details of current post. |
|
| 595 |
+ * @param string $field_name Name of field. |
|
| 596 |
+ * @param WP_REST_Request $request Current request |
|
| 597 |
+ * |
|
| 598 |
+ * @return mixed |
|
| 599 |
+ */ |
|
| 600 |
+ public static function get_post_meta( $object, $field_name, $request ) {
|
|
| 601 |
+ $meta = get_post_meta( $object['id'], self::meta_key( $field_name ), true ); |
|
| 602 |
+ |
|
| 603 |
+ if ( ctype_digit( $meta ) ) {
|
|
| 604 |
+ $meta = intval( $meta ); |
|
| 605 |
+ } |
|
| 606 |
+ |
|
| 607 |
+ return $meta; |
|
| 608 |
+ } |
|
| 609 |
+ |
|
| 610 |
+ /** |
|
| 611 |
+ * Handler for updating custom field data. |
|
| 612 |
+ * |
|
| 613 |
+ * @param mixed $value The value of the field |
|
| 614 |
+ * @param object $object The object from the response |
|
| 615 |
+ * @param string $field_name Name of field |
|
| 616 |
+ * |
|
| 617 |
+ * @return bool|int |
|
| 618 |
+ */ |
|
| 619 |
+ public static function update_post_meta( $value, $object, $field_name ) {
|
|
| 620 |
+ return update_post_meta( $object->ID, self::meta_key( $field_name ), strip_tags( $value ) ); |
|
| 621 |
+ } |
|
| 622 |
+ |
|
| 623 |
+ /** |
|
| 624 |
+ * Handler for updating array values by merging with the existing array. |
|
| 625 |
+ * |
|
| 626 |
+ * @param mixed $value The value of the field |
|
| 627 |
+ * @param object $object The object from the response |
|
| 628 |
+ * @param string $field_name Name of field |
|
| 629 |
+ * |
|
| 630 |
+ * @return bool|int |
|
| 631 |
+ */ |
|
| 632 |
+ public static function update_post_meta_array( $value, $object, $field_name ) {
|
|
| 633 |
+ // Convert PHP object to array |
|
| 634 |
+ if ( is_object( $value ) ) {
|
|
| 635 |
+ $value = (array) $value; |
|
| 636 |
+ } |
|
| 637 |
+ |
|
| 638 |
+ if ( ! is_array( $value ) ) {
|
|
| 639 |
+ return false; |
|
| 640 |
+ } |
|
| 641 |
+ |
|
| 642 |
+ $type = $object->post_type; |
|
| 643 |
+ |
|
| 644 |
+ $meta = get_post_meta( $object->ID, self::meta_key( $field_name, $type ), true ); |
|
| 645 |
+ |
|
| 646 |
+ if ( ! is_array( $meta ) ) {
|
|
| 647 |
+ $meta = array(); |
|
| 648 |
+ } |
|
| 649 |
+ |
|
| 650 |
+ $meta = array_merge( $meta, $value ); |
|
| 651 |
+ |
|
| 652 |
+ return update_post_meta( $object->ID, self::meta_key( $field_name, $type ), $meta ); |
|
| 653 |
+ } |
|
| 654 |
+ |
|
| 655 |
+ /** |
|
| 656 |
+ * Handler for updating array values by merging with the existing multidimentional array. |
|
| 657 |
+ * |
|
| 658 |
+ * @param mixed $value The value of the field |
|
| 659 |
+ * @param object $object The object from the response |
|
| 660 |
+ * @param string $field_name Name of field |
|
| 661 |
+ * |
|
| 662 |
+ * @return bool|int |
|
| 663 |
+ */ |
|
| 664 |
+ public static function update_post_meta_arrays( $value, $object, $field_name ) {
|
|
| 665 |
+ if ( ! is_array( $value ) ) {
|
|
| 666 |
+ return false; |
|
| 667 |
+ } |
|
| 668 |
+ |
|
| 669 |
+ $type = $object->post_type; |
|
| 670 |
+ |
|
| 671 |
+ $meta = get_post_meta( $object->ID, self::meta_key( $field_name, $type ), true ); |
|
| 672 |
+ |
|
| 673 |
+ if ( ! is_array( $meta ) ) {
|
|
| 674 |
+ $meta = array(); |
|
| 675 |
+ } |
|
| 676 |
+ |
|
| 677 |
+ foreach ( $value as $index => $array ) {
|
|
| 678 |
+ if ( ! is_array( $array ) ) {
|
|
| 679 |
+ continue; |
|
| 680 |
+ } |
|
| 681 |
+ |
|
| 682 |
+ if ( ! isset( $meta[ $index ] ) || ! is_array( $meta[ $index ] ) ) {
|
|
| 683 |
+ $meta[ $index ] = array(); |
|
| 684 |
+ } |
|
| 685 |
+ |
|
| 686 |
+ $meta[ $index ] = array_merge( $meta[ $index ], $array ); |
|
| 687 |
+ } |
|
| 688 |
+ |
|
| 689 |
+ return update_post_meta( $object->ID, self::meta_key( $field_name, $type ), $meta ); |
|
| 690 |
+ } |
|
| 691 |
+ |
|
| 692 |
+ /** |
|
| 693 |
+ * Handler for updating array values by merging with existing multidimensional arrays. |
|
| 694 |
+ * |
|
| 695 |
+ * @param mixed $value The value of the field |
|
| 696 |
+ * @param object $object The object from the response |
|
| 697 |
+ * @param string $field_name Name of field |
|
| 698 |
+ * |
|
| 699 |
+ * @return bool|int |
|
| 700 |
+ */ |
|
| 701 |
+ public static function update_post_meta_arrays_multi( $value, $object, $field_name ) {
|
|
| 702 |
+ if ( ! is_array( $value ) ) {
|
|
| 703 |
+ return false; |
|
| 704 |
+ } |
|
| 705 |
+ |
|
| 706 |
+ $type = $object->post_type; |
|
| 707 |
+ |
|
| 708 |
+ $meta = get_post_meta( $object->ID, self::meta_key( $field_name, $type ), true ); |
|
| 709 |
+ |
|
| 710 |
+ if ( ! is_array( $meta ) ) {
|
|
| 711 |
+ $meta = array(); |
|
| 712 |
+ } |
|
| 713 |
+ |
|
| 714 |
+ foreach ( $value as $key => $arrays ) {
|
|
| 715 |
+ if ( ! is_array( $arrays ) ) {
|
|
| 716 |
+ continue; |
|
| 717 |
+ } |
|
| 718 |
+ |
|
| 719 |
+ if ( ! isset( $meta[ $key ] ) || ! is_array( $meta[ $key ] ) ) {
|
|
| 720 |
+ $meta[ $key ] = array(); |
|
| 721 |
+ } |
|
| 722 |
+ |
|
| 723 |
+ foreach ( $arrays as $index => $array ) {
|
|
| 724 |
+ if ( ! is_array( $array ) ) {
|
|
| 725 |
+ continue; |
|
| 726 |
+ } |
|
| 727 |
+ |
|
| 728 |
+ if ( ! isset( $meta[ $key ][ $index ] ) || ! is_array( $meta[ $key ][ $index ] ) ) {
|
|
| 729 |
+ $meta[ $key ][ $index ] = array(); |
|
| 730 |
+ } |
|
| 731 |
+ |
|
| 732 |
+ $meta[ $key ][ $index ] = array_merge( $meta[ $key ][ $index ], $array ); |
|
| 733 |
+ } |
|
| 734 |
+ } |
|
| 735 |
+ |
|
| 736 |
+ return update_post_meta( $object->ID, self::meta_key( $field_name, $type ), $meta ); |
|
| 737 |
+ } |
|
| 738 |
+ |
|
| 739 |
+ /** |
|
| 740 |
+ * Get an array of SportsPress meta field values. |
|
| 741 |
+ * |
|
| 742 |
+ * @param array $object Details of current post. |
|
| 743 |
+ * @param string $field_name Name of field. |
|
| 744 |
+ * @param WP_REST_Request $request Current request |
|
| 745 |
+ * |
|
| 746 |
+ * @return mixed |
|
| 747 |
+ */ |
|
| 748 |
+ public static function get_post_meta_recursive( $object, $field_name, $request ) {
|
|
| 749 |
+ $meta = get_post_meta( $object['id'], self::meta_key( $field_name ), false ); |
|
| 750 |
+ |
|
| 751 |
+ return array_map( 'intval', $meta ); |
|
| 752 |
+ } |
|
| 753 |
+ |
|
| 754 |
+ /** |
|
| 755 |
+ * Handler for updating multiple custom field values. |
|
| 756 |
+ * |
|
| 757 |
+ * @param array $values The values of the field |
|
| 758 |
+ * @param object $object The object from the response |
|
| 759 |
+ * @param string $field_name Name of field |
|
| 760 |
+ * |
|
| 761 |
+ * @return bool|int |
|
| 762 |
+ */ |
|
| 763 |
+ public static function update_post_meta_recursive( $values, $object, $field_name ) {
|
|
| 764 |
+ delete_post_meta( $object->ID, self::meta_key( $field_name ) ); |
|
| 765 |
+ |
|
| 766 |
+ $response = true; |
|
| 767 |
+ foreach ( $values as $value ) {
|
|
| 768 |
+ $response = add_post_meta( $object->ID, self::meta_key( $field_name ), $value ); |
|
| 769 |
+ } |
|
| 770 |
+ |
|
| 771 |
+ return $response; |
|
| 772 |
+ } |
|
| 773 |
+ |
|
| 774 |
+ /** |
|
| 775 |
+ * Get an array of SportsPress meta field values and split into separate arrays based on placeholder zeroes. |
|
| 776 |
+ * |
|
| 777 |
+ * @param array $object Details of current post. |
|
| 778 |
+ * @param string $field_name Name of field. |
|
| 779 |
+ * @param WP_REST_Request $request Current request |
|
| 780 |
+ * |
|
| 781 |
+ * @return mixed |
|
| 782 |
+ */ |
|
| 783 |
+ public static function get_post_meta_recursive_split( $object, $field_name, $request ) {
|
|
| 784 |
+ $array = self::get_post_meta_recursive( $object, $field_name, $request ); |
|
| 785 |
+ |
|
| 786 |
+ $meta = array(); |
|
| 787 |
+ $i = 0; |
|
| 788 |
+ foreach ( $array as $value ) {
|
|
| 789 |
+ if ( $value ) {
|
|
| 790 |
+ $meta[ $i ][] = $value; |
|
| 791 |
+ } else {
|
|
| 792 |
+ $i ++; |
|
| 793 |
+ } |
|
| 794 |
+ } |
|
| 795 |
+ |
|
| 796 |
+ return $meta; |
|
| 797 |
+ } |
|
| 798 |
+ |
|
| 799 |
+ /** |
|
| 800 |
+ * Get a list of posts with a meta value of the given field name. |
|
| 801 |
+ * |
|
| 802 |
+ * @param array $object Details of current post. |
|
| 803 |
+ * @param string $field_name Name of field. |
|
| 804 |
+ * @param WP_REST_Request $request Current request |
|
| 805 |
+ * |
|
| 806 |
+ * @return mixed |
|
| 807 |
+ */ |
|
| 808 |
+ public static function get_post_ids_with_meta( $object, $field_name, $request ) {
|
|
| 809 |
+ $meta_key = self::meta_key( $field_name ); |
|
| 810 |
+ |
|
| 811 |
+ $query_args = array( |
|
| 812 |
+ 'post_type' => $meta_key, |
|
| 813 |
+ 'posts_per_page' => 2000, |
|
| 814 |
+ 'meta_query' => array( |
|
| 815 |
+ 'key' => $object['type'], |
|
| 816 |
+ 'value' => $object['id'], |
|
| 817 |
+ 'compare' => 'IN', |
|
| 818 |
+ ), |
|
| 819 |
+ ); |
|
| 820 |
+ |
|
| 821 |
+ if ( 'sp_event' === $meta_key ) {
|
|
| 822 |
+ $query_args['orderby'] = 'date'; |
|
| 823 |
+ $query_args['order'] = 'DESC'; |
|
| 824 |
+ $query_args['post_status'] = array( 'publish', 'future' ); |
|
| 825 |
+ } else {
|
|
| 826 |
+ $query_args['orderby'] = 'title'; |
|
| 827 |
+ $query_args['order'] = 'ASC'; |
|
| 828 |
+ $query_args['post_status'] = 'publish'; |
|
| 829 |
+ } |
|
| 830 |
+ |
|
| 831 |
+ $posts_query = new WP_Query(); |
|
| 832 |
+ $query_result = $posts_query->query( $query_args ); |
|
| 833 |
+ |
|
| 834 |
+ return wp_list_pluck( $query_result, 'ID' ); |
|
| 835 |
+ } |
|
| 836 |
+ |
|
| 837 |
+ /** |
|
| 838 |
+ * Get custom SportsPress data based on post type and field name. |
|
| 839 |
+ * |
|
| 840 |
+ * @param array $object Details of current post. |
|
| 841 |
+ * @param string $field_name Name of field. |
|
| 842 |
+ * @param WP_REST_Request $request Current request |
|
| 843 |
+ * |
|
| 844 |
+ * @return mixed |
|
| 845 |
+ */ |
|
| 846 |
+ public static function get_post_data( $object, $field_name, $request ) {
|
|
| 847 |
+ $type = $object['type']; |
|
| 848 |
+ |
|
| 849 |
+ $post = new $type( $object['id'] ); |
|
| 850 |
+ |
|
| 851 |
+ return $post->$field_name(); |
|
| 852 |
+ } |
|
| 853 |
+ |
|
| 854 |
+ /** |
|
| 855 |
+ * Get meta key of a field |
|
| 856 |
+ */ |
|
| 857 |
+ public static function meta_key( $field_name, $type = null ) {
|
|
| 858 |
+ $names = array( |
|
| 859 |
+ 'current_teams' => 'sp_current_team', |
|
| 860 |
+ 'events' => 'sp_event', |
|
| 861 |
+ 'lists' => 'sp_list', |
|
| 862 |
+ 'nationalities' => 'sp_nationality', |
|
| 863 |
+ 'past_teams' => 'sp_past_team', |
|
| 864 |
+ 'performance' => 'sp_players', |
|
| 865 |
+ 'players' => 'sp_player', |
|
| 866 |
+ 'offense' => 'sp_offense', |
|
| 867 |
+ 'defense' => 'sp_defense', |
|
| 868 |
+ 'table' => 'sp_teams', |
|
| 869 |
+ 'tables' => 'sp_table', |
|
| 870 |
+ 'teams' => 'sp_team', |
|
| 871 |
+ ); |
|
| 872 |
+ |
|
| 873 |
+ if ( isset( $type ) ) {
|
|
| 874 |
+ switch ( $type ) {
|
|
| 875 |
+ case 'sp_table': |
|
| 876 |
+ $names['data'] = 'sp_teams'; |
|
| 877 |
+ break; |
|
| 878 |
+ case 'sp_list': |
|
| 879 |
+ $names['data'] = 'sp_players'; |
|
| 880 |
+ break; |
|
| 881 |
+ } |
|
| 882 |
+ } |
|
| 883 |
+ |
|
| 884 |
+ $names = apply_filters( 'sportspress_rest_meta_keys', $names, $type ); |
|
| 885 |
+ |
|
| 886 |
+ if ( array_key_exists( $field_name, $names ) ) {
|
|
| 887 |
+ $field_name = $names[ $field_name ]; |
|
| 888 |
+ } else {
|
|
| 889 |
+ $field_name = 'sp_' . $field_name; |
|
| 890 |
+ } |
|
| 891 |
+ |
|
| 892 |
+ return $field_name; |
|
| 893 |
+ } |
|
| 894 |
+ |
|
| 895 |
+ /** |
|
| 896 |
+ * Enable meta query vars |
|
| 897 |
+ */ |
|
| 898 |
+ public static function meta_query( $valid_vars ) {
|
|
| 899 |
+ $valid_vars = array_merge( $valid_vars, array( 'meta_key', 'meta_value', 'meta_query' ) ); |
|
| 900 |
+ return $valid_vars; |
|
| 901 |
+ } |
|
| 902 |
+ |
|
| 903 |
+ /** |
|
| 904 |
+ * Add scheduled events to query |
|
| 905 |
+ */ |
|
| 906 |
+ public static function event_query( $args ) {
|
|
| 907 |
+ $args['post_status'] = array( 'publish', 'future' ); |
|
| 908 |
+ return $args; |
|
| 909 |
+ } |
|
| 910 |
+ |
|
| 911 |
+ /** |
|
| 912 |
+ * Enable post status in events query |
|
| 913 |
+ */ |
|
| 914 |
+ public static function query_vars( $vars ) {
|
|
| 915 |
+ global $wp; |
|
| 916 |
+ $vars[] = 'post_status'; |
|
| 917 |
+ return $vars; |
|
| 918 |
+ } |
|
| 919 |
+ } |
|
| 920 |
+ |
|
| 921 |
+endif; |
|
| 922 |
+ |
|
| 923 |
+return new SP_REST_API(); |
|
| 0 | 924 |