Skip to content

Abilities: Sync core/settings-get with WordPress core - #1206

Merged
gziolo merged 4 commits into
developfrom
update/sync-settings-get-with-core
Oct 26, 2026
Merged

gziolo merged 4 commits into
developfrom
update/sync-settings-get-with-core

Conversation

@gziolo

@gziolo gziolo commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

What?

Follow-up to #691. Syncs the plugin's core/settings-get ability 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:

  • Settings now use their REST API names in both the fields input and response keys. For example, blogname is now title, admin_email is now email, and timezone_string is now timezone. Calls requesting the old field names fail input validation.
  • The deprecated core/read-settings alias is removed. Callers must migrate to core/settings-get and its REST API field names. The alias only forwarded calls and could not preserve the old input/output contract after this sync.
  • Values that fail their schema, or settings that were never saved and have no registered default, are omitted. Consumers must tolerate missing properties.

How?

Settings now follows WP_Abilities_Settings from core:

  • A setting with show_in_abilities => true reuses the name and schema from show_in_rest. An array value is used instead of show_in_rest.
  • Each value is validated against its schema, before and after sanitizing. A bad value is left out, so it no longer fails the whole call.
  • A setting that was never saved returns its registered default, or is left out when it has none.
  • Settings with a type that the REST settings endpoint does not support are skipped. Two settings with the same exposed name trigger _doing_it_wrong().
  • Object schemas reject properties they do not declare.
  • The input accepts objects and a comma-separated fields string. fields must have unique items.
  • The ability is not registered when no setting is exposed.
  • The label is now "Get Settings", and the descriptions match core.

Plugin-only parts stay and are marked with // Plugin: comments: overriding the core copy and show_in_rest meta. The alias forwarding tests are removed.

Show_In_Abilities now marks every curated setting with true, so it reuses the REST schema. It also adds wp_page_for_privacy_policy, which core registers since WordPress 7.2.

Not ported: the new siteurl description in core's register_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

  1. Run the PHP tests:
    npm run test:php -- --filter 'SettingsTest|Show_In_AbilitiesTest'
    
  2. Reactivate the plugin (the PHP tests deactivate it), then run the e2e spec:
    npm run test:e2e -- tests/e2e/specs/abilities/core-settings-get.spec.js
    
  3. Enable the Custom Abilities experiment and run core/settings-get as an admin. The result uses REST API names, such as title and email.

Validation

On WordPress 7.1.3:

  • After alias removal: 49 focused PHP tests passed, 106 assertions, zero skips.
  • Before alias removal: all 5 settings browser tests passed.
  • git diff --check passed.

Changelog Entry

Changed - The core/settings-get ability now matches WordPress core. Settings use their REST API names (for example, title instead of blogname), and a value that does not match its schema is left out.

Removed - The deprecated core/read-settings ability alias. Use core/settings-get with REST API field names (for example, title instead of blogname). The alias could not keep the old field names or response shape after the sync with WordPress core.

🤖 Generated with Claude Code

Open WordPress Playground Preview

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`.
@gziolo
gziolo requested a review from a team October 19, 2026 09:18
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@gziolo gziolo self-assigned this Oct 19, 2026
@gziolo gziolo added this to the 1.5.0 milestone Oct 19, 2026
@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.22%. Comparing base (a0b5dd5) to head (8809c6f).

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     
Flag Coverage Δ
unit 84.22% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@gziolo gziolo changed the title Abilities: Sync core/settings-get with WordPress core Abilities: Sync core/settings-get with WordPress core Oct 19, 2026
The changelog is assembled at release time, so the entry belongs in the
PR description instead.
@dkotter

dkotter commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

The deprecated core/read-settings alias is removed

I'm personally fine with removing these aliases in all three PRs here, but holding on merging to see if anyone else has concerns

gziolo added a commit that referenced this pull request Oct 26, 2026
## 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 -->
@gziolo
gziolo merged commit 6d53858 into develop Oct 26, 2026
36 of 37 checks passed
@gziolo
gziolo deleted the update/sync-settings-get-with-core branch October 26, 2026 10:38
@github-project-automation github-project-automation Bot moved this from Needs review to Done in WordPress AI Roadmap Oct 26, 2026
@gziolo

gziolo commented Oct 26, 2026 •

Copy link
Copy Markdown
Member Author

I didn't hear any concerns, so I merged PRs. I'm open to changing the approach if any issues are raised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants