wpseek.com
A WordPress-centric search engine for devs and theme authors
insert_hooked_blocks_into_rest_response › WordPress Function
Since6.6.0
Deprecatedn/a
› insert_hooked_blocks_into_rest_response ( $response, $post )
Parameters: (2) |
|
Returns: |
|
Defined at: |
|
Codex: | |
Change Log: |
|
Hooks into the REST API response for the Posts endpoint and adds the first and last inner blocks.
Source
function insert_hooked_blocks_into_rest_response( $response, $post ) { if ( empty( $response->data['content']['raw'] ) ) { return $response; } $response->data['content']['raw'] = apply_block_hooks_to_content_from_post_object( $response->data['content']['raw'], $post, 'insert_hooked_blocks_and_set_ignored_hooked_blocks_metadata' ); // If the rendered content was previously empty, we leave it like that. if ( empty( $response->data['content']['rendered'] ) ) { return $response; } // `apply_block_hooks_to_content` is called above. Ensure it is not called again as a filter. $priority = has_filter( 'the_content', 'apply_block_hooks_to_content_from_post_object' ); if ( false !== $priority ) { remove_filter( 'the_content', 'apply_block_hooks_to_content_from_post_object', $priority ); } /** This filter is documented in wp-includes/post-template.php */ $response->data['content']['rendered'] = apply_filters( 'the_content', $response->data['content']['raw'] ); // Restore the filter if it was set initially. if ( false !== $priority ) { add_filter( 'the_content', 'apply_block_hooks_to_content_from_post_object', $priority ); } return $response; }