Skip to content

Abilities API: Improve inline documentation - #14550

Closed
gziolo wants to merge 4 commits into
WordPress:trunkfrom
gziolo:docs/abilities-api-docblocks
Closed

gziolo wants to merge 4 commits into
WordPress:trunkfrom
gziolo:docs/abilities-api-docblocks

Conversation

@gziolo

@gziolo gziolo commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

This PR updates the Abilities API docblocks so they match how the code works. It changes documentation only. The code is not changed.

What changed

  • Permissions. Explains how required_capabilities and permission_callback work together. List the capabilities needed for every execution in required_capabilities. Check anything that depends on the input in permission_callback. The examples now follow this rule.
  • Examples. Removes required from the input and output schemas, because it has no effect there. Adds a note that a custom category must be registered before an ability can use it. The wp_get_abilities() sorting example now keeps the array keys.
  • Schemas and callbacks. Explains when an input schema is required, when the default value is used, and what arguments the callbacks receive. Notes that exceptions thrown by callbacks are converted to WP_Error.
  • Execution lifecycle. Adds a short list of the hooks that WP_Ability::execute() runs, in order.
  • wp_get_abilities(). Clarifies which abilities reach the wp_get_abilities_item_include filter, how meta matching works, and what has_required_capabilities does and does not check.
  • Naming. Ability names need exactly one slash. Category slugs cannot start or end with a dash.

Trac ticket: https://core.trac.wordpress.org/ticket/66325, https://core.trac.wordpress.org/ticket/65569

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code, OpenAI Codex
Model(s): Claude Opus 5.5, GPT-6
Used for: Checking docblocks against the implementation, reviewing the PR, refining documentation, and running validation checks. I reviewed all changes.


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.

🤖 Generated with Claude Code

Updates the Abilities API docblocks so they match how the code works:
- Explain how `required_capabilities` and `permission_callback` work together. Required capabilities apply to every execution. The permission callback checks what depends on the input.
- Fix the examples. Remove `required` from schemas, register categories before use, and use input in the permission callback.
- Describe the execution lifecycle and the order of its hooks.
- Clarify what `wp_get_abilities()` returns, and how its filters and the `meta` matching work.
- Document the naming rules for abilities and category slugs more precisely.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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.

@gziolo gziolo self-assigned this Oct 20, 2026
@gziolo
gziolo requested review from jorgefilipecosta and a balanced review from Copilot October 21, 2026 15:29
@gziolo
gziolo marked this pull request as ready for review October 21, 2026 15:29
@github-actions

github-actions Bot commented Oct 21, 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.

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

Props gziolo, jorgefilipecosta.

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

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.

🟢 Approval recommended

The documentation-only changes match the reviewed implementation, with no unresolved issues.

No open issues 🎉

What changed in this PR

Updates Abilities API inline documentation to reflect existing behavior without changing runtime code.

Changes:

  • Clarifies capability requirements and input-dependent permission checks.
  • Documents schemas, callbacks, execution hooks, and discovery filtering.
  • Corrects examples and naming constraints.
File Description
src/​wp-includes/​abilities-api/​class-wp-ability.php Clarifies required capabilities in class docblocks.
src/​wp-includes/​abilities-api/​class-wp-abilities-registry.php Aligns registration documentation with permission behavior.
src/​wp-includes/​abilities-api.php Expands API guidance and corrects examples and documented contracts.

Review effort: Balanced

@jorgefilipecosta jorgefilipecosta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

wporg-sync pushed a commit that referenced this pull request Oct 23, 2026
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
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 23, 2026
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/wordpress-develop#14550.

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



Built from https://develop.svn.wordpress.org/trunk@64685


git-svn-id: http://core.svn.wordpress.org/trunk@63835 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@gziolo

gziolo commented Oct 23, 2026

Copy link
Copy Markdown
Member Author

Committed with https://core.trac.wordpress.org/changeset/64685.

@gziolo gziolo closed this Oct 23, 2026
@gziolo
gziolo deleted the docs/abilities-api-docblocks branch October 23, 2026 07:26
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