Blocks: Introduce WP_Block_Processor for efficiently parsing blocks.
The Block Processor follows the HTML API in providing a streaming, near-zero-overhead, lazy, re-entrant parser for traversing block structure. This class provides an alternate interface to `parse_blocks()` which is more amenable to a number of common server-side operations on posts, especially those needing to operate on only a part of a full post. Developed in https://github.com/WordPress/wordpress-develop/pull/9105 Discussed in https://core.trac.wordpress.org/ticket/61401 Props dmsnell, gziolo, jonsurrell, soean, tjnowell, westonruter. Fixes #61401. Built from https://develop.svn.wordpress.org/trunk@60939 git-svn-id: http://core.svn.wordpress.org/trunk@60275 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -2376,6 +2376,17 @@ function render_block( $parsed_block ) {
|
||||
/**
|
||||
* Parses blocks out of a content string.
|
||||
*
|
||||
* Given an HTML document, this function fully-parses block content, producing
|
||||
* a tree of blocks and their contents, as well as top-level non-block content,
|
||||
* which will appear as a block with no `blockName`.
|
||||
*
|
||||
* This function can be memory heavy for certain documents, particularly those
|
||||
* with deeply-nested blocks or blocks with extensive attribute values. Further,
|
||||
* this function must parse an entire document in one atomic operation.
|
||||
*
|
||||
* If the entire parsed document is not necessary, consider using {@see WP_Block_Processor}
|
||||
* instead, as it provides a streaming and low-overhead interface for finding blocks.
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param string $content Post content.
|
||||
|
||||
1983
wp-includes/class-wp-block-processor.php
Normal file
1983
wp-includes/class-wp-block-processor.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.9-alpha-60938';
|
||||
$wp_version = '6.9-alpha-60939';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
@@ -268,6 +268,7 @@ require ABSPATH . WPINC . '/html-api/class-wp-html-token.php';
|
||||
require ABSPATH . WPINC . '/html-api/class-wp-html-stack-event.php';
|
||||
require ABSPATH . WPINC . '/html-api/class-wp-html-processor-state.php';
|
||||
require ABSPATH . WPINC . '/html-api/class-wp-html-processor.php';
|
||||
require ABSPATH . WPINC . '/class-wp-block-processor.php';
|
||||
require ABSPATH . WPINC . '/class-wp-http.php';
|
||||
require ABSPATH . WPINC . '/class-wp-http-streams.php';
|
||||
require ABSPATH . WPINC . '/class-wp-http-curl.php';
|
||||
|
||||
Reference in New Issue
Block a user