Make WordPress Core


Ignore:
Timestamp:
09/20/2023 01:24:32 AM (20 months ago)
Author:
isabel_brison
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/blocks/editor.php

    r56619 r56629  
    447447            ),
    448448        );
    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
    450460        $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() );
    455461    }
    456462
     
    529535
    530536    /**
     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    /**
    531550     * @ticket 52920
    532551     * @expectedDeprecated block_editor_settings
Note: See TracChangeset for help on using the changeset viewer.