Skip to content

Commit 737b12f

Browse files
committed
By reusing match-text/prefix PHP can release $block_name earlier.
this won’t matter, but it’s easy to add now
1 parent cfbff7f commit 737b12f

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/wp-content/themes/twentytwentyone/inc/template-functions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ function twenty_twenty_one_print_first_instance_of_block( $block_name, $content
371371
// Loop over top-level blocks.
372372
if ( class_exists( '\WP_Block_Processor' ) && function_exists( '\str_starts_with' ) ) {
373373
// Scan for blocks whose block type matches the prefix, if provided a wildcard.
374-
$prefix = rtrim( $block_name, '*' );
375-
$match_fully = $prefix === $block_name;
374+
$match_text = rtrim( $block_name, '*' );
375+
$match_fully = $match_text === $block_name;
376376
$processor = new WP_Block_Processor( $content );
377377

378378
while ( $instances_count < $instances && $processor->next_block() ) {
@@ -387,8 +387,8 @@ function twenty_twenty_one_print_first_instance_of_block( $block_name, $content
387387
* In each case, the condition only holds when the match is successful.
388388
*/
389389
$match_fully
390-
? $processor->is_block_type( $block_name )
391-
: str_starts_with( $processor->get_printable_block_type(), $prefix )
390+
? $processor->is_block_type( $match_text )
391+
: str_starts_with( $processor->get_printable_block_type(), $match_text )
392392
) {
393393
$blocks_content .= render_block( $processor->extract_full_block_and_advance() );
394394
++$instances_count;

0 commit comments

Comments
 (0)