feat: add AbstractAbility and AbstractAbilityRegistrar - #76
Open
Adi-ty wants to merge 2 commits into
Open
Conversation
Telemetry-agnostic base classes for the WordPress Abilities API (6.9+), lifted from the shape proven in rtcamp/wp-dev-tools (rtCamp/wp-devtools#12, item 1). AbstractAbility declares the pieces of an ability and maps them to wp_register_ability() args; AbstractAbilityRegistrar (a Registrable) hooks wp_abilities_api_categories_init / wp_abilities_api_init, registers the shared category idempotently, and loops its abilities. Both callbacks are wrapped in defaulted closures because core invokes them with zero arguments when no input schema is declared. category_description() is abstract: core rejects categories without a non-empty description. On cores older than 6.9 the hooks never fire, so the registrar is inert and the package's WordPress floor is unchanged.
Abstracts cookbook gains an Abilities section (must-implement list, override seams, shared-category consumer example, the WP <6.9 inertness note); README and docs index updated. The AI-instruction ability lists now name the ability abstracts and wp_register_ability, and pick up AbstractFeature, which was missing from both since it landed.
There was a problem hiding this comment.
Pull request overview
Adds WordPress Abilities API abstractions, registration support, tests, and consumer guidance.
Changes:
- Introduces
AbstractAbilityandAbstractAbilityRegistrar. - Adds unit and integration coverage for mapping, permissions, registration, and execution.
- Updates framework documentation and AI instructions.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
inc/Contracts/Abstracts/AbstractAbility.php |
Defines the ability contract and registration arguments. |
inc/Contracts/Abstracts/AbstractAbilityRegistrar.php |
Registers categories and abilities on API hooks. |
tests/Contracts/Abstracts/AbstractAbilityTest.php |
Tests argument mapping and permissions. |
tests/Contracts/Abstracts/AbstractAbilityRegistrarTest.php |
Tests registration and execution round-trips. |
README.md |
Lists the new abstracts. |
docs/index.md |
Updates abstract counts and navigation. |
docs/abstracts.md |
Adds the Abilities API cookbook. |
ai/framework-php.instructions.md |
Adds consumer review guidance. |
.github/instructions/php.instructions.md |
Updates the framework abstract inventory. |
AGENTS.md |
Documents WordPress-version compatibility. |
Comment on lines
+94
to
+96
| * @return array<string, mixed>|\WP_Error Result data, or an error. | ||
| */ | ||
| abstract public function execute( mixed $input ): array|\WP_Error; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Add AbstractAbility and AbstractAbilityRegistrar — telemetry-agnostic base classes for the WordPress 6.9+ Abilities API. The telemetry-shaped AbstractAbility from wp-dev-tools is decomposed: registration timing and category ownership live on the registrar, the ability stays a plain describable object. Both are hook-guarded, so the package's 6.5 floor is unchanged.
Closes
Part of rtcamp/wp-devtools#12
Changes
How I verified
Acceptance criteria
Runtime behavior
AbstractAbilityandAbstractAbilityRegistrarexist inwp-frameworkwith unit tests; a trivial ability can be defined and registers onwp_abilities_api_init.Code quality
Reviewer notes