Make WordPress Core


Ignore:
Timestamp:
09/20/2023 01:24:32 AM (2 years 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/src/wp-includes/block-editor.php

    r56500 r56629  
    410410 *
    411411 * @since 6.3.0
     412 * @since 6.4.0 Return null if there is no post content block.
    412413 * @access private
    413414 *
    414415 * @global int $post_ID
    415416 *
    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.
    417418 */
    418419function wp_get_post_content_block_attributes() {
     
    422423
    423424    if ( ! $is_block_theme || ! $post_ID ) {
    424         return array();
     425        return null;
    425426    }
    426427
     
    458459        $post_content_block = wp_get_first_block( $template_blocks, 'core/post-content' );
    459460
    460         if ( ! empty( $post_content_block['attrs'] ) ) {
     461        if ( isset( $post_content_block['attrs'] ) ) {
    461462            return $post_content_block['attrs'];
    462463        }
    463464    }
    464465
    465     return array();
     466    return null;
    466467}
    467468
     
    636637    $post_content_block_attributes = wp_get_post_content_block_attributes();
    637638
    638     if ( ! empty( $post_content_block_attributes ) ) {
     639    if ( isset( $post_content_block_attributes ) ) {
    639640        $editor_settings['postContentAttributes'] = $post_content_block_attributes;
    640641    }
Note: See TracChangeset for help on using the changeset viewer.