Add event format to REST API
This commit is contained in:
@@ -120,21 +120,37 @@ class SP_REST_API {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
register_rest_field( 'sp_event',
|
register_rest_field( 'sp_event',
|
||||||
'day',
|
'format',
|
||||||
array(
|
array(
|
||||||
'get_callback' => 'SP_REST_API::get_post_data',
|
'get_callback' => 'SP_REST_API::get_post_data',
|
||||||
'update_callback' => 'SP_REST_API::update_post_meta',
|
'update_callback' => 'SP_REST_API::update_post_meta',
|
||||||
'schema' => array(
|
'schema' => array(
|
||||||
'description' => __( 'Match Day', 'sportspress' ),
|
'description' => __( 'Format', 'sportspress' ),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'context' => array( 'view', 'edit', 'embed' ),
|
'context' => array( 'view', 'edit', 'embed' ),
|
||||||
'arg_options' => array(
|
'arg_options' => array(
|
||||||
'sanitize_callback' => 'sanitize_text_field',
|
'sanitize_callback' => 'sanitize_text_field',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
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',
|
register_rest_field( 'sp_event',
|
||||||
'minutes',
|
'minutes',
|
||||||
|
|||||||
@@ -26,9 +26,14 @@ class SP_Event extends SP_Custom_Post{
|
|||||||
return $post_status;
|
return $post_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function day() {
|
public function format() {
|
||||||
$day = get_post_meta( $this->ID, 'sp_day', true );
|
$format = get_post_meta( $this->ID, 'sp_format', true );
|
||||||
return $day;
|
return $format;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function day() {
|
||||||
|
$day = get_post_meta( $this->ID, 'sp_day', true );
|
||||||
|
return $day;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function minutes() {
|
public function minutes() {
|
||||||
|
|||||||
Reference in New Issue
Block a user