Filter hook 'rest_prepare_block_pattern'

in WP Core File wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php at line 220

View Source

rest_prepare_block_pattern

Filter Hook
Description
Filters the REST API response for a block pattern.

Hook Information

File Location wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php View on GitHub
Hook Type Filter
Line Number 220

Hook Parameters

Type Name Description
WP_REST_Response $response The response object.
object $raw_pattern The unprepared block pattern.
WP_REST_Request $request The request object.

Usage Examples

Basic Usage
<?php
// Hook into rest_prepare_block_pattern
add_filter('rest_prepare_block_pattern', 'my_custom_filter', 10, 3);

function my_custom_filter($response, $raw_pattern, $request) {
    // Your custom filtering logic here
    return $response;
}

Source Code Context

wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php:220 - How this hook is used in WordPress core
<?php
 215  		 *
 216  		 * @param WP_REST_Response $response    The response object.
 217  		 * @param object           $raw_pattern The unprepared block pattern.
 218  		 * @param WP_REST_Request  $request     The request object.
 219  		 */
 220  		return apply_filters( 'rest_prepare_block_pattern', $response, $raw_pattern, $request );
 221  	}
 222  
 223  	/**
 224  	 * Retrieves the block pattern's schema, conforming to JSON Schema.
 225  	 *

PHP Documentation

<?php
/**
		 * Filters the REST API response for a block pattern.
		 *
		 * @since 5.8.0
		 *
		 * @param WP_REST_Response $response    The response object.
		 * @param object           $raw_pattern The unprepared block pattern.
		 * @param WP_REST_Request  $request     The request object.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 3
  • File: wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php
Related Hooks

Related hooks will be displayed here in future updates.