Changeset 58785
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-template-utils.php
r58768 r58785 1603 1603 } 1604 1604 1605 if ( ! isset( $changes->post_content ) ) { 1606 return $changes; 1607 } 1608 1605 1609 $hooked_blocks = get_hooked_blocks(); 1606 1610 if ( empty( $hooked_blocks ) && ! has_filter( 'hooked_block_types' ) ) { -
trunk/tests/phpunit/tests/block-templates/injectIgnoredHookedBlocksMetadataAttributes.php
r58614 r58785 622 622 ); 623 623 } 624 625 /** 626 * @ticket 61550 627 */ 628 public function test_inject_ignored_hooked_blocks_metadata_attributes_into_template_with_no_changes_to_post_content() { 629 register_block_type( 630 'tests/hooked-block', 631 array( 632 'block_hooks' => array( 633 'core/heading' => 'after', 634 ), 635 ) 636 ); 637 638 $id = self::TEST_THEME . '//' . 'my_template'; 639 $template = get_block_template( $id, 'wp_template' ); 640 641 $changes = new stdClass(); 642 $changes->ID = $template->wp_id; 643 644 // Note that we're not setting `$changes->post_content`! 645 646 $post = inject_ignored_hooked_blocks_metadata_attributes( $changes ); 647 $this->assertFalse( 648 isset( $post->post_content ), 649 "post_content shouldn't have been set." 650 ); 651 } 652 653 /** 654 * @ticket 61550 655 */ 656 public function test_inject_ignored_hooked_blocks_metadata_attributes_into_template_part_with_no_changes_to_post_content() { 657 register_block_type( 658 'tests/hooked-block', 659 array( 660 'block_hooks' => array( 661 'core/heading' => 'after', 662 ), 663 ) 664 ); 665 666 $id = self::TEST_THEME . '//' . 'my_template_part'; 667 $template = get_block_template( $id, 'wp_template_part' ); 668 669 $changes = new stdClass(); 670 $changes->ID = $template->wp_id; 671 // Note that we're not setting `$changes->post_content`! 672 673 $post = inject_ignored_hooked_blocks_metadata_attributes( $changes ); 674 $this->assertFalse( 675 isset( $post->post_content ), 676 "post_content shouldn't have been set." 677 ); 678 } 624 679 }
Note: See TracChangeset
for help on using the changeset viewer.