Skip to content

Commit 1f8967b

Browse files
committed
Block Processor: Rename extract_block() method for clearer documentation.
In testing during the release candidacy for WordPress 6.9 it was found that the `extract_block()` method may do more work than is expected based off of its name. This change renames the method to `extract_full_block_and_advance()` to communicate that it does move the Block Processor forward and to hint at the fact that it also encompasses all inner blocks during that advance. Developed in WordPress/wordpress-develop#10538 Discussed in https://core.trac.wordpress.org/ticket/61401 Follow-up to [60939]. Props dlh, dmsnell, jonsurrell, westonruter. See #61401. Built from https://develop.svn.wordpress.org/trunk@61294 git-svn-id: http://core.svn.wordpress.org/trunk@60606 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 73b24b0 commit 1f8967b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

wp-includes/class-wp-block-processor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
* block, and re-serialize it into the original document. It’s possible to do so
195195
* while skipping over the parse of the rest of the document.
196196
*
197-
* {@see self::extract_block()} will scan forward from the current block opener
197+
* {@see self::extract_full_block_and_advance()} will scan forward from the current block opener
198198
* and build the parsed block structure until the current block is closed. It will
199199
* include all inner HTML and inner blocks, and parse all of the inner blocks. It
200200
* can be used to extract a block at any depth in the document, helpful for operating
@@ -207,7 +207,7 @@
207207
* }
208208
*
209209
* $gallery_at = $processor->get_span()->start;
210-
* $gallery_block = $processor->extract_block();
210+
* $gallery_block = $processor->extract_full_block_and_advance();
211211
* $after_gallery = $processor->get_span()->start;
212212
* return (
213213
* substr( $post_content, 0, $gallery_at ) .
@@ -1223,7 +1223,7 @@ public function get_depth(): int {
12231223
* }
12241224
*
12251225
* $gallery_at = $processor->get_span()->start;
1226-
* $gallery = $processor->extract_block();
1226+
* $gallery = $processor->extract_full_block_and_advance();
12271227
* $ends_before = $processor->get_span();
12281228
* $ends_before = $ends_before->start ?? strlen( $post_content );
12291229
*
@@ -1254,7 +1254,7 @@ public function get_depth(): int {
12541254
* }
12551255
* }
12561256
*/
1257-
public function extract_block(): ?array {
1257+
public function extract_full_block_and_advance(): ?array {
12581258
if ( $this->is_html() ) {
12591259
$chunk = $this->get_html_content();
12601260

@@ -1291,7 +1291,7 @@ public function extract_block(): ?array {
12911291
* @todo Use iteration instead of recursion, or at least refactor to tail-call form.
12921292
*/
12931293
if ( $this->opens_block() ) {
1294-
$inner_block = $this->extract_block();
1294+
$inner_block = $this->extract_full_block_and_advance();
12951295
$block['innerBlocks'][] = $inner_block;
12961296
$block['innerContent'][] = null;
12971297
}

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '7.0-alpha-61291';
19+
$wp_version = '7.0-alpha-61294';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)