diff --git a/includes/api/class-sp-rest-api.php b/includes/api/class-sp-rest-api.php index 859b5a3cd..feaa14f81 100644 --- a/includes/api/class-sp-rest-api.php +++ b/includes/api/class-sp-rest-api.php @@ -135,6 +135,23 @@ public static function register_fields() { ), ) ); + + register_rest_field( 'sp_event', + 'format', + array( + 'get_callback' => 'SP_REST_API::get_post_data', + 'update_callback' => 'SP_REST_API::update_post_meta', + 'schema' => array( + 'description' => __( 'Format', 'sportspress' ), + 'type' => 'string', + 'enum' => array('league', 'friendly', 'tournament'), + 'context' => array( 'view', 'edit', 'embed' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + ) + ); register_rest_field( 'sp_event', 'minutes', diff --git a/includes/class-sp-event.php b/includes/class-sp-event.php index e16c3d277..a6c249925 100644 --- a/includes/class-sp-event.php +++ b/includes/class-sp-event.php @@ -29,7 +29,12 @@ public function status() { public function day() { $day = get_post_meta( $this->ID, 'sp_day', true ); return $day; - } + } + + public function format() { + $format = get_post_meta( $this->ID, 'sp_format', true ); + return $format; + } public function minutes() { $minutes = get_post_meta( $this->ID, 'sp_minutes', true );