Skip to content

CSS API: Add CSS token processor foundations - #92

Draft
sirreal wants to merge 1044 commits into
trunkfrom
css-api/css-token-processor-foundations
Draft

sirreal wants to merge 1044 commits into
trunkfrom
css-api/css-token-processor-foundations

Conversation

@sirreal

@sirreal sirreal commented Jul 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add WP_CSS_Token_Processor as the low-level CSS Syntax tokenization foundation
  • add WP_CSS_Builder, used to serialize token values safely
  • support safe, repeatable updates to URL and string token values
  • load both classes during WordPress bootstrap
  • add focused unit coverage and the synchronized PHP Toolkit CSS corpus

This is intentionally extracted from css-api/add-css-token-processor without its adjacent stylesheet parser, font normalization, selector, and custom test-harness explorations. It provides a small base for follow-up CSS API work, including the style-attribute processor in #78.

Validation

  • WP_TESTS_SKIP_INSTALL=1 vendor/bin/phpunit tests/phpunit/tests/css-api/wpCssBuilder.php — 46 tests, 200 assertions
  • WP_TESTS_SKIP_INSTALL=1 vendor/bin/phpunit tests/phpunit/tests/css-api/wpCssTokenProcessor.php — 266 tests, 385 assertions
  • vendor/bin/phpcs --standard=phpcs.xml.dist on the four PHP files
  • git diff --check

Trac ticket: https://core.trac.wordpress.org/ticket/62653

Use of AI Tools

AI assistance: Yes
Tool(s): ChatGPT/Codex
Model(s): GPT-5
Used for: extracting the CSS foundations from the broader API exploration, refining the implementation and tests, adversarial review, and updating this PR description.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@sirreal
sirreal force-pushed the css-api/css-token-processor-foundations branch from b7e1df7 to 2a146f7 Compare July 23, 2026 10:31
@sirreal
sirreal force-pushed the css-api/css-token-processor-foundations branch from 2a146f7 to 7c1178c Compare August 26, 2026 09:57
Comment on lines +120 to +156
public static function string( string $value ): string {
$value = wp_scrub_utf8( $value );
$escaped = strtr(
$value,
array(
// Escape existing backslashes to prevent unintentional escapes in result.
'\\' => '\\5C ',

// Pre-processing replaces NULLs and some newlines. Replace and escape as necessary.
"\0" => "\u{FFFD}",

// Normalize and replace newlines. https://www.w3.org/TR/css-syntax-3/#input-preprocessing
"\r\n" => '\\A ',
"\r" => '\\A ',
"\f" => '\\A ',

// Newlines must be escaped in CSS strings.
"\n" => '\\A ',

// Arbitrary characters for Unicode escaping:

// HTML syntax may be problematic.
'<' => '\\3C ',
'>' => '\\3E ',
'&' => '\\26 ',

// CSS syntax may be problematic.
',' => '\\2C ',
';' => '\\3B ',
'{' => '\\7B ',
'}' => '\\7D ',
'"' => '\\22 ',
"'" => '\\27 ',
)
);
return "\"{$escaped}\"";
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This form of escaping is problematic because there are places in Core that use sanitize_text_field() for CSS. In the space-terminated escape sequences, the terminating whitespace character is significant, so the first space is consumed by the escape sequence. This means that 1 space becomes 0, 2 becomes 1, etc. If the adjacent 2 spaces are collapsed to 1, it breaks that input.

https://github.com/WordPress/wordpress-develop/blob/36d425e7bbd177507f0df6d543b1cb8d8a5da41a/src/wp-includes/fonts/class-wp-font-utils.php#L65

https://github.com/WordPress/wordpress-develop/blob/36d425e7bbd177507f0df6d543b1cb8d8a5da41a/src/wp-includes/formatting.php#L5751-L5754

That function seems unsuitable for the CSS escaping and should probably be replaced with the CSS functions in this PR, but in the interest of being defensive it may be best to always use the 6 character form of the escapes: \00003C instead of \3C . This may be less confusing and less likely to break downstream expectations, although either is a valid CSS Unicode escape sequence.

@sirreal
sirreal force-pushed the css-api/css-token-processor-foundations branch from 2ed7203 to 7711c31 Compare September 25, 2026 07:07
@sirreal
sirreal force-pushed the css-api/css-token-processor-foundations branch from 7711c31 to a9d4b5d Compare October 9, 2026 08:13
lancewillett and others added 24 commits October 17, 2026 18:53
Declare the data providers in `tests/phpunit/tests/functions/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Make the daylight-saving-time helper static so the timezone provider does not require an instance.

Developed in: WordPress#14382

Props rejaulalomkhan, huzaifaalmesbah.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@64440 602fd350-edb4-49c9-b593-d223f7449a82
Declare the data providers in `tests/phpunit/tests/admin/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Update direct calls to the submenu provider to use `self::`.

Developed in: WordPress#14389

Props rejaulalomkhan.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@64441 602fd350-edb4-49c9-b593-d223f7449a82
Declare the data providers in `tests/phpunit/tests/bookmark/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions.

Developed in: WordPress#14391

Props rejaulalomkhan.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@64442 602fd350-edb4-49c9-b593-d223f7449a82
Declare the data providers in `tests/phpunit/tests/sitemaps/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions.

Developed in: WordPress#14392

Props rejaulalomkhan.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@64443 602fd350-edb4-49c9-b593-d223f7449a82
Declare the data providers in `tests/phpunit/tests/comment/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions.

Developed in: WordPress#14393

Props rejaulalomkhan.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@64444 602fd350-edb4-49c9-b593-d223f7449a82
Declare the data providers in `tests/phpunit/tests/term/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions. Call the existing static `text_array_to_dataprovider()` helper with `self::`.

Developed in: WordPress#14395

Props rejaulalomkhan.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@64445 602fd350-edb4-49c9-b593-d223f7449a82
Declare the data providers in `tests/phpunit/tests/compat/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions.

Developed in: WordPress#14396

Props rejaulalomkhan.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@64446 602fd350-edb4-49c9-b593-d223f7449a82
Declare the data providers in `tests/phpunit/tests/date/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions.

Developed in: WordPress#14397

Props rejaulalomkhan.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@64447 602fd350-edb4-49c9-b593-d223f7449a82
Declare the data providers in `tests/phpunit/tests/fonts/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions.

Developed in: WordPress#14400

Props rejaulalomkhan.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@64448 602fd350-edb4-49c9-b593-d223f7449a82
Declare the data providers in `tests/phpunit/tests/block-supports/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions.

Developed in: WordPress#14398

Props rejaulalomkhan.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@64449 602fd350-edb4-49c9-b593-d223f7449a82
Declare the data providers in `tests/phpunit/tests/canonical/` as `public static` for compatibility with newer PHPUnit versions. Preserve their datasets and assertions.

Developed in: WordPress#14399

Props rejaulalomkhan.
See #66211.


git-svn-id: https://develop.svn.wordpress.org/trunk@64450 602fd350-edb4-49c9-b593-d223f7449a82
Replace the empty `test_prepare_item()` stub with assertions for page fields in the edit context and the `self`, `collection`, and `about` links returned by `WP_REST_Posts_Controller::prepare_item_for_response()`.

Developed in: WordPress#14384

Props rejaulalomkhan, huzaifaalmesbah.
See #40538.


git-svn-id: https://develop.svn.wordpress.org/trunk@64451 602fd350-edb4-49c9-b593-d223f7449a82
Replace the empty `test_prepare_item()` stub with assertions for the navigation ID, response status, and embeddable `self` link returned by `WP_REST_Navigation_Fallback_Controller::prepare_item_for_response()`. Verify that requesting only `id` through `_fields` omits links.

Developed in: WordPress#14385

Props rejaulalomkhan.
See #40538, #66073.


git-svn-id: https://develop.svn.wordpress.org/trunk@64452 602fd350-edb4-49c9-b593-d223f7449a82
Check leading and trailing whitespace, whitespace-only values, encoded separators, and character-reference boundaries in `class_list()`. Prevent empty class names and incorrect decoding from passing unnoticed.

Developed in: WordPress#14300

Props jonsurrell.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64453 602fd350-edb4-49c9-b593-d223f7449a82
Verify importer mappings, blog and user selection, request options, quota handling, and command-line argument parsing. Cover the 100-row boundary in `get_imported_posts()`.

Developed in: WordPress#14327

Props huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64454 602fd350-edb4-49c9-b593-d223f7449a82
Verify that `extract_serialized_parent_block()` retains the outer block and `remove_serialized_parent_block()` returns its inner content across nested blocks, attributes, comments, and whitespace.

Developed in: WordPress#14331

Props rejaulalomkhan.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64455 602fd350-edb4-49c9-b593-d223f7449a82
Covers category lookup by ID and object, array output, edit-con filtering, and invalid or wrong-taxonomy inputs.

Developed in: WordPress#14363

Props shailu25.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64456 602fd350-edb4-49c9-b593-d223f7449a82
Checks direct and indirect ancestry, unrelated categories, and term IDs from another taxonomy.

Developed in: WordPress#14364

Props shailu25.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64457 602fd350-edb4-49c9-b593-d223f7449a82
…t is not set.

This resolves an error if `mysqli_num_fields()` is called before a successful SELECT-type query is performed:
{{{
mysqli_num_fields(): Argument #1 ($result) must be of type mysqli_result, false given
}}}

Developed in WordPress#13099.

Follow-up to r21472.

Props joehorntw, akshat2802, mukesh27, rejaulalomkhan, SergeyBiryukov.
Fixes #64130.

git-svn-id: https://develop.svn.wordpress.org/trunk@64458 602fd350-edb4-49c9-b593-d223f7449a82
Verifies category cache invalidation and its action, plus regeneration of the category hierarchy option.

Developed in: WordPress#14365

Props shailu25, mukesh27.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64459 602fd350-edb4-49c9-b593-d223f7449a82
Covers object and array sanitization, filter arguments, and preservation of unset fields.

Developed in: WordPress#14366

Props shailu25, mukesh27.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64460 602fd350-edb4-49c9-b593-d223f7449a82
Checks field casting, con-specific filters and escaping, including the database slug path.

Developed in: WordPress#14367

Props shailu25, mukesh27.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64461 602fd350-edb4-49c9-b593-d223f7449a82
Covers post ID and global-post lookup, empty results, compatibility properties, and the categories filter.

Developed in: WordPress#14368

Props shailu25, mukesh27.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64462 602fd350-edb4-49c9-b593-d223f7449a82
Checks matching and missing categories, the empty-category case, global-post fallback, and invalid posts.

Developed in: WordPress#14369

Props shailu25, mukesh27.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64463 602fd350-edb4-49c9-b593-d223f7449a82
lancewillett and others added 30 commits October 20, 2026 21:32
Add coverage for `Plugin_Installer_Skin::do_overwrite()`, including comparison markup, update and downgrade actions, unmet requirements, and filtered output. Verify that `after()` stops after displaying the overwrite screen.

Developed in: WordPress#14576

Props huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64660 602fd350-edb4-49c9-b593-d223f7449a82
Add coverage for `Plugin_Upgrader::check_package()`, including invalid packages, plugin header discovery, remote path mapping, and unmet PHP and WordPress requirements. Verify uploaded plugin data and restore the filesystem global after each test.

Developed in: WordPress#14577

Props huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64661 602fd350-edb4-49c9-b593-d223f7449a82
Test `wp_plugin_update_row()` and `wp_plugin_update_rows()` across update availability, permissions, package and PHP requirements, escaped output, links, hooks, and multisite screens.

Developed in: WordPress#14578

Props huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64662 602fd350-edb4-49c9-b593-d223f7449a82
Test `wp_get_update_data()` for plugin, theme, core, and translation updates, including permissions, dismissed core updates, singular and plural titles, and filtered results.

Developed in: WordPress#14579

Props huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64663 602fd350-edb4-49c9-b593-d223f7449a82
Test `WP_Site_Health::detect_plugin_theme_auto_update_issues()` across plugin and theme auto-update filters, settings visibility, reported statuses, and filter arguments.

Developed in: WordPress#14580

Props huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64664 602fd350-edb4-49c9-b593-d223f7449a82
Test the plugin sections produced by `WP_Debug_Data`, including must-use plugins, active and inactive plugins, available updates, auto-update settings, and filtered debug strings.

Developed in: WordPress#14583

Props huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64665 602fd350-edb4-49c9-b593-d223f7449a82
Test `WP_Plugin_Dependencies::get_circular_dependencies()` and `WP_Plugin_Dependencies::check_for_circular_dependencies()` for cached results, acyclic dependencies, missing plugins, and dependency cycles.

Developed in: WordPress#14584

Props huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64666 602fd350-edb4-49c9-b593-d223f7449a82
Test `WP_Site_Health::get_test_plugin_version()` for active and inactive plugins, available updates, singular and plural descriptions, update links, and multisite behavior.

Developed in: WordPress#14582

Props huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64667 602fd350-edb4-49c9-b593-d223f7449a82
Test `WP_Plugins_List_Table::no_items()` for empty views, search terms, escaped output, directory links, installation permissions, and multisite behavior.

Developed in: WordPress#14585

Props huzaifaalmesbah.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64668 602fd350-edb4-49c9-b593-d223f7449a82
…heme_JSON`.

See #65860.



git-svn-id: https://develop.svn.wordpress.org/trunk@64669 602fd350-edb4-49c9-b593-d223f7449a82
For backward compatibility, `register_setting()` still accepts a sanitize callback as its third argument, converting it into the `sanitize_callback` argument without a deprecation notice. Its docblock documented `$args` only as an array, so once PHPStan began reading the hash notation in r63420, callers passing a callback were reported, such as Twenty Eleven and the deprecated `add_option_update_handler()`. This form remains in wide use across thousands of plugins and themes in the theme & plugin directories.

Developed in WordPress#14137.
Follow-up to r38635, r63420.

Props jorgefilipecosta, westonruter.
See #65817, #65860.


git-svn-id: https://develop.svn.wordpress.org/trunk@64670 602fd350-edb4-49c9-b593-d223f7449a82
This update adds four and removes five certificates to the bundle.

Props westonruter, peterwilsoncc.
Fixes #66355.


git-svn-id: https://develop.svn.wordpress.org/trunk@64671 602fd350-edb4-49c9-b593-d223f7449a82
PHPStan treated many install-dependent constants as fixed values. Those missing from `dynamicConstantNames` took their placeholder value from the PHPStan bootstrap, and listed ones without a type took the type of their only visible definition. For `WP_DEBUG_LOG` that definition was `false`, so the `is_string()` checks for a log file path in `wp_debug_mode()` and `WP_Debug_Data` were reported as impossible.

Every install-dependent constant now has an explicit type, including those the bootstrap had pinned, such as the content and plugin paths, the cookie names, the memory limits, and the timeouts. Each type is what core expects: the values it defines and documents, and that its reads are designed for. Where real-world configurations are known to define wider values, most often by passing `getenv()` through unconverted, a comment notes them along with how core handles them. Widening the types to cover such values instead would require handling invalid configuration at every read.

The bootstrap definitions remain, since PHPStan does not discover constants that core defines inside a function, but their values no longer affect the analysis. The `preg_replace()` results that define the cookie paths are cast to strings to fit their types, and the PHPUnit bootstrap now defines the memory limits as strings to match theirs.

Developed in WordPress#14034.
Follow-up to r61699, r62965, r63191, r63356.

Props rahultank, westonruter.
See #65817.


git-svn-id: https://develop.svn.wordpress.org/trunk@64672 602fd350-edb4-49c9-b593-d223f7449a82
Several `step_*()` methods in the HTML Processor can throw an `Exception` via `insert_virtual_node()` when bookmarks run out. Documenting this with `@throws` shows PHPStan that the generic `catch` in `step()` is reachable, so its `catch.neverThrown` ignore is removed. The existing `identical.alwaysFalse` ignore now covers that `catch` as well, since PHPStan cannot see `$last_error` being set by a call that throws.

Dead code is also removed from `wp-admin/plugins.php`, along with a redundant check in `WP_REST_Users_Controller::check_reassign()`, whose documented types are corrected.

Developed in WordPress#13073.
Follow-up to r39426, r63023, r64294.

Props dpantazis, westonruter.
See #65817.


git-svn-id: https://develop.svn.wordpress.org/trunk@64673 602fd350-edb4-49c9-b593-d223f7449a82
…anged.

Saving a secret's current value again demoted it to the previous slot. Settings forms do this on every submit, so a rotation in progress lost the previous value it depends on.

`WP_Secrets_Libsodium_Provider::set()` now treats an unchanged write as a no-op: nothing is stored and `wp_secret_changed` does not fire. The exception is a write that raises `needs_rotation`, such as `wp_import_option_as_secret()` on an option holding the current value. That write is recorded and keeps the previous version.

`WP_Secrets_Provider::set()` now documents that an unchanged write must not discard the previous version, and `WP_Secrets_Provider_Conformance` tests it, so the rule applies to third-party providers too.

Follow-up to [r64337].

Props ravipatel, ericmann, whyisjake.
Fixes #66353. See #66187.


git-svn-id: https://develop.svn.wordpress.org/trunk@64674 602fd350-edb4-49c9-b593-d223f7449a82
Replaces `isset()` and `array_key_exists()` ternaries that return the tested value or a fallback of `null` or `''` with the null coalescing operator (`??`), and self-referencing `$x = $x ?? $y` assignments with the null coalescing assignment operator (`??=`).

**Why this is safe**

- `??` and `isset()` test the same condition, so the fallback is used in exactly the same cases.
- `array_key_exists()` and `??` only differ for a key that exists with a `null` value. Every converted `array_key_exists()` site falls back to `null`, so both forms return `null` in that case as well.
- `??=` requires PHP 7.4, which is already the minimum supported version.
- No behavior change; this is test-only code.

Developed in WordPress#14616.

Follow-up to r63609, r63633.

Props Soean, huzaifaalmesbah.
See #65819.

git-svn-id: https://develop.svn.wordpress.org/trunk@64675 602fd350-edb4-49c9-b593-d223f7449a82
This commit generates per-block custom, "Additional CSS" for blocks that a parent block parses and renders itself, such as the links in a navigation menu.

Previously, the frontend did not render generate CSS for these blocks, the major case being Navigation Link blocks.

Developed in: WordPress#14538

Props mikachan, mrleemon, scruffian.

Fixes #66345.



git-svn-id: https://develop.svn.wordpress.org/trunk@64676 602fd350-edb4-49c9-b593-d223f7449a82
Me est ipsa dis strictus possim non fusius et eaque vel ottomanicum te quarta, fridericus il mus labore et rutrum veritatis iniuratum est veritatis luminare in eros iste. Ex 7.2 ea nemo opponat ac iaculantur iniuriis lacus claram lius uantum id quo polona odio subiectum quo omnis te li. Eos quo quam nemo fastus partem quo egestas v iudico ille, lius sint ruinae, ea rem nam iustitiam nemo d nobilitas solatium est rerum inscio civilatcm recentem. Et'y me pede ac me filiis ad quo quis. Ab'me eget renovo pressa odit noviciam iste gaudere, indigne, rem merentur ullo alias eum dicit me eum cum unde y poenam ut sed porta eum rem il conserrare contumeliis. Ea v netus urgebat mi quo quam est per dignus ut, tot'y cum odit mus ruinae nunc est indicant te y arcui sed amet mandata sint nec dignus unde custodiae assum et vero fretjuentia eius quos nulla quod, nobile usus y illo statum florem.per wisi eros modestius sed AssuMenda ille falcitenentem non li scripto et est iure dictabat unde ab m essentiam vero. Eget'w ti.

Props onemaggie, juanfra, poena, iamarinoh, shailu25, areziaal, josephscott, ddewan, noruzzaman, williampatton, jeffpaul, kafleg, maneshtimilsina, sakshamsharma5, soean, moonjellydigital, sheulyshila, yashjawale, maxinacube, mukesh27, nilambar, huzaifaalmesbah, mukeshpanchal27, westonruter.
See #66352.



git-svn-id: https://develop.svn.wordpress.org/trunk@64677 602fd350-edb4-49c9-b593-d223f7449a82
This changeset adds missing fonts and images to Ipsum.

Follow-up to [64677].

Props westonruter.
See #66352.



git-svn-id: https://develop.svn.wordpress.org/trunk@64678 602fd350-edb4-49c9-b593-d223f7449a82
Follow-up to [64677], [64678].

Props ravipatel.
See #66352.



git-svn-id: https://develop.svn.wordpress.org/trunk@64679 602fd350-edb4-49c9-b593-d223f7449a82
…y` with an `author` object.

The `core/content-query` ability filtered posts by author through a `where.author_slug` string, while each post returns its author as an `author` object with `id`, `name`, and `slug`. The REST API posts collection filters by author ID, which the ability did not take.
Replace the filter with a `where.author` object that takes the `id` or the `slug` the `author` field returns, so a result's author can be given back as a filter.

Developed in WordPress#14673.

Follow-up to [64388].

Props jorgefilipecosta, gziolo.
See #66268.

git-svn-id: https://develop.svn.wordpress.org/trunk@64680 602fd350-edb4-49c9-b593-d223f7449a82
This ensures that `dynamic_sidebar()` displays the correct sidebar when it has the same ID as the sanitized name of another sidebar registered earlier.

An exact sidebar ID match is now prioritized over a sanitized name match, which may be less accurate.

Developed in WordPress#12166.

Follow-up to r5474.

Props sainathpoojary, wildworks, alexvorn2, markoheijnen, dilip2615, mosescursor, im3dabasia1, SergeyBiryukov.
Fixes #22116.

git-svn-id: https://develop.svn.wordpress.org/trunk@64681 602fd350-edb4-49c9-b593-d223f7449a82
Since a non-scalar key was made to yield an empty string in r52292 and non-string scalars were again coerced to a string in r52370, `sanitize_key()` handles values of any type, and its tests cover this. Most of its callers pass raw request data or REST parameters, which are untyped, so documenting `$key` as a `string` caused PHPStan to report an error at nearly every call site.

The `sanitize_key` filter is updated to match, as it receives the original key, and its sanitized key is now typed as a lowercase string so that the result of `apply_filters()` agrees with the function's return type. The cast to `string` before `strtolower()` makes the existing coercion explicit without changing behavior. Tests are added for additional non-string types and for the arguments passed to the filter.

This resolves 50 PHPStan errors at rule level 10.

Developed in WordPress#14759.
Follow-up to r13718, r52292, r52370.

See #54160, #65817.


git-svn-id: https://develop.svn.wordpress.org/trunk@64682 602fd350-edb4-49c9-b593-d223f7449a82
Adds the `label` as a supported element within the `theme.json` schema to allow theme developers/editors to modify the styles as required.

Developed in WordPress#13105.
Merges PHP component of WordPress/gutenberg#81160 to WordPress-Develop.

Fixes #65899.
Props sarthaknagoshe2002, wildworks, onemaggie, im3dabasia1.



git-svn-id: https://develop.svn.wordpress.org/trunk@64683 602fd350-edb4-49c9-b593-d223f7449a82
Restoring a top-level note from the Trash now also restores the child notes that were trashed along with it. Child notes the user trashed individually before trashing the parent stay in the Trash.

Developed in: WordPress#14044

Props wildworks, mukesh27, peterwilsoncc.
Fixes #66255.

git-svn-id: https://develop.svn.wordpress.org/trunk@64684 602fd350-edb4-49c9-b593-d223f7449a82
Clarify required capabilities and input-dependent permission checks,
schema handling, callbacks, and execution hooks. Correct registration
examples and naming constraints, and document discovery filtering
and preservation of ability keys.

Developed in WordPress#14550.

Props gziolo, jorgefilipecosta.
See #66325, #65569.




git-svn-id: https://develop.svn.wordpress.org/trunk@64685 602fd350-edb4-49c9-b593-d223f7449a82
`_wp_preload_entity_actions()` and `_wp_preload_entity_fields()` assumed
`$paths` was an array, so the editor crashed when an earlier
`block_editor_rest_api_preload_paths` callback returned `null`, `false`,
a string or an object. Empty values are now turned into an array so the
entity paths are still added. Other non-array values, and contexts that
are not a `WP_Block_Editor_Context`, are returned unchanged. `$context`
now defaults to `null`, so calling either function with one argument no
longer throws an `ArgumentCountError`.

Numeric script module ids are now handled as strings. PHP turned them into
integer array keys, so `wp_get_registered_entity_field_modules()` and
`wp_get_registered_entity_action_modules()` could miss them in a strict
comparison and `array_merge()` could renumber them. Both functions now
return a list of entries holding the module id and the ids of the fields
or actions it applies to. This is the shape the REST controllers already
returned, and they now use these results directly. The entity fields
endpoint now returns module ids as strings, matching its schema.

A field registered with the id `'0'` is no longer rejected as empty.

The code duplicated between the two APIs now lives in a new
`entity-utils.php` file:
- `_wp_add_entity_preload_paths()` builds the preload paths for both
  preload callbacks.
- `_wp_add_entity_modules_to_editor_script()` adds the script modules to
  the editor script for both `admin_footer` callbacks. It takes a callable
  rather than the modules, so the registries are still only read on pages
  that load the editor script.

Developed in WordPress#14716.

Props oandregal, jorgefilipecosta.
See #66229, #66343.


git-svn-id: https://develop.svn.wordpress.org/trunk@64686 602fd350-edb4-49c9-b593-d223f7449a82
Require `view_site_health_checks` for `core/get-environment-info`
instead of `manage_options`. Add regression tests.

Props gziolo, jorgefilipecosta, jonsurrell.
Fixes #66369.



git-svn-id: https://develop.svn.wordpress.org/trunk@64687 602fd350-edb4-49c9-b593-d223f7449a82
… users who may see them.

The `core/content-query` ability returned the author's display name and slug for every post the current user can read, and its `author` slug filter named any user of the site.
Return them only to users who may see the author: the author themselves, users who can edit them or list users, and otherwise users who can read a published post of theirs in a post type exposed to abilities, where the ability already returns the author.

Follow-up to [64388], [64680].

Props jorgefilipecosta, gziolo.
See #66268.

git-svn-id: https://develop.svn.wordpress.org/trunk@64688 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.