Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-inclu.../rest-api/endpoint...
File: class-wp-rest-blocks-controller.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Synced patterns REST API: WP_REST_Blocks_Controller class
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage REST_API
[5] Fix | Delete
* @since 5.0.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Controller which provides a REST endpoint for the editor to read, create,
[10] Fix | Delete
* edit, and delete synced patterns (formerly called reusable blocks).
[11] Fix | Delete
* Patterns are stored as posts with the wp_block post type.
[12] Fix | Delete
*
[13] Fix | Delete
* @since 5.0.0
[14] Fix | Delete
*
[15] Fix | Delete
* @see WP_REST_Posts_Controller
[16] Fix | Delete
* @see WP_REST_Controller
[17] Fix | Delete
*/
[18] Fix | Delete
class WP_REST_Blocks_Controller extends WP_REST_Posts_Controller {
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Checks if a pattern can be read.
[22] Fix | Delete
*
[23] Fix | Delete
* @since 5.0.0
[24] Fix | Delete
*
[25] Fix | Delete
* @param WP_Post $post Post object that backs the block.
[26] Fix | Delete
* @return bool Whether the pattern can be read.
[27] Fix | Delete
*/
[28] Fix | Delete
public function check_read_permission( $post ) {
[29] Fix | Delete
// By default the read_post capability is mapped to edit_posts.
[30] Fix | Delete
if ( ! current_user_can( 'read_post', $post->ID ) ) {
[31] Fix | Delete
return false;
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
return parent::check_read_permission( $post );
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* Filters a response based on the context defined in the schema.
[39] Fix | Delete
*
[40] Fix | Delete
* @since 5.0.0
[41] Fix | Delete
* @since 6.3.0 Adds the `wp_pattern_sync_status` postmeta property to the top level of response.
[42] Fix | Delete
*
[43] Fix | Delete
* @param array $data Response data to filter.
[44] Fix | Delete
* @param string $context Context defined in the schema.
[45] Fix | Delete
* @return array Filtered response.
[46] Fix | Delete
*/
[47] Fix | Delete
public function filter_response_by_context( $data, $context ) {
[48] Fix | Delete
$data = parent::filter_response_by_context( $data, $context );
[49] Fix | Delete
[50] Fix | Delete
/*
[51] Fix | Delete
* Remove `title.rendered` and `content.rendered` from the response.
[52] Fix | Delete
* It doesn't make sense for a pattern to have rendered content on its own,
[53] Fix | Delete
* since rendering a block requires it to be inside a post or a page.
[54] Fix | Delete
*/
[55] Fix | Delete
unset( $data['title']['rendered'] );
[56] Fix | Delete
unset( $data['content']['rendered'] );
[57] Fix | Delete
[58] Fix | Delete
// Add the core wp_pattern_sync_status meta as top level property to the response.
[59] Fix | Delete
$data['wp_pattern_sync_status'] = isset( $data['meta']['wp_pattern_sync_status'] ) ? $data['meta']['wp_pattern_sync_status'] : '';
[60] Fix | Delete
unset( $data['meta']['wp_pattern_sync_status'] );
[61] Fix | Delete
return $data;
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* Retrieves the pattern's schema, conforming to JSON Schema.
[66] Fix | Delete
*
[67] Fix | Delete
* @since 5.0.0
[68] Fix | Delete
*
[69] Fix | Delete
* @return array Item schema data.
[70] Fix | Delete
*/
[71] Fix | Delete
public function get_item_schema() {
[72] Fix | Delete
if ( $this->schema ) {
[73] Fix | Delete
return $this->add_additional_fields_schema( $this->schema );
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
$schema = parent::get_item_schema();
[77] Fix | Delete
[78] Fix | Delete
/*
[79] Fix | Delete
* Allow all contexts to access `title.raw` and `content.raw`.
[80] Fix | Delete
* Clients always need the raw markup of a pattern to do anything useful,
[81] Fix | Delete
* e.g. parse it or display it in an editor.
[82] Fix | Delete
*/
[83] Fix | Delete
$schema['properties']['title']['properties']['raw']['context'] = array( 'view', 'edit' );
[84] Fix | Delete
$schema['properties']['content']['properties']['raw']['context'] = array( 'view', 'edit' );
[85] Fix | Delete
[86] Fix | Delete
/*
[87] Fix | Delete
* Remove `title.rendered` and `content.rendered` from the schema.
[88] Fix | Delete
* It doesn't make sense for a pattern to have rendered content on its own,
[89] Fix | Delete
* since rendering a block requires it to be inside a post or a page.
[90] Fix | Delete
*/
[91] Fix | Delete
unset( $schema['properties']['title']['properties']['rendered'] );
[92] Fix | Delete
unset( $schema['properties']['content']['properties']['rendered'] );
[93] Fix | Delete
[94] Fix | Delete
$this->schema = $schema;
[95] Fix | Delete
[96] Fix | Delete
return $this->add_additional_fields_schema( $this->schema );
[97] Fix | Delete
}
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function