WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/26/2020 08:29:04 AM (6 months ago)
Author:
youknowriad
Message:

Block Editor: Fix WP_Block_Supports class compatibility with Gutenberg-provided class.

When using WordPress trunk with Gutenberg master, there's an incompatibility causing
the dynamic block generated classes to be omitted.
This commit refactors the block supports to fix that problem.

Props nosolosw.
Fixes #51606.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block.php

    r49226 r49310  
    193193     */
    194194    public function render( $options = array() ) {
    195         global $post, $current_parsed_block;
     195        global $post;
    196196        $options = wp_parse_args(
    197197            $options,
     
    207207            $index = 0;
    208208            foreach ( $this->inner_content as $chunk ) {
    209                 if ( is_string( $chunk ) ) {
    210                     $block_content .= $chunk;
    211                 } else {
    212                     $parent_parsed_block  = $current_parsed_block;
    213                     $current_parsed_block = $this->inner_blocks[ $index ]->parsed_block;
    214                     $block_content       .= $this->inner_blocks[ $index++ ]->render();
    215                     $current_parsed_block = $parent_parsed_block;
    216                 }
     209                $block_content .= is_string( $chunk ) ?
     210                    $chunk :
     211                    $this->inner_blocks[ $index++ ]->render();
    217212            }
    218213        }
     
    220215        if ( $is_dynamic ) {
    221216            $global_post   = $post;
     217            $parent = WP_Block_Supports::$block_to_render;
     218            WP_Block_Supports::$block_to_render = $this->parsed_block;
    222219            $block_content = (string) call_user_func( $this->block_type->render_callback, $this->attributes, $block_content, $this );
     220            WP_Block_Supports::$block_to_render = $parent;
    223221            $post          = $global_post;
    224222        }
Note: See TracChangeset for help on using the changeset viewer.