Try 2: Add get and post/pages abilities.#10867
Try 2: Add get and post/pages abilities.#10867jorgefilipecosta wants to merge 8 commits intoWordPress:trunkfrom
Conversation
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
| * @return WP_Ability|null The registered ability instance on success, null on failure. | ||
| */ | ||
| public function register( string $name, array $args ): ?WP_Ability { | ||
| if ( ! preg_match( '/^[a-z0-9-]+\/[a-z0-9-]+$/', $name ) ) { |
There was a problem hiding this comment.
This change is extracted in a different PR, and is a temporary just for testing.
Part of: WordPress/ai#40
Alternative to #10665, trying to implement what was discussed with
@JasonTheAdams and @justlevine.
This PR adds
getabilities for post types via the Abilities API, enabling AI agents to retrieve posts and pages throughcore/post-type/{slug}/get. It Introduce ashow_in_abilitiesoption onregister_post_type()to control which post types expose abilities, enabled by default forpostandpagefor now (if we agree in this approach we will expand to menus, media etc)-Support single-post retrieval by ID and multi-post querying with filters for status, author, search, taxonomy, meta, date, comment status, ping status and more.
I think the biggest decision we need to do is the naming of the ability. I went for
core/post-type/{post-type-slug}/getwhere post-type-slug is the post type identifier (post, page etc). We could discuss other naming possibilities.Test plan
Retrieve a single post by ID with meta and taxonomies (use a valid id):
Query posts filtered by meta key existence:
Nested meta query with AND/OR relations:
Nested taxonomy query with AND/OR relations:
Retrieve most recent pages: