Skip to content

Commit

Permalink
Rearrange some recursion plans.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Dec 10, 2023
1 parent 40476d6 commit 3f74308
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/wp-includes/class-wp-block-patterns-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private function prepare_content( $pattern, $hooked_blocks, $at = 0 ) {
}

// @todo: Allow for core blocks without "core/" namespace.
if ( ! in_array( $block['name'], array_keys( $hooked_blocks ), true ) ) {
if ( ! isset( $hooked_blocks[ $block['name'] ] ) ) {
continue;
}

Expand Down Expand Up @@ -244,7 +244,33 @@ private function prepare_content( $pattern, $hooked_blocks, $at = 0 ) {

if ( 'opener' === $block['type'] ) {
$stack[] = $block;
// @todo add blocks if this inner block is a hooked block

/**
* <!-- anchor1 -->
* <!-- inner1 /-->
* <!-- inner2 -->

Check failure on line 251 in src/wp-includes/class-wp-block-patterns-registry.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Tabs must be used to indent lines; spaces are not allowed
* <!-- /inner2 -->

Check failure on line 252 in src/wp-includes/class-wp-block-patterns-registry.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Tabs must be used to indent lines; spaces are not allowed
* <!-- /anchor1 -->
*
*
* <!-- anchor1 -->
* <!-- inner1 /-->
* <!-- anchor2 --> <<<< restart here
* <!-- inner3 /-->
* <!-- /anchor2 --> >>>> return, replaced entire region with XYZ
* <!-- /anchor1 -->
*/
if ( isset( $hooked_blocks[ $block['name'] ] ) ) {
// recurse.
$new_region = recurse( $pattern, $hooked_blocks, $block['at'] );
$content = (
substr( $content, 0, $block['at'] ) .
$new_region .
substr( $content, $closing_block['at'] + $closing_block['length'] )
);
$block['length'] = strlen( $new_region );
$at = $block['at'] + $block['length'];
}
}

// @todo Check if this matches the name of the bottom stack item.
Expand Down

0 comments on commit 3f74308

Please sign in to comment.