diff --git a/includes/api/class-sp-rest-api.php b/includes/api/class-sp-rest-api.php index 7e19b7e2..bb540d5b 100644 --- a/includes/api/class-sp-rest-api.php +++ b/includes/api/class-sp-rest-api.php @@ -119,6 +119,22 @@ class SP_REST_API { ), ) ); + + register_rest_field( 'sp_event', + 'day', + array( + 'get_callback' => 'SP_REST_API::get_post_data', + 'update_callback' => 'SP_REST_API::update_post_meta', + 'schema' => array( + 'description' => __( 'Match Day', 'sportspress' ), + 'type' => 'string', + 'context' => array( 'view', 'edit', 'embed' ), + 'arg_options' => array( + 'sanitize_callback' => 'sanitize_text_field', + ), + ), + ) + ); register_rest_field( 'sp_event', 'minutes', @@ -502,22 +518,6 @@ class SP_REST_API { ), ) ); - - register_rest_field( 'sp_event', - 'day', - array( - 'get_callback' => 'SP_REST_API::get_post_data', - 'update_callback' => 'SP_REST_API::update_post_meta_arrays', - 'schema' => array( - 'description' => __( 'Results', 'sportspress' ), - 'type' => 'array', - 'context' => array( 'view', 'edit' ), - 'arg_options' => array( - 'sanitize_callback' => 'rest_sanitize_request_arg', - ), - ), - ) - ); do_action( 'sportspress_register_rest_fields' ); } diff --git a/includes/class-sp-event.php b/includes/class-sp-event.php index 91e4b7fe..1d63c2fc 100644 --- a/includes/class-sp-event.php +++ b/includes/class-sp-event.php @@ -25,6 +25,11 @@ class SP_Event extends SP_Custom_Post{ } return $post_status; } + + public function day() { + $day = get_post_meta( $this->ID, 'sp_day', true ); + return $day; + } public function minutes() { $minutes = get_post_meta( $this->ID, 'sp_minutes', true ); @@ -702,10 +707,4 @@ class SP_Event extends SP_Custom_Post{ public function sort_timeline( $a, $b ) { return $a['time'] - $b['time']; } - - public function day() { - $day = get_post_meta( $this->ID, 'sp_day', true ); - if ( '' === $day ) $day = 'empty'; - return $day; - } }