Plugin Directory

Changeset 2406757


Ignore:
Timestamp:
10/26/2020 01:03:38 PM (5 years ago)
Author:
nosolosw
Message:

Commiting Gutenberg version 9.2.2

Location:
gutenberg/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • gutenberg/trunk/changelog.txt

    r2404624 r2406757  
    11== Changelog ==
     2
     3= 9.2.2 =
     4
     5### Bug Fixes
     6
     7- Fix widget previews in the widget screen [26356](https://github.com/WordPress/gutenberg/pull/26356) [26417](https://github.com/WordPress/gutenberg/pull/26417)
    28
    39= 9.2.1 =
  • gutenberg/trunk/gutenberg.php

    r2404624 r2406757  
    66 * Requires at least: 5.3
    77 * Requires PHP: 5.6
    8  * Version: 9.2.1
     8 * Version: 9.2.2
    99 * Author: Gutenberg Team
    1010 * Text Domain: gutenberg
     
    1414
    1515### BEGIN AUTO-GENERATED DEFINES
    16 define( 'GUTENBERG_VERSION', '9.2.1' );
    17 define( 'GUTENBERG_GIT_COMMIT', 'f798da665b21fd76606fd46c7cc08432bcde007e' );
     16define( 'GUTENBERG_VERSION', '9.2.2' );
     17define( 'GUTENBERG_GIT_COMMIT', '28b1593597ced9fd9dfb3450ad8dca9f087ab198' );
    1818### END AUTO-GENERATED DEFINES
    1919
  • gutenberg/trunk/lib/class-wp-block-supports.php

    r2403733 r2406757  
    1919     */
    2020    private $block_supports = array();
     21
     22    /**
     23     * Tracks the current block to be rendered.
     24     *
     25     * @var array
     26     */
     27    public static $block_to_render = null;
    2128
    2229    /**
     
    6875     * the given block all of the features that the block supports.
    6976     *
    70      * @param  array $parsed_block Block as parsed from content.
    7177     * @return array               Array of HTML attributes.
    7278     */
    73     public function apply_block_supports( $parsed_block ) {
    74         $block_attributes = $parsed_block['attrs'];
     79    public function apply_block_supports() {
     80        $block_attributes = self::$block_to_render['attrs'];
    7581        $block_type       = WP_Block_Type_Registry::get_instance()->get_registered(
    76             $parsed_block['blockName']
     82            self::$block_to_render['blockName']
    7783        );
    7884
     
    145151 */
    146152function get_block_wrapper_attributes( $extra_attributes = array() ) {
    147     global $current_parsed_block;
    148     $new_attributes = WP_Block_Supports::get_instance()->apply_block_supports( $current_parsed_block );
     153    $new_attributes = WP_Block_Supports::get_instance()->apply_block_supports();
    149154
    150155    if ( empty( $new_attributes ) && empty( $extra_attributes ) ) {
     
    192197}
    193198
     199/**
     200 * Callback hooked to the register_block_type_args filter.
     201 *
     202 * This hooks into block registration to wrap the render_callback
     203 * of dynamic blocks with a closure that keeps track of the
     204 * current block to be rendered.
     205 *
     206 * @param array $args Block attributes.
     207 * @return array Block attributes.
     208 */
     209function wp_block_supports_track_block_to_render( $args ) {
     210    if ( is_callable( $args['render_callback'] ) ) {
     211        $block_render_callback   = $args['render_callback'];
     212        $args['render_callback'] = function( $attributes, $content, $block = null ) use ( $block_render_callback ) {
     213            // Check for null for back compatibility with WP_Block_Type->render
     214            // which is unused since the introduction of WP_Block class.
     215            //
     216            // See:
     217            // - https://core.trac.wordpress.org/ticket/49927
     218            // - commit 910de8f6890c87f93359c6f2edc6c27b9a3f3292 at wordpress-develop.
     219
     220            if ( null === $block ) {
     221                return $block_render_callback( $attributes, $content );
     222            }
     223
     224            $parent_block                       = WP_Block_Supports::$block_to_render;
     225            WP_Block_Supports::$block_to_render = $block->parsed_block;
     226            $result                             = $block_render_callback( $attributes, $content, $block );
     227            WP_Block_Supports::$block_to_render = $parent_block;
     228            return $result;
     229        };
     230    }
     231    return $args;
     232}
     233
    194234add_action( 'init', array( 'WP_Block_Supports', 'init' ), 22 );
     235add_filter( 'register_block_type_args', 'wp_block_supports_track_block_to_render' );
  • gutenberg/trunk/lib/class-wp-block.php

    r2403733 r2406757  
    204204    public function render( $options = array() ) {
    205205        global $post;
    206         global $current_parsed_block;
    207206        $options = array_replace(
    208207            array(
     
    218217            $index = 0;
    219218            foreach ( $this->inner_content as $chunk ) {
    220                 if ( is_string( $chunk ) ) {
    221                     $block_content .= $chunk;
    222                 } else {
    223                     $parent_parsed_block  = $current_parsed_block;
    224                     $current_parsed_block = $this->inner_blocks[ $index ]->parsed_block;
    225                     $block_content       .= $this->inner_blocks[ $index++ ]->render();
    226                     $current_parsed_block = $parent_parsed_block;
    227                 }
     219                $block_content .= is_string( $chunk ) ?
     220                    $chunk :
     221                    $this->inner_blocks[ $index++ ]->render();
    228222            }
    229223        }
  • gutenberg/trunk/lib/compat.php

    r2404624 r2406757  
    509509}
    510510add_filter( 'post_type_labels_wp_block', 'gutenberg_override_reusable_block_post_type_labels', 10, 0 );
    511 
    512 global $current_parsed_block;
    513 $current_parsed_block = array(
    514     'blockName'  => null,
    515     'attributes' => null,
    516 );
    517 
    518 /**
    519  * Wraps the render_callback of dynamic blocks to keep track
    520  * of the current block being rendered via a global variable
    521  * called $current_parsed_block.
    522  *
    523  * This is for get_block_wrapper_attributes to get access
    524  * to the runtime data of the block being rendered.
    525  *
    526  * This shim can be removed when the plugin requires WordPress 5.6.
    527  *
    528  * @since 9.2.1
    529  *
    530  * @param array $args Block attributes.
    531  * @return array Block attributes.
    532  */
    533 function gutenberg_current_parsed_block_tracking( $args ) {
    534     if ( null !== $args['render_callback'] ) {
    535         $block_render_callback   = $args['render_callback'];
    536         $args['render_callback'] = function( $attributes, $content, $block ) use ( $block_render_callback ) {
    537             global $current_parsed_block;
    538             $parent_parsed_block  = $current_parsed_block;
    539             $current_parsed_block = $block->parsed_block;
    540             $result               = $block_render_callback( $attributes, $content, $block );
    541             $current_parsed_block = $parent_parsed_block;
    542             return $result;
    543         };
    544     }
    545     return $args;
    546 }
    547 add_filter( 'register_block_type_args', 'gutenberg_current_parsed_block_tracking' );
  • gutenberg/trunk/readme.txt

    r2404626 r2406757  
    44Tested up to: 5.5
    55Requires PHP: 5.6
    6 Stable tag: 9.2.1
     6Stable tag: 9.2.2
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5858== Changelog ==
    5959
    60 To read the changelog for Gutenberg 9.2.1, please navigate to the <a href="https://github.com/WordPress/gutenberg/releases/tag/v9.2.1">release page</a>.
     60To read the changelog for Gutenberg 9.2.2, please navigate to the <a href="https://github.com/WordPress/gutenberg/releases/tag/v9.2.2">release page</a>.
Note: See TracChangeset for help on using the changeset viewer.