Repository navigation
Abilities API: Add the core/term-create, core/term-update and core/term-delete abilities - #16409
jorgefilipecosta wants to merge 2 commits into
Conversation
Adds `core/terms-query`, which lists the terms of a taxonomy exposed to abilities, and the `show_in_abilities` argument of `register_taxonomy()`, `true` for `category` and `post_tag`. See #66743.
…re/term-delete` abilities. Adds the write abilities for the terms of a taxonomy exposed to abilities, next to `core/terms-query`. Create and update return the written term in the shape of a `core/terms-query` item. See #66743.
|
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: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
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. |
Shape from WordPress/abilities#22. Same approach as #16028.
Stacked on #16102, which adds
core/terms-query, theWP_Abilities_Termsclass and theshow_in_abilitiestaxonomy argument. Until it lands, the diff here includes those changes; only the last commit belongs to this PR.This PR adds the
core/term-create,core/term-updateandcore/term-deleteabilities to thecontentcategory, for the taxonomies that setshow_in_abilities:core/term-createtakes{ data, fields }and returns the new term.data.taxonomyanddata.nameare required.core/term-updatetakes{ where: { taxonomy, id }, data, fields }, changes only the attributes indataand returns the term.core/term-deletetakes{ where: { taxonomy, id }, permanent: true }, deletes the term permanently and returns{ outcome }.permanentis required and must be true, since terms have no Trash. A default term is refused.dataacceptsname,slug,descriptionandparent.Creating a category:
{ "id": 5, "taxonomy": "category", "name": "Product updates", "slug": "product-updates", "link": "http://localhost:8950/category/product-updates/" }Changing its slug and description, and asking for some fields:
{ "id": 5, "name": "Product updates", "slug": "updates", "description": "Release notes and roadmap updates." }Deleting it. For the default category the answer is a
term_is_defaulterror:{ "outcome": "deleted" }Trac ticket: https://core.trac.wordpress.org/ticket/66743
Testing
Verify unit tests are passing:
Or run the examples above in the editor console as an administrator.
AI disclosure: the change and tests were drafted with AI assistance (Claude Code).