7 Commits

Author SHA1 Message Date
audrasjb ff6d1641d8 Code Modernization: Replace strpos() with str_contains().
This changeset replaces recently introduced `false !== strpos( ... )` and `false === strpos( ... )` with `str_contains()` in core files, making the code more readable and consistent, as well as better aligned with modern development practices.

Introduced in [60269] and [60939]. Fixed during WCEU2026 contribution day.

Follow-up to [52039], [55988], [56245], [60269] and [60939].

Props Soean, mukesh27.
Fixes #65408.


Built from https://develop.svn.wordpress.org/trunk@62461


git-svn-id: http://core.svn.wordpress.org/trunk@61742 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2026-06-04 14:09:43 +00:00
dmsnell 84b291c319 Blocks: Ensure extract_full_block_and_advance() matches parse_blocks()
The behavior of WP_Block_Processor::extract_full_block_and_advance() should produce an identical output to what parse_blocks() would return on the same substring of input.

Unfortunately, when HTML spans followed inner blocks, they were being omitted in the output parse tree. This was due to an omission in the original code which would look for those blocks before advancing again after calling `extract_full_block_and_advance()` recursively.

This patch adds the missing check and resolves the discrepancy.

Developed in: https://github.com/WordPress/wordpress-develop/pull/10769
Discussed in: https://core.trac.wordpress.org/ticket/64538

Follow-up to [60939].

Props dmsnell, jonsurrell, jorbin.
Fixes #64537.

Built from https://develop.svn.wordpress.org/trunk@61509


git-svn-id: http://core.svn.wordpress.org/trunk@60820 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2026-01-22 01:12:36 +00:00
dmsnell 653082d744 Block Processor: Fix is_block_type() for inner HTML
Previously, the WP_Block_Processor class was making a mistake in
mis-reporting whether a token matches a block type when #innerHTML spans
are involved.

This patch fixes the logic, which was originally written before a
distinction between inner HTML and top-level freeform content was built.

Developed in https://github.com/WordPress/wordpress-develop/pull/10701
Discussed in https://core.trac.wordpress.org/ticket/64485

Fixes #64485.

Built from https://develop.svn.wordpress.org/trunk@61452


git-svn-id: http://core.svn.wordpress.org/trunk@60764 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2026-01-08 23:45:59 +00:00
dmsnell 1f8967b293 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 https://github.com/WordPress/wordpress-develop/pull/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
2025-11-24 21:54:34 +00:00
Aaron Jorbin cf38be60a7 Coding Standards: Fix blank spaces.
Nice to meet you, where you been?

See #63168.

Built from https://develop.svn.wordpress.org/trunk@61036


git-svn-id: http://core.svn.wordpress.org/trunk@60372 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-21 14:03:27 +00:00
Aaron Jorbin d85e98edf8 Coding Standards: Use preincrment.
Sorry Dennis.

Introduced in [60939].
See #63168.



Built from https://develop.svn.wordpress.org/trunk@61035


git-svn-id: http://core.svn.wordpress.org/trunk@60371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2025-10-21 14:01:58 +00:00
dmsnell d9547eadf7 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
2025-10-15 21:53:28 +00:00