rest_block_hooks_post_types filter-hookWP 7.0.0

Filters which post types should have Block Hooks applied.

Allows themes and plugins to add or remove post types that should have Block Hooks functionality enabled in the REST API.

Usage

add_filter( 'rest_block_hooks_post_types', 'wp_kama_rest_block_hooks_post_types_filter', 10, 3 );

/**
 * Function for `rest_block_hooks_post_types` filter-hook.
 * 
 * @param string[]         $content_like_post_types Array of post type names that support Block Hooks.
 * @param string           $post_type               The current post type being processed.
 * @param stdClass|WP_Post $prepared_post           The prepared post object.
 *
 * @return string[]
 */
function wp_kama_rest_block_hooks_post_types_filter( $content_like_post_types, $post_type, $prepared_post ){
	// filter...
	return $content_like_post_types;
}
$content_like_post_types(string[])
Array of post type names that support Block Hooks.
$post_type(string)
The current post type being processed.
$prepared_post(stdClass|WP_Post)
The prepared post object.

Changelog

Since 7.0.0 Introduced.

Where the hook is called

WP_REST_Posts_Controller::prepare_item_for_database()
rest_block_hooks_post_types
WP_REST_Posts_Controller::prepare_item_for_response()
rest_block_hooks_post_types
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 1508
$content_like_post_types = apply_filters( 'rest_block_hooks_post_types', $content_like_post_types, $this->post_type, $prepared_post );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 2176
$content_like_post_types = apply_filters( 'rest_block_hooks_post_types', $content_like_post_types, $this->post_type, $post );

Where the hook is used in WordPress

Usage not found.