Changeset 58234
- Timestamp:
- 05/29/2024 11:55:27 AM (2 months ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-block.php
r58084 r58234 409 409 public function render( $options = array() ) { 410 410 global $post; 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 411 434 $options = wp_parse_args( 412 435 $options, … … 534 557 $block_content = apply_filters( "render_block_{$this->name}", $block_content, $this->parsed_block, $this ); 535 558 559 560 561 562 563 564 536 565 return $block_content; 537 566 } -
trunk/src/wp-includes/deprecated.php
r58090 r58234 6319 6319 return $block_content; 6320 6320 } 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 -
trunk/src/wp-includes/interactivity-api/interactivity-api.php
r57826 r58234 7 7 * @since 6.5.0 8 8 */ 9 10 /**11 * Processes the directives on the rendered HTML of the interactive blocks.12 *13 * This processes only one root interactive block at a time because the14 * rendered HTML of that block contains the rendered HTML of all its inner15 * blocks, including any interactive block. It does so by ignoring all the16 * interactive inner blocks until the root interactive block is processed.17 *18 * @since 6.5.019 *20 * @param array $parsed_block The parsed block.21 * @return array The same parsed block.22 */23 function wp_interactivity_process_directives_of_interactive_blocks( array $parsed_block ): array {24 static $root_interactive_block = null;25 26 /*27 * Checks whether a root interactive block is already annotated for28 * processing, and if it is, it ignores the subsequent ones.29 */30 if ( null === $root_interactive_block ) {31 $block_name = $parsed_block['blockName'];32 $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_name );33 34 if (35 isset( $block_name ) &&36 ( ( isset( $block_type->supports['interactivity'] ) && true === $block_type->supports['interactivity'] ) ||37 ( isset( $block_type->supports['interactivity']['interactive'] ) && true === $block_type->supports['interactivity']['interactive'] ) )38 ) {39 // Annotates the root interactive block for processing.40 $root_interactive_block = array( $block_name, $parsed_block );41 42 /*43 * Adds a filter to process the root interactive block once it has44 * finished rendering.45 */46 $process_interactive_blocks = static function ( string $content, array $parsed_block ) use ( &$root_interactive_block, &$process_interactive_blocks ): string {47 // Checks whether the current block is the root interactive block.48 list($root_block_name, $root_parsed_block) = $root_interactive_block;49 if ( $root_block_name === $parsed_block['blockName'] && $parsed_block === $root_parsed_block ) {50 // The root interactive blocks has finished rendering, process it.51 $content = wp_interactivity_process_directives( $content );52 // Removes the filter and reset the root interactive block.53 remove_filter( 'render_block_' . $parsed_block['blockName'], $process_interactive_blocks );54 $root_interactive_block = null;55 }56 return $content;57 };58 59 /*60 * Uses a priority of 100 to ensure that other filters can add additional61 * directives before the processing starts.62 */63 add_filter( 'render_block_' . $block_name, $process_interactive_blocks, 100, 2 );64 }65 }66 67 return $parsed_block;68 }69 /*70 * Uses a priority of 100 to ensure that other filters can add additional attributes to71 * $parsed_block before the processing starts.72 */73 add_filter( 'render_block_data', 'wp_interactivity_process_directives_of_interactive_blocks', 100, 1 );74 9 75 10 /** -
trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPIFunctions.php
r57987 r58234 526 526 $this->assertNull( $input_value ); 527 527 } 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 528 564 }
Note: See TracChangeset
for help on using the changeset viewer.