Changeset 59482
- Timestamp:
- 12/04/2024 12:05:33 PM (7 weeks ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r59166 r59482 1218 1218 // Merge the existing post object with the updated post object to pass to the block hooks algorithm for context. 1219 1219 $context = (object) array_merge( (array) $existing_post, (array) $post ); 1220 $context = new WP_Post( $context ); // Convert to WP_Post object. 1220 1221 $serialized_block = apply_block_hooks_to_content( $markup, $context, 'set_ignored_hooked_blocks_metadata' ); 1221 1222 $root_block = parse_blocks( $serialized_block )[0]; -
trunk/tests/phpunit/tests/blocks/updateIgnoredHookedBlocksPostMeta.php
r58578 r59482 194 194 ); 195 195 } 196 197 /** 198 * @ticket 62639 199 */ 200 public function test_update_ignored_hooked_blocks_postmeta_sets_correct_context_type() { 201 $action = new MockAction(); 202 add_filter( 'hooked_block_types', array( $action, 'filter' ), 10, 4 ); 203 204 $original_markup = '<!-- wp:navigation-link {"label":"News","type":"page","id":2,"url":"http://localhost:8888/?page_id=2","kind":"post-type"} /-->'; 205 $post = new stdClass(); 206 $post->ID = self::$navigation_post->ID; 207 $post->post_content = $original_markup; 208 $post->post_type = 'wp_navigation'; 209 210 $post = update_ignored_hooked_blocks_postmeta( $post ); 211 212 $args = $action->get_args(); 213 $contexts = array_column( $args, 3 ); 214 215 foreach ( $contexts as $context ) { 216 $this->assertInstanceOf( 217 WP_Post::class, 218 $context, 219 'The context passed to the hooked_block_types filter is not a WP_Post instance.' 220 ); 221 } 222 } 196 223 }
Note: See TracChangeset
for help on using the changeset viewer.