Changeset 2406757
- Timestamp:
- 10/26/2020 01:03:38 PM (5 years ago)
- Location:
- gutenberg/trunk
- Files:
-
- 6 edited
-
changelog.txt (modified) (1 diff)
-
gutenberg.php (modified) (2 diffs)
-
lib/class-wp-block-supports.php (modified) (4 diffs)
-
lib/class-wp-block.php (modified) (2 diffs)
-
lib/compat.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gutenberg/trunk/changelog.txt
r2404624 r2406757 1 1 == 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) 2 8 3 9 = 9.2.1 = -
gutenberg/trunk/gutenberg.php
r2404624 r2406757 6 6 * Requires at least: 5.3 7 7 * Requires PHP: 5.6 8 * Version: 9.2. 18 * Version: 9.2.2 9 9 * Author: Gutenberg Team 10 10 * Text Domain: gutenberg … … 14 14 15 15 ### BEGIN AUTO-GENERATED DEFINES 16 define( 'GUTENBERG_VERSION', '9.2. 1' );17 define( 'GUTENBERG_GIT_COMMIT', ' f798da665b21fd76606fd46c7cc08432bcde007e' );16 define( 'GUTENBERG_VERSION', '9.2.2' ); 17 define( 'GUTENBERG_GIT_COMMIT', '28b1593597ced9fd9dfb3450ad8dca9f087ab198' ); 18 18 ### END AUTO-GENERATED DEFINES 19 19 -
gutenberg/trunk/lib/class-wp-block-supports.php
r2403733 r2406757 19 19 */ 20 20 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; 21 28 22 29 /** … … 68 75 * the given block all of the features that the block supports. 69 76 * 70 * @param array $parsed_block Block as parsed from content.71 77 * @return array Array of HTML attributes. 72 78 */ 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']; 75 81 $block_type = WP_Block_Type_Registry::get_instance()->get_registered( 76 $parsed_block['blockName']82 self::$block_to_render['blockName'] 77 83 ); 78 84 … … 145 151 */ 146 152 function 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(); 149 154 150 155 if ( empty( $new_attributes ) && empty( $extra_attributes ) ) { … … 192 197 } 193 198 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 */ 209 function 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 194 234 add_action( 'init', array( 'WP_Block_Supports', 'init' ), 22 ); 235 add_filter( 'register_block_type_args', 'wp_block_supports_track_block_to_render' ); -
gutenberg/trunk/lib/class-wp-block.php
r2403733 r2406757 204 204 public function render( $options = array() ) { 205 205 global $post; 206 global $current_parsed_block;207 206 $options = array_replace( 208 207 array( … … 218 217 $index = 0; 219 218 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(); 228 222 } 229 223 } -
gutenberg/trunk/lib/compat.php
r2404624 r2406757 509 509 } 510 510 add_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 track520 * of the current block being rendered via a global variable521 * called $current_parsed_block.522 *523 * This is for get_block_wrapper_attributes to get access524 * 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.1529 *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 4 4 Tested up to: 5.5 5 5 Requires PHP: 5.6 6 Stable tag: 9.2. 16 Stable tag: 9.2.2 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 58 58 == Changelog == 59 59 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>.60 To 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.