From c7c87cc4d18dbb0c2293ae04777fe352502c353d Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Thu, 15 Sep 2016 14:01:03 +1000 Subject: [PATCH] Add offense and defense to REST API props @sagund07 --- includes/api/class-sp-rest-api.php | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/includes/api/class-sp-rest-api.php b/includes/api/class-sp-rest-api.php index b6415fce..daa51851 100644 --- a/includes/api/class-sp-rest-api.php +++ b/includes/api/class-sp-rest-api.php @@ -157,6 +157,38 @@ class SP_REST_API { ) ); + register_rest_field( 'sp_event', + 'offense', + array( + 'get_callback' => 'SP_REST_API::get_post_meta_recursive', + 'update_callback' => 'SP_REST_API::update_post_meta_recursive', + 'schema' => array( + 'description' => __( 'Offense', 'sportspress' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'rest_sanitize_request_arg', + ), + ), + ) + ); + + register_rest_field( 'sp_event', + 'defense', + array( + 'get_callback' => 'SP_REST_API::get_post_meta_recursive', + 'update_callback' => 'SP_REST_API::update_post_meta_recursive', + 'schema' => array( + 'description' => __( 'Defense', 'sportspress' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'arg_options' => array( + 'sanitize_callback' => 'rest_sanitize_request_arg', + ), + ), + ) + ); + register_rest_field( 'sp_event', 'staff', array( @@ -731,6 +763,8 @@ class SP_REST_API { 'past_teams' => 'sp_past_team', 'performance' => 'sp_players', 'players' => 'sp_player', + 'offense' => 'sp_offense', + 'defense' => 'sp_defense', 'table' => 'sp_teams', 'tables' => 'sp_table', 'teams' => 'sp_team',