@@ -1476,6 +1476,35 @@ protected function prepare_item_for_database( $request ) {
14761476 $ prepared_post ->page_template = null ;
14771477 }
14781478
1479+ /**
1480+ * Applies Block Hooks to content-like post types.
1481+ *
1482+ * Content-like post types are those that support the editor and would benefit
1483+ * from Block Hooks functionality. This replaces the individual post type filters
1484+ * that were previously hardcoded in default-filters.php.
1485+ *
1486+ * @since 7.0.0
1487+ */
1488+ $ content_like_post_types = array ( 'post ' , 'page ' , 'wp_block ' , 'wp_navigation ' );
1489+
1490+ /**
1491+ * Filters which post types should have Block Hooks applied.
1492+ *
1493+ * Allows themes and plugins to add or remove post types that should
1494+ * have Block Hooks functionality enabled in the REST API.
1495+ *
1496+ * @since 7.0.0
1497+ *
1498+ * @param array $content_like_post_types Array of post type names that support Block Hooks.
1499+ * @param string $post_type The current post type being processed.
1500+ * @param object $prepared_post The prepared post object.
1501+ */
1502+ $ content_like_post_types = apply_filters ( 'rest_block_hooks_post_types ' , $ content_like_post_types , $ this ->post_type , $ prepared_post );
1503+
1504+ if ( in_array ( $ this ->post_type , $ content_like_post_types , true ) ) {
1505+ $ prepared_post = update_ignored_hooked_blocks_postmeta ( $ prepared_post );
1506+ }
1507+
14791508 /**
14801509 * Filters a post before it is inserted via the REST API.
14811510 *
@@ -2127,6 +2156,34 @@ public function prepare_item_for_response( $item, $request ) {
21272156 }
21282157 }
21292158
2159+ /**
2160+ * Applies Block Hooks to content-like post types for REST response.
2161+ *
2162+ * This replaces the individual post type filters that were previously hardcoded
2163+ * in default-filters.php.
2164+ *
2165+ * @since 7.0.0
2166+ */
2167+ $ content_like_post_types = array ( 'post ' , 'page ' , 'wp_block ' , 'wp_navigation ' );
2168+
2169+ /**
2170+ * Filters which post types should have Block Hooks applied.
2171+ *
2172+ * Allows themes and plugins to add or remove post types that should
2173+ * have Block Hooks functionality enabled in the REST API.
2174+ *
2175+ * @since 7.0.0
2176+ *
2177+ * @param array $content_like_post_types Array of post type names that support Block Hooks.
2178+ * @param string $post_type The current post type being processed.
2179+ * @param WP_Post $post The post object.
2180+ */
2181+ $ content_like_post_types = apply_filters ( 'rest_block_hooks_post_types ' , $ content_like_post_types , $ this ->post_type , $ post );
2182+
2183+ if ( in_array ( $ this ->post_type , $ content_like_post_types , true ) ) {
2184+ $ response = insert_hooked_blocks_into_rest_response ( $ response , $ post );
2185+ }
2186+
21302187 /**
21312188 * Filters the post data for a REST API response.
21322189 *
0 commit comments