Add event mode to REST API
This commit is contained in:
@@ -136,6 +136,22 @@ class SP_REST_API {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
register_rest_field( 'sp_event',
|
||||||
|
'mode',
|
||||||
|
array(
|
||||||
|
'get_callback' => 'SP_REST_API::get_post_data',
|
||||||
|
'update_callback' => 'SP_REST_API::update_post_meta',
|
||||||
|
'schema' => array(
|
||||||
|
'description' => __( 'Mode', 'sportspress' ),
|
||||||
|
'type' => 'string',
|
||||||
|
'context' => array( 'view', 'edit', 'embed' ),
|
||||||
|
'arg_options' => array(
|
||||||
|
'sanitize_callback' => 'sanitize_text_field',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
register_rest_field( 'sp_event',
|
register_rest_field( 'sp_event',
|
||||||
'day',
|
'day',
|
||||||
array(
|
array(
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ class SP_Event extends SP_Custom_Post{
|
|||||||
return $day;
|
return $day;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function mode() {
|
||||||
|
$mode = get_post_meta( $this->ID, 'sp_mode', true );
|
||||||
|
return $mode;
|
||||||
|
}
|
||||||
|
|
||||||
public function minutes() {
|
public function minutes() {
|
||||||
$minutes = get_post_meta( $this->ID, 'sp_minutes', true );
|
$minutes = get_post_meta( $this->ID, 'sp_minutes', true );
|
||||||
if ( '' === $minutes ) $minutes = get_option( 'sportspress_event_minutes', 90 );
|
if ( '' === $minutes ) $minutes = get_option( 'sportspress_event_minutes', 90 );
|
||||||
|
|||||||
Reference in New Issue
Block a user