Skip to content
Open
Prev Previous commit
Next Next commit
The freeform-check is redundant, already handled by the matching logic.
  • Loading branch information
dmsnell committed Jan 7, 2026
commit 35019d2c8b3c1a6500f1905a82a071f21edcc0d6
Original file line number Diff line number Diff line change
Expand Up @@ -397,15 +397,10 @@ function twenty_twenty_one_print_first_instance_of_block( $block_name, $content

// Loop top-level blocks, releasing them from memory as soon as possible.
while ( $instance_count < $instances && null !== ( $block = array_shift( $blocks ) ) ) {
// Skip inter-block whitespace and other freeform non-block HTML.
if ( ! isset( $block['blockName'] ) ) {
continue;
}

if (
$match_fully
? $block_name === $block['blockName']
: str_starts_with( $block['blockName'], $prefix )
: str_starts_with( $block['blockName'] ?? '', $prefix )
Copy link

@sabernhardt sabernhardt Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str_starts_with theoretically could be a problem in the legacy fallback if the site runs:

(I do not recommend editing the legacy code because then you need to test it with legacy systems.)

Any site that supports WP_Block_Processor should support str_starts_with too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in 99968c4 I removed str_starts_with() because it’s easy enough to avoid it. theoretically it would be possible that someone manually adds the WP_Block_Processor class on an old install without it.

in the process I discovered a bug I had overlooked with precedence in the conditional. this has been resolved by splitting the conditional into two.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and in 52e0dd3 I added it back, but added the feature gate. after undoing the legacy changes it didn’t seem as important to keep things coherent between them. I also misunderstood your comment initially because I overlooked that I introduced str_starts_with() in the legacy updates.

) {
$blocks_content .= render_block( $block );
++$instance_count;
Expand Down
Loading