Skip to content

Editor: update npm packages in trunk for 6.7.1. - #1

Open
hemnfor22 wants to merge 3885 commits into
hemnfor22:trunkfrom
WordPress:trunk
Open

hemnfor22 wants to merge 3885 commits into
hemnfor22:trunkfrom
WordPress:trunk

Conversation

@hemnfor22

Copy link
Copy Markdown
Owner

Syncs Editor packages for WordPress 6.7.1 RC1. Includes the following PRs:

Reviewed by desrosj.
Merges [59437] to trunk.

Props mmaattiiaass, ramonopoly, mamaduka, get_dave, poena, ntsekouras, mcsf, jsnajdr, 0mirka00, desrosj, joemcgill, cbravobernal, azaozz, room34, mayanktripathi32, im3dabasia1, jonsurrell. Fixes #62478, #62447.

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

If you need code to programmatically create categories and associate them with posts in WordPress, you can use the following snippets. These will help you add categories within your WordPress post editor or even through custom functions.

1. Add a Category Programmatically

You can add a category using the wp_insert_term() function. Here’s an example of how to create a category from your theme's functions.php file or a custom plugin:

function create_custom_category() {
    $category_name = 'My Custom Category'; // Change the category name
    $category_slug = 'my-custom-category'; // Change the slug if needed
    
    // Check if category already exists
    if (!term_exists($category_name, 'category')) {
        wp_insert_term(
            $category_name, // Category name
            'category',     // Taxonomy (must be 'category' for posts)
            array(
                'slug' => $category_slug // Optional: Define a custom slug
            )
        );
    }
}
add_action('init', 'create_custom_category');

2. Assign Category to a Post Programmatically

If you want to assign this newly created category to a specific post programmatically, you can use the following code:

function assign_category_to_post($post_id) {
    $category_name = 'My Custom Category'; // Use your category name
    
    // Get the category ID
    $category = get_term_by('name', $category_name, 'category');
    if ($category) {
        // Assign category to post
        wp_set_post_categories($post_id, array($category->term_id));
    }
}
add_action('save_post', 'assign_category_to_post');

In this case, whenever a post is saved, it will automatically get the category "My Custom Category" assigned to it.

Make sure to replace 'My Custom Category' with the name of the category you want to assign to the posts.

3. Create a Custom Category for Each Post Automatically

If you'd like a new category to be created automatically whenever a post is published (for example, based on the post title or a custom field), you can customize the following:

function auto_create_category_for_post($post_id) {
    // Avoid infinite loop or unnecessary calls
    if (wp_is_post_revision($post_id)) return;

    // Get the post title and create a category with it
    $post = get_post($post_id);
    $category_name = sanitize_title_with_dashes($post->post_title);

    // Check if the category exists, if not create it
    if (!term_exists($category_name, 'category')) {
        wp_insert_term(
            $category_name, 
            'category',
            array(
                'slug' => sanitize_title($category_name)
            )
        );
    }

    // Assign the category to the post
    $category = get_term_by('name', $category_name, 'category');
    wp_set_post_categories($post_id, array($category->term_id));
}
add_action('publish_post', 'auto_create_category_for_post');

4. Display Category Dropdown in Post Editor (If Not Visible)

If you want to display a category dropdown programmatically when it's not visible in the post editor, use this code snippet:

function enable_categories_in_post_editor() {
    add_meta_box(
        'categorydiv', 
        __('Categories'), 
        'post_categories_meta_box', 
        'post', 
        'side', 
        'core'
    );
}
add_action('add_meta_boxes', 'enable_categories_in_post_editor');

Where to Place the Code:

  • functions.php File: If you're using a custom theme, you can place the code in your theme's functions.php file.
  • Custom Plugin: If you prefer to use a custom plugin, create a simple plugin and add the code inside it.

By using these snippets, you can automate category creation and assignment, or ensure that categories appear in your WordPress editor even if they don't by default.

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


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.

Repository owner locked and limited conversation to collaborators Nov 20, 2024
@pento
pento force-pushed the trunk branch 2 times, most recently from 3af2d27 to 64ede28 Compare July 6, 2026 03:10
lancewillett and others added 25 commits October 17, 2026 19:07
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: #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: #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: #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: #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: #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: #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: #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: #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: #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: #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: #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: #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: #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 #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: #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: #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: #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: #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: #14369

Props shailu25, mukesh27.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64463 602fd350-edb4-49c9-b593-d223f7449a82
Check capability and registration decisions for core submenus, plugin pages, hidden pages, and parent-menu fallbacks. Restore menu and request globals between cases.

Developed in: #14372

Props huzaifaalmesbah, mukesh27.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64464 602fd350-edb4-49c9-b593-d223f7449a82
Checks the default category list and custom separator, parent, and post-ID output.

Developed in: #14373

Props shailu25, mukesh27.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64465 602fd350-edb4-49c9-b593-d223f7449a82
Covers the default walker, invalid-walker fallback, and a supplied custom walker.

Developed in: #14374

Props shailu25, mukesh27.
See #65819.


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

Developed in: #14375

Props rejaulalomkhan, mukesh27.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64467 602fd350-edb4-49c9-b593-d223f7449a82
Covers the default dropdown walker, invalid-walker fallback, and a supplied custom walker.

Developed in: #14376

Props shailu25, mukesh27.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64468 602fd350-edb4-49c9-b593-d223f7449a82
Verify editor modes across MIME types and filenames, lint settings, HTMLHint permissions, argument overrides, and the `wp_code_editor_settings` filter.

Developed in: #14377

Props huzaifaalmesbah, mukesh27.
See #65819.


git-svn-id: https://develop.svn.wordpress.org/trunk@64469 602fd350-edb4-49c9-b593-d223f7449a82
lancewillett and others added 30 commits October 20, 2026 21:59
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: #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: #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: #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: #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 #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 #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 #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 #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: #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 #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 #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 #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 #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: #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 #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 #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
Add a `data_processing` option to REST routes and route handlers, so a route can serve its response data as returned. The option is `false` to turn off every feature, or an array with any of the `fields`, `embed` and `links` keys. Every feature is on by default, the handler setting applies over the route setting feature by feature, and turning off `links` also turns off `embed`.
The settings are resolved once, when the request is matched, and stored on the request attributes, the matched handler and the response, where `rest_filter_response_fields()`, `WP_REST_Controller::get_fields_for_response()` and `WP_REST_Server::response_to_data()` read them. They apply to served, enveloped, batched and preloaded requests, and to responses returned by the `rest_pre_dispatch` filter. The index lists the settings of endpoints that turn a feature off.
Response data that is not an array is now served as returned even without the option: `_fields` leaves scalars and objects alone and keeps list items that are not arrays, links are not added to them unless the object implements `ArrayAccess`, and `rest_preload_api_request()` no longer casts preloaded data to an array.
This lets endpoints that own their output schema, such as the abilities run endpoint, return objects, lists and scalar values unchanged.

Props jorgefilipecosta, gziolo.
See #66267.
Fixes #66372.

git-svn-id: https://develop.svn.wordpress.org/trunk@64689 602fd350-edb4-49c9-b593-d223f7449a82
This replaces `foreach` loops that return early on the first matching or failing element with `array_any()` and `array_all()`, with no change in behavior. These loops were all added in later features, so they were missed by the conversions in r62550 and r62553.

Developed in #14618.
Follow-up to r59783, r62550, r62553, r62564, r63453, r64337, r64351, r64388, r64402, r64500, r64588.

Props soean.
See #65818.


git-svn-id: https://develop.svn.wordpress.org/trunk@64690 602fd350-edb4-49c9-b593-d223f7449a82
The admin menu's accordion animation sometimes degraded to a plain cross-fade, because a cross-document view transition snapshots the incoming page at its first render, which can happen before the admin menu has finished parsing. A render-blocking `expect` link now holds the first render until `#wpcontent`, the element right after the admin menu, is parsed, so the snapshot always has the complete menu without waiting for the rest of the page. The link is only printed once the View Transitions style has been printed, since an `expect` target that never appears blocks rendering until the whole document is parsed.

The animation itself is also refined. Each menu item's snapshot is clipped to its animating box, so a submenu wipes open or closed in step with the items around it instead of overlapping them. The Collapse Menu button moves with the menu instead of cross-fading. An open flyout fades out while moving with its menu item, instead of being cut off by that clip.

The style is now enqueued from `wp-admin/admin-header.php` instead of on the `admin_enqueue_scripts` action, which `iframe_header()` also fires, so screens without the admin menu no longer load it. As a result, unhooking `wp_enqueue_view_transitions_admin_css()` no longer turns off admin View Transitions. Dequeuing the `wp-view-transitions-admin` style does, and it works in 7.0 as well.

Developed in #11912.
Follow-up to r61491.

Props westonruter, b1ink0, zieladam, mukesh27, dhrupo, audrasjb, joedolson, huzaifaalmesbah, jasonsa19, ozgursar, nikunj8866, darshitrajyaguru97.
See #64470.
Fixes #65032.


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

This aims to bring consistency with the other tests, so that the test could run with `--group option`.

Follow-up to r57920.

Props welcher.
Fixes #66366.

git-svn-id: https://develop.svn.wordpress.org/trunk@64692 602fd350-edb4-49c9-b593-d223f7449a82
WordPress themes can support both `editor-styles` (plural) for the block editor and `editor-style` (singular) for the TinyMCE/classic editors.

This improves the documentation of the `add_editor_style()` and `remove_editor_styles()` functions to use `add_theme_support( 'editor-styles' )` and `remove_theme_support( 'editor-styles' )` to add stylesheets to the block editor.

The tests for theme support are expanded to ensure that the subtle distinction is retained.

Props azaozz, chaion07, desrosj, hellofromtonya, khoipro, oglekler, sabernhardt, sergeybiryukov, soean, sukhendu2002.
Fixes #60826.




git-svn-id: https://develop.svn.wordpress.org/trunk@64693 602fd350-edb4-49c9-b593-d223f7449a82
…g a plugin or theme.

After a plugin or theme is installed from an uploaded ZIP file in `wp-admin/update.php`, the upload is cleaned up when `$result || is_wp_error( $result )`. A `WP_Error` is an object and therefore always truthy, so the first operand already covers it and the `is_wp_error()` call can never return `true`. PHPStan reports this as `function.impossibleType`.

The condition is reduced to `if ( $result )`, which behaves identically: a failed installation still cleans up the upload, and only `false`, which `WP_Upgrader::run()` returns when filesystem credentials are requested, keeps the upload so it is still there once the credentials are entered.

This empties the `function.impossibleType` baseline, so the file and its entry in `phpstan.neon.dist` are removed.

Developed in #14778.

Props Soean.
See #65817.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.