Skip to content

Abilities API: Use the public meta flag for core abilities#12517

Closed
gziolo wants to merge 3 commits into
WordPress:trunkfrom
gziolo:add/65568-core-abilities-public
Closed

Abilities API: Use the public meta flag for core abilities#12517
gziolo wants to merge 3 commits into
WordPress:trunkfrom
gziolo:add/65568-core-abilities-public

Conversation

@gziolo

@gziolo gziolo commented Jul 14, 2026

Copy link
Copy Markdown
Member

Follow-up to #12463, which introduced the public flag in ability metadata as a single high-level control over client exposure.

This change adopts that flag for the core abilities shipped with WordPress. The three core abilities now declare meta.public instead of meta.show_in_rest:

  • core/get-site-info
  • core/get-user-info
  • core/get-environment-info

Why

public seeds show_in_rest through the null-coalescing chain (show_in_rest = meta['show_in_rest'] ?? meta['public'] ?? false), so REST exposure stays exactly the same. Using public also keeps the intent in stored metadata, so other channels (MCP, AI agents) can read it through the wp_register_ability_args filter. An explicit show_in_rest: false would still win if a channel ever needs to opt out.

Testing

npm run test:php -- --group abilities-api --filter 'wpRegisterCoreAbilities'

Each ..._ability_is_registered test now asserts that public is true and keeps the show_in_rest assertion to confirm the flag still enables REST exposure.

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


🤖 Generated with Claude Code

Switch the three core abilities (`core/get-site-info`, `core/get-user-info`,
and `core/get-environment-info`) from `meta.show_in_rest` to the higher-level
`meta.public` flag.

The `public` flag seeds `show_in_rest`, so REST exposure stays the same. Other
channels (MCP, AI agents) can now read the intent through the
`wp_register_ability_args` filter.

Follow-up to PR WordPress#12463.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gziolo gziolo self-assigned this Jul 14, 2026
@github-actions

github-actions Bot commented Jul 14, 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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props gziolo, mukesh27.

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

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates WordPress core Abilities API registrations to use the new high-level meta.public flag (introduced in #12463) as the source of truth for client exposure, while preserving REST exposure via the existing show_in_rest null-coalescing default.

Changes:

  • Switch core abilities from meta.show_in_rest => true to meta.public => true in core registration.
  • Update PHPUnit assertions to verify meta.public is set for the three core abilities while still confirming show_in_rest resolves to true.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/wp-includes/abilities.php Sets meta.public for the three core abilities, relying on core defaulting to derive meta.show_in_rest.
tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php Adds assertions that public is true while keeping show_in_rest assertions to confirm REST exposure remains enabled.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Make the `public` meta flag default to false so it is always present in the
resolved meta, and authors opt in explicitly. A null value is treated as unset.

Reword the flag documentation across the class, registry, REST schema, and
`wp_register_ability()`. Describe it as "available to clients such as the REST
API, MCP, or AI agents", note the false default, and mention that per-channel
settings such as `show_in_rest` can override it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gziolo

gziolo commented Jul 14, 2026

Copy link
Copy Markdown
Member Author

@mukeshpanchal27, appreciate your review. I applied some follow-up changes to improve the documentation via c832138. I plan another pass after reviewing PHPDoc in other places that document the example usage of the Abilities API to promote the revised approach.

…` docs.

Update the examples and guidance in the Abilities API documentation to use the
high-level `public` flag instead of `show_in_rest`. Rename the "REST API
Integration" section to "Client Exposure", explain that `public` seeds the
per-channel defaults, and show how to override a single channel such as
`show_in_rest`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 62737
GitHub commit: 5f14502

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Jul 14, 2026
@gziolo gziolo deleted the add/65568-core-abilities-public branch July 14, 2026 15:56
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.

3 participants