Changeset 58292
- Timestamp:
- 06/03/2024 12:35:47 PM (8 months ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r58291 r58292 1137 1137 1138 1138 /** 1139 * Hooks into the REST API response for the core/navigation block and adds the first and last inner blocks. 1140 * 1141 * @since 6.6.0 1142 * 1143 * @param WP_REST_Response $response The response object. 1144 * @param WP_Post $post Post object. 1145 * @return WP_REST_Response The response object. 1146 */ 1147 function insert_hooked_blocks_into_rest_response( $response, $post ) { 1148 if ( ! isset( $response->data['content']['raw'] ) || ! isset( $response->data['content']['rendered'] ) ) { 1149 return $response; 1150 } 1151 1152 $attributes = array(); 1153 $ignored_hooked_blocks = get_post_meta( $post->ID, '_wp_ignored_hooked_blocks', true ); 1154 if ( ! empty( $ignored_hooked_blocks ) ) { 1155 $ignored_hooked_blocks = json_decode( $ignored_hooked_blocks, true ); 1156 $attributes['metadata'] = array( 1157 'ignoredHookedBlocks' => $ignored_hooked_blocks, 1158 ); 1159 } 1160 $content = get_comment_delimited_block_content( 1161 'core/navigation', 1162 $attributes, 1163 $response->data['content']['raw'] 1164 ); 1165 1166 $content = apply_block_hooks_to_content( $content, $post ); 1167 1168 // Remove mock Navigation block wrapper. 1169 $content = remove_serialized_parent_block( $content ); 1170 1171 $response->data['content']['raw'] = $content; 1172 1173 /** This filter is documented in wp-includes/post-template.php */ 1174 $response->data['content']['rendered'] = apply_filters( 'the_content', $content ); 1175 1176 return $response; 1177 } 1178 1179 /** 1139 1180 * Returns a function that injects the theme attribute into, and hooked blocks before, a given block. 1140 1181 * -
trunk/src/wp-includes/default-filters.php
r58291 r58292 761 761 add_filter( 'rest_pre_insert_wp_navigation', 'update_ignored_hooked_blocks_postmeta' ); 762 762 763 // Inject hooked blocks into the wp_navigation post type REST response. 764 add_filter( 'rest_prepare_wp_navigation', 'insert_hooked_blocks_into_rest_response', 10, 2 ); 765 763 766 unset( $filter, $action );
Note: See TracChangeset
for help on using the changeset viewer.