rest_prepare_block_pattern
Filters the REST API response for a block pattern.
Usage
add_filter( 'rest_prepare_block_pattern', 'wp_kama_rest_prepare_block_pattern_filter', 10, 3 );
/**
* Function for `rest_prepare_block_pattern` filter-hook.
*
* @param WP_REST_Response $response The response object.
* @param object $raw_pattern The unprepared block pattern.
* @param WP_REST_Request $request The request object.
*
* @return WP_REST_Response
*/
function wp_kama_rest_prepare_block_pattern_filter( $response, $raw_pattern, $request ){
// filter...
return $response;
}
- $response(WP_REST_Response)
- The response object.
- $raw_pattern(object)
- The unprepared block pattern.
- $request(WP_REST_Request)
- The request object.
Changelog
| Since 5.8.0 | Introduced. |
Where the hook is called
rest_prepare_block_pattern
wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php 220
return apply_filters( 'rest_prepare_block_pattern', $response, $raw_pattern, $request );