Changeset 56629
- Timestamp:
- 09/20/2023 01:24:32 AM (15 months ago)
- Location:
- trunk
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-editor.php
r56500 r56629 410 410 * 411 411 * @since 6.3.0 412 * @since 6.4.0 Return null if there is no post content block. 412 413 * @access private 413 414 * 414 415 * @global int $post_ID 415 416 * 416 * @return array Post Content block attributes or empty array if they don't exist.417 * @return array|null Post Content block attributes array or null if Post Content block doesn't exist. 417 418 */ 418 419 function wp_get_post_content_block_attributes() { … … 422 423 423 424 if ( ! $is_block_theme || ! $post_ID ) { 424 return array();425 return null; 425 426 } 426 427 … … 458 459 $post_content_block = wp_get_first_block( $template_blocks, 'core/post-content' ); 459 460 460 if ( ! empty( $post_content_block['attrs'] ) ) {461 if ( isset( $post_content_block['attrs'] ) ) { 461 462 return $post_content_block['attrs']; 462 463 } 463 464 } 464 465 465 return array();466 return null; 466 467 } 467 468 … … 636 637 $post_content_block_attributes = wp_get_post_content_block_attributes(); 637 638 638 if ( ! empty( $post_content_block_attributes ) ) {639 if ( isset( $post_content_block_attributes ) ) { 639 640 $editor_settings['postContentAttributes'] = $post_content_block_attributes; 640 641 } -
trunk/tests/phpunit/tests/blocks/editor.php
r56619 r56629 447 447 ), 448 448 ); 449 // With no block theme, expect an empty array. 449 // With no block theme, expect null. 450 $this->assertNull( wp_get_post_content_block_attributes() ); 451 452 switch_theme( 'block-theme' ); 453 454 $this->assertSame( $attributes_with_layout, wp_get_post_content_block_attributes() ); 455 } 456 457 public function test_wp_get_post_content_block_attributes_no_layout() { 458 switch_theme( 'block-theme-post-content-default' ); 459 450 460 $this->assertSame( array(), wp_get_post_content_block_attributes() ); 451 452 switch_theme( 'block-theme' );453 454 $this->assertSame( $attributes_with_layout, wp_get_post_content_block_attributes() );455 461 } 456 462 … … 529 535 530 536 /** 537 * @ticket 59358 538 */ 539 public function test_get_block_editor_settings_without_post_content_block() { 540 541 $post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) ); 542 543 $settings = get_block_editor_settings( array(), $post_editor_context ); 544 545 $this->assertArrayNotHasKey( 'postContentAttributes', $settings ); 546 547 } 548 549 /** 531 550 * @ticket 52920 532 551 * @expectedDeprecated block_editor_settings -
trunk/tests/phpunit/tests/theme/themeDir.php
r56621 r56629 186 186 'Block Theme [1.0.0] in subdirectory', 187 187 'Block Theme Deprecated Path', 188 'Block Theme Post Content Default', 188 189 'Block Theme with defined Typography Fonts', 189 190 'Empty `fontFace` in theme.json - no webfonts defined',
Note: See TracChangeset
for help on using the changeset viewer.