rebase on oct-10-2023
This commit is contained in:
@@ -40,6 +40,7 @@ class WP_REST_Blocks_Controller extends WP_REST_Posts_Controller {
|
||||
* Filters a response based on the context defined in the schema.
|
||||
*
|
||||
* @since 5.0.0
|
||||
* @since 6.3.0 Adds the `wp_pattern_sync_status` postmeta property to the top level of response.
|
||||
*
|
||||
* @param array $data Response data to filter.
|
||||
* @param string $context Context defined in the schema.
|
||||
@@ -56,6 +57,9 @@ class WP_REST_Blocks_Controller extends WP_REST_Posts_Controller {
|
||||
unset( $data['title']['rendered'] );
|
||||
unset( $data['content']['rendered'] );
|
||||
|
||||
// Add the core wp_pattern_sync_status meta as top level property to the response.
|
||||
$data['wp_pattern_sync_status'] = isset( $data['meta']['wp_pattern_sync_status'] ) ? $data['meta']['wp_pattern_sync_status'] : '';
|
||||
unset( $data['meta']['wp_pattern_sync_status'] );
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -67,6 +71,10 @@ class WP_REST_Blocks_Controller extends WP_REST_Posts_Controller {
|
||||
* @return array Item schema data.
|
||||
*/
|
||||
public function get_item_schema() {
|
||||
if ( $this->schema ) {
|
||||
return $this->add_additional_fields_schema( $this->schema );
|
||||
}
|
||||
|
||||
// Do not cache this schema because all properties are derived from parent controller.
|
||||
$schema = parent::get_item_schema();
|
||||
|
||||
@@ -86,7 +94,9 @@ class WP_REST_Blocks_Controller extends WP_REST_Posts_Controller {
|
||||
unset( $schema['properties']['title']['properties']['rendered'] );
|
||||
unset( $schema['properties']['content']['properties']['rendered'] );
|
||||
|
||||
return $schema;
|
||||
$this->schema = $schema;
|
||||
|
||||
return $this->add_additional_fields_schema( $this->schema );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user