Repository navigation
Abilities: Sync core/settings-get with WordPress core - #1206
Conversation
Apply the changes that shipped with the `core/settings-get` ability in WordPress core (r64311, Trac #64605): - Settings flagged `show_in_abilities => true` reuse the name and schema from `show_in_rest`, so they use the REST API names. - Values are validated against their schema, and a bad value is left out. - Never saved settings read as the registered default or are left out. - Unsupported types are skipped, and duplicate names trigger a notice. - The ability is not registered when no setting is exposed. - The polyfill marks every curated setting with `true` and adds `wp_page_for_privacy_policy`.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1206 +/- ##
=============================================
+ Coverage 84.18% 84.22% +0.04%
+ Complexity 3516 3500 -16
=============================================
Files 139 139
Lines 13484 13497 +13
=============================================
+ Hits 11351 11368 +17
+ Misses 2133 2129 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
core/settings-get with WordPress core
The changelog is assembled at release time, so the entry belongs in the PR description instead.
I'm personally fine with removing these aliases in all three PRs here, but holding on merging to see if anyone else has concerns |
## What? See [#64657](https://core.trac.wordpress.org/ticket/64657), [r64346](WordPress/wordpress-develop@39981fd). This PR syncs the `core/users-query` ability with the version that landed in WordPress core. The plugin acts as a polyfill until WordPress 7.2 is out. It also removes the deprecated `core/read-users` alias. ## Why? The ability was first built in this plugin (#774) and then moved to WordPress core. During the core review, the input and output shape changed a lot. The plugin should behave the same as core, so code written for the plugin keeps working on WordPress 7.2. The old alias cannot keep the old contract after these changes, so it is removed. This is the same as what #1206 does for `core/read-settings`. ## How? The PR has two commits: 1. **Sync with core.** `includes/Abilities/Users/Users.php` is now a copy of the core class `WP_Abilities_Users`. Each difference from core is marked with a `// Plugin:` comment: the `init()` method, unregistering the copy from core, an explicit `show_in_rest`, and the `ai` text domain. 2. **Remove the alias.** `core/read-users` is no longer registered. These are breaking changes for callers: - **Input:** it is now `{ where, fields, pagination }`. `where` takes `ids`, `slugs`, `usernames`, `roles`, and `has_published_posts`. The old root-level `id`, `email`, `username`, `slug`, `include`, `page`, and `per_page` are removed. Lookup by email is no longer supported. - **Output:** it is always `{ items, pagination: { total, total_pages } }`. A single user is no longer returned as a bare object. - **Order:** results are ordered by username, not by display name. - **Errors:** a filter that cannot be used is rejected, not ignored. A page after the last one returns a 404 error. - **Permissions:** filtering by username needs permission to list users. - **Label:** the label is now "Query Users". Tests: - `UsersTest.php` is ported from the core test `wpRegisterCoreUsersAbility.php`. It also keeps two tests that only the plugin needs. - `Users_RestTest.php` is new. It is ported from the core test `wpRestAbilitiesUsersController.php` and runs the ability through the REST run endpoint. - The e2e spec now uses the new input and output. ### Use of AI Tools AI assistance: Yes Tool(s): Claude Code Model(s): Claude Opus 5.5 Used for: Comparing the core commit with the plugin, porting the code and tests, updating the e2e spec, and running the checks. I reviewed the diff and the test results. ## Testing Instructions 1. Run `npm run test:php -- --filter Users`. 2. Run the multisite tests: `npx wp-env --config=.wp-env.test.json run cli --env-cwd=wp-content/plugins/ai bash -c "WP_MULTISITE=1 vendor/bin/phpunit -c phpunit.xml.dist --filter Users"`. 3. Reactivate the plugin with `npx wp-env --config=.wp-env.test.json run cli wp plugin activate ai`. Then run `npx wp-scripts test-playwright --config tests/e2e/playwright.config.ts tests/e2e/specs/abilities/core-users-query.spec.js`. 4. Manual check: enable the Custom Abilities experiment. Then run `core/users-query` with `{ "where": { "roles": [ "administrator" ] }, "fields": [ "id", "name" ] }` and check that the result has `items` and `pagination`. ## Changelog Entry > Changed - The `core/users-query` ability now matches WordPress core. The input is now `where`, `fields`, and `pagination`, and the output is always `items` and `pagination`. Users are looked up through the `ids`, `slugs`, or `usernames` lists in `where`, and lookup by email is no longer supported. Results are ordered by username, a filter that cannot be used is rejected, and a page after the last one returns an error. > > Removed - The deprecated `core/read-users` ability alias. Use `core/users-query` with the new `where`, `fields`, and `pagination` input. The alias could not keep the old input and response shape after the sync with WordPress core. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- wp-playground-preview:start --> <a href="https://playground.wordpress.net?blueprint-url=data:application/json,%7B%22preferredVersions%22%3A%7B%22wp%22%3A%22latest%22%7D%2C%22login%22%3Atrue%2C%22landingPage%22%3A%22%2Fwp-admin%2Fadmin.php%3Fpage%3Dai-wp-admin%22%2C%22steps%22%3A%5B%7B%22step%22%3A%22installPlugin%22%2C%22pluginData%22%3A%7B%22resource%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2FWordPress%2Fai%2Freleases%2Fdownload%2Fci-artifacts%2Fpr-1207-d5ad0beff70da1174077f53075849859a61036e5.zip%22%7D%7D%5D%7D" target="_blank" rel="noopener noreferrer"> <img src="https://raw.githubusercontent.com/adamziel/playground-preview/refs/heads/trunk/assets/playground-preview-button.svg" alt="Open WordPress Playground Preview" width="220" height="57" /> </a> <!-- wp-playground-preview:end -->
|
I didn't hear any concerns, so I merged PRs. I'm open to changing the approach if any issues are raised. |
What?
Follow-up to #691. Syncs the plugin's
core/settings-getability with the version that shipped in WordPress core in r64311 (Trac #64605).Why?
The core version got more changes during review. The plugin should behave the same way, so the two stay in sync.
Breaking changes:
fieldsinput and response keys. For example,blognameis nowtitle,admin_emailis nowemail, andtimezone_stringis nowtimezone. Calls requesting the old field names fail input validation.core/read-settingsalias is removed. Callers must migrate tocore/settings-getand its REST API field names. The alias only forwarded calls and could not preserve the old input/output contract after this sync.How?
Settingsnow followsWP_Abilities_Settingsfrom core:show_in_abilities => truereuses thenameandschemafromshow_in_rest. An array value is used instead ofshow_in_rest._doing_it_wrong().fieldsstring.fieldsmust have unique items.Plugin-only parts stay and are marked with
// Plugin:comments: overriding the core copy andshow_in_restmeta. The alias forwarding tests are removed.Show_In_Abilitiesnow marks every curated setting withtrue, so it reuses the REST schema. It also addswp_page_for_privacy_policy, which core registers since WordPress 7.2.Not ported: the new
siteurldescription in core'sregister_initial_settings(). Changing it from the plugin would also change the REST API.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code, Codex
Model(s): Claude Opus 5.5, GPT-6
Used for: Comparing the core commit with the plugin, porting the code and tests, and running the checks. I reviewed the diff and the test results. Codex also validated the core sync, removed the deprecated alias, updated the tests and changelog, and ran the focused PHP tests.
Testing Instructions
core/settings-getas an admin. The result uses REST API names, such astitleandemail.Validation
On WordPress 7.1.3:
git diff --checkpassed.Changelog Entry
🤖 Generated with Claude Code