Editor: Fix post editor layout when Post Content has no attributes.

Changes output of `wp_get_post_content_block_attributes` to return null if Post Content block doesn’t exist or empty array if it has no attributes.

Props flixos90, mukesh27.
Fixes #59358.


git-svn-id: https://develop.svn.wordpress.org/trunk@56629 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Isabel Brison
2023-09-20 01:24:32 +00:00
parent a0cce3900e
commit bee2dc4ba2
7 changed files with 144 additions and 7 deletions
+21 -2
View File
@@ -446,14 +446,20 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
'type' => 'constrained',
),
);
// With no block theme, expect an empty array.
$this->assertSame( array(), wp_get_post_content_block_attributes() );
// With no block theme, expect null.
$this->assertNull( wp_get_post_content_block_attributes() );
switch_theme( 'block-theme' );
$this->assertSame( $attributes_with_layout, wp_get_post_content_block_attributes() );
}
public function test_wp_get_post_content_block_attributes_no_layout() {
switch_theme( 'block-theme-post-content-default' );
$this->assertSame( array(), wp_get_post_content_block_attributes() );
}
/**
* @ticket 53458
*/
@@ -527,6 +533,19 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
switch_theme( WP_DEFAULT_THEME );
}
/**
* @ticket 59358
*/
public function test_get_block_editor_settings_without_post_content_block() {
$post_editor_context = new WP_Block_Editor_Context( array( 'post' => get_post() ) );
$settings = get_block_editor_settings( array(), $post_editor_context );
$this->assertArrayNotHasKey( 'postContentAttributes', $settings );
}
/**
* @ticket 52920
* @expectedDeprecated block_editor_settings
+1
View File
@@ -185,6 +185,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
'Block Theme [0.4.0]',
'Block Theme [1.0.0] in subdirectory',
'Block Theme Deprecated Path',
'Block Theme Post Content Default',
'Block Theme with defined Typography Fonts',
'Empty `fontFace` in theme.json - no webfonts defined',
'A theme with the Update URI header',