Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
182 commits
Select commit Hold shift + click to select a range
6a235c7
Add core/content-create, core/content-update, and core/content-delete…
jorgefilipecosta Sep 11, 2026
cbbe754
Share the content ability test fixtures in a base test case
jorgefilipecosta Sep 11, 2026
ed7b2d5
Add core/content-create tests
jorgefilipecosta Sep 11, 2026
5aa0c78
Add core/content-update tests
jorgefilipecosta Sep 11, 2026
c1f4ffb
Add core/content-delete tests
jorgefilipecosta Sep 11, 2026
0c87e67
Add an e2e spec for the content write abilities
jorgefilipecosta Sep 11, 2026
c5259ad
Resolve post and author IDs strictly in the content abilities
jorgefilipecosta Sep 11, 2026
201ff09
Describe the content abilities without referring to the REST controller
jorgefilipecosta Sep 11, 2026
d73f4c2
Accept raw objects for the title, content, and excerpt of content writes
jorgefilipecosta Sep 11, 2026
7b97d13
Check the delete capability again before trashing or deleting a post
jorgefilipecosta Sep 11, 2026
616a62b
Cover pages, custom post types, custom taxonomies, and the endpoint f…
jorgefilipecosta Sep 11, 2026
4026cbe
Address the review findings in the content write abilities
jorgefilipecosta Sep 11, 2026
f512316
Clean up every post the content write e2e spec creates
jorgefilipecosta Sep 11, 2026
eef65a0
Share the content ability test fixtures and follow the doc conventions
jorgefilipecosta Sep 11, 2026
9da59d3
Type the ability name of the registration helper as a lowercase slug
jorgefilipecosta Sep 11, 2026
290b85c
Tell the caller why an author, sticky or term request was refused
jorgefilipecosta Sep 28, 2026
a9fe275
Require the publish capability for a custom public status
jorgefilipecosta Sep 28, 2026
3d1b52e
Reject IDs beyond the integer range instead of wrapping them around
jorgefilipecosta Sep 29, 2026
60d2be1
Keep the query author filter on declared author support
jorgefilipecosta Sep 29, 2026
c5e8c01
Make the slug unique when a post is created without a status
jorgefilipecosta Sep 29, 2026
843c196
Read the post again after saving the terms and sticky flag
jorgefilipecosta Sep 29, 2026
a6f4f35
Let the write tests fail when the behavior they cover breaks
jorgefilipecosta Sep 29, 2026
6e3373d
Correct docblocks that contradict the behavior
jorgefilipecosta Sep 29, 2026
3636493
Assign a term ID sent as a scalar instead of clearing the terms
jorgefilipecosta Sep 29, 2026
a3bb7a7
Leave the content query's ID parsing as on develop
jorgefilipecosta Sep 29, 2026
bbd3bcc
Ignore fields the post type does not support
jorgefilipecosta Sep 29, 2026
50e5dcf
Return extras errors unchanged, as the REST API does
jorgefilipecosta Sep 29, 2026
497a36a
Follow the posts controller's delete flow
jorgefilipecosta Sep 29, 2026
0ffc9c4
Build the invalid template message as the posts controller does
jorgefilipecosta Sep 29, 2026
09ae7c9
Find the writable taxonomies as the posts controller does
jorgefilipecosta Sep 29, 2026
0ad495f
Check author and sticky permissions for every post type
jorgefilipecosta Sep 29, 2026
28bb136
Lay out the date handling as the posts controller does
jorgefilipecosta Sep 29, 2026
4d518df
Resolve exposed posts and post types with two helpers
jorgefilipecosta Sep 29, 2026
6196ec1
Register the write abilities in one method
jorgefilipecosta Sep 29, 2026
bcbb64c
List the settable statuses as the posts controller does
jorgefilipecosta Sep 29, 2026
1c1a5ed
Check the featured media where the other objects are validated
jorgefilipecosta Sep 29, 2026
c117f33
Build the taxonomy properties without a separate lookup method
jorgefilipecosta Sep 29, 2026
d9f4abd
Raise the sticky and password errors as the posts controller does
jorgefilipecosta Sep 29, 2026
59a33aa
List the reserved input keys where they are used
jorgefilipecosta Sep 29, 2026
a9a0eb5
Fail a direct create for an unexposed post type as not found
jorgefilipecosta Sep 29, 2026
ccb3892
Build the title, content, and excerpt properties from one definition
jorgefilipecosta Sep 29, 2026
f05366d
Derive the update input schema from the create schema
jorgefilipecosta Sep 29, 2026
d6f4888
Trim the write abilities' comments
jorgefilipecosta Sep 29, 2026
850aeba
Group the write execute callbacks and schemas with the write helpers
jorgefilipecosta Sep 29, 2026
02e6451
Merge the registration and schema tests of each write ability
jorgefilipecosta Sep 29, 2026
7200fdd
Drop plugin-only tests that repeat another ability's test
jorgefilipecosta Sep 29, 2026
9cd2eea
Drop tests that cannot fail on the write abilities
jorgefilipecosta Sep 29, 2026
7e07a71
Trim the content test base class
jorgefilipecosta Sep 29, 2026
2299162
Let the test case restore hooks after plugin-only tests
jorgefilipecosta Sep 29, 2026
9af4c72
Make the sibling slug test fail when the parent is ignored
jorgefilipecosta Sep 29, 2026
9984359
Keep only the lifecycle test in the write abilities e2e spec
jorgefilipecosta Sep 29, 2026
66381ea
Drop taxonomy terms from the write abilities for now
jorgefilipecosta Sep 30, 2026
b9d6cef
Drop the sticky flag and the password from the write abilities for now
jorgefilipecosta Sep 30, 2026
7662d2c
Drop the featured media from the write abilities for now
jorgefilipecosta Sep 30, 2026
cf7d37e
Drop the post format from the write abilities for now
jorgefilipecosta Sep 30, 2026
6680182
Drop the menu order and comment settings from the write abilities for…
jorgefilipecosta Sep 30, 2026
e54cdfb
Drop the template from the write abilities for now
jorgefilipecosta Sep 30, 2026
e0ed4a1
Leave custom public statuses to the checks the posts endpoint makes
jorgefilipecosta Sep 30, 2026
05bae4a
Leave the slug of a post created without a status as the posts endpoi…
jorgefilipecosta Sep 30, 2026
a6c9ca3
Make a draft slug unique against the given parent as the posts endpoi…
jorgefilipecosta Sep 30, 2026
024de32
Read the parent as the posts endpoint does
jorgefilipecosta Sep 30, 2026
c68fe62
Ignore an empty raw title as the posts endpoint does
jorgefilipecosta Sep 30, 2026
cfac143
Report the posts endpoint's error codes
jorgefilipecosta Sep 30, 2026
d6a543f
Name the errors after the endpoint's without the rest_ prefix
jorgefilipecosta Sep 30, 2026
55c0461
Stop enabling the removed AI toggle in the write abilities spec
jorgefilipecosta Sep 30, 2026
5db1049
Test the publish and author checks of the update ability
jorgefilipecosta Sep 30, 2026
91b8108
Test that raw text objects can be PHP objects
jorgefilipecosta Sep 30, 2026
8af3802
Read the force flag the way the posts endpoint does
jorgefilipecosta Sep 30, 2026
ab1bd51
Check the status before the author, as the posts endpoint does
jorgefilipecosta Sep 30, 2026
3aa752d
Decide trash support the way the posts endpoint does
jorgefilipecosta Sep 30, 2026
c7be71b
Return the raw fields of a written post, as the posts endpoint does
jorgefilipecosta Sep 30, 2026
e1be893
Leave the read ability's schemas as develop has them
jorgefilipecosta Sep 30, 2026
2a7457f
Stop saying raw fields need edit access after a write
jorgefilipecosta Sep 30, 2026
15640ec
Stop saying date_gmt is ignored when a date is given
jorgefilipecosta Sep 30, 2026
f951a4a
Stop promising more than the posts endpoint does
jorgefilipecosta Sep 30, 2026
50e100d
Ask for dates with a timezone offset
jorgefilipecosta Sep 30, 2026
c70e95e
Point the docblocks at the checks that run
jorgefilipecosta Sep 30, 2026
f86d987
Assert the statuses the ported create tests dropped
jorgefilipecosta Sep 30, 2026
818b06d
Port the core test for an attachment that cannot be trashed
jorgefilipecosta Sep 30, 2026
03bd931
Send the GMT date back in the ported floating-date tests
jorgefilipecosta Sep 30, 2026
82c2b7d
Port the core tests for empty text and a parent of 0 on update
jorgefilipecosta Sep 30, 2026
8bb55a0
Restore the endpoint's draft, pending, and default status cases
jorgefilipecosta Sep 30, 2026
b073126
Say which null date the empty date test sends
jorgefilipecosta Sep 30, 2026
c09d2bf
Describe the raw fields of a written post as a write returns them
jorgefilipecosta Sep 30, 2026
e63261c
Drop the repeated exposure check from the update callback
jorgefilipecosta Oct 1, 2026
3ae4153
Say in the class docblock that writes answer in the edit context
jorgefilipecosta Oct 1, 2026
799c3f2
Say only the content keeps its value in the e2e update step
jorgefilipecosta Oct 1, 2026
7c7abca
Track the e2e posts by ID and record each as soon as it exists
jorgefilipecosta Oct 1, 2026
bb06fa0
Take the query's field names as plain strings in the write abilities
jorgefilipecosta Oct 5, 2026
bea21fb
Reject write input that cannot be applied
jorgefilipecosta Oct 5, 2026
ff5840a
Return written posts under the query's edit-access rules
jorgefilipecosta Oct 5, 2026
0571c26
Return the deleted post itself from a forced deletion
jorgefilipecosta Oct 5, 2026
f2fb5a3
Decide field support by post_type_supports() again
jorgefilipecosta Oct 5, 2026
a058d94
Share the ID lookup, post type check, and schemas with the query
jorgefilipecosta Oct 5, 2026
6a408b1
Name the write helpers after content instead of REST
jorgefilipecosta Oct 5, 2026
41c555c
Report every field that cannot be applied as content_invalid_field
jorgefilipecosta Oct 5, 2026
ee5d6e5
Describe the write GMT date as core/content-query returns it
jorgefilipecosta Oct 5, 2026
5e8fcf8
Check post type exposure in one place when reading content
jorgefilipecosta Oct 5, 2026
3f43de9
Drop post_type_cap() from the content abilities
jorgefilipecosta Oct 6, 2026
1c8f632
Stop popping the faked filter context in the content tests
jorgefilipecosta Oct 6, 2026
4bb574b
Return an empty rendered title when a title filter returns a non-string
jorgefilipecosta Oct 6, 2026
615753a
Drop the unreachable missing post type branch from the update
jorgefilipecosta Oct 6, 2026
879044b
Slash the prepared post inline
jorgefilipecosta Oct 6, 2026
a095ef0
Fold the write field support map into the check that uses it
jorgefilipecosta Oct 6, 2026
217f370
Share the e2e runAbility() helper
jorgefilipecosta Oct 6, 2026
57a31b1
Require the publish capability for a custom public status
jorgefilipecosta Oct 6, 2026
b47b5a0
Reject a parent that would make a loop
jorgefilipecosta Oct 6, 2026
dc606c1
Require a readable parent of the same post type
jorgefilipecosta Oct 6, 2026
7c17345
Keep a draft's floating date when its GMT date is sent back
jorgefilipecosta Oct 6, 2026
b145f6a
Make the slug unique when a post is created without a status
jorgefilipecosta Oct 6, 2026
e7922ec
Make a draft's slug unique under the parent it keeps
jorgefilipecosta Oct 6, 2026
efdd623
Mark where the query calls helpers core does not have
jorgefilipecosta Oct 6, 2026
804e0d1
Restore develop's comment in normalize_include()
jorgefilipecosta Oct 6, 2026
54762b4
Say why a write leaves out raw fields instead of failing
jorgefilipecosta Oct 6, 2026
93fec78
Describe how dates without a timezone offset are read
jorgefilipecosta Oct 6, 2026
3f8d23a
Set the public meta flag on the content write abilities
jorgefilipecosta Oct 6, 2026
7d5658f
Filter and return the author by slug in core/content-query
jorgefilipecosta Oct 6, 2026
7eefd2a
Assign the author by slug in the write abilities
jorgefilipecosta Oct 6, 2026
b63c489
List the settable statuses in the core/content-update schema
jorgefilipecosta Oct 6, 2026
74b478b
Let an update send back the post's current author
jorgefilipecosta Oct 6, 2026
7fead1d
Remove the Plugin markers that core no longer needs
jorgefilipecosta Oct 6, 2026
fa409e4
Say that editors can tell whether an author slug exists
jorgefilipecosta Oct 6, 2026
caf67be
Say that an update keeps the fields it leaves out
jorgefilipecosta Oct 6, 2026
73acf58
Describe what the write permission check returns now
jorgefilipecosta Oct 6, 2026
a304b09
Write the annotation comments as block comments
jorgefilipecosta Oct 6, 2026
278e0db
Describe every rule the parent field follows
jorgefilipecosta Oct 6, 2026
9e06881
Build the status enum the way the query does
jorgefilipecosta Oct 6, 2026
f2407fc
Check that a create rejected for a raw object writes no post
jorgefilipecosta Oct 6, 2026
fb8be0e
Drop a status test block that only repeats validation
jorgefilipecosta Oct 6, 2026
ef23f2d
Rename two update tests that kept REST names
jorgefilipecosta Oct 6, 2026
5d02174
Look up an exposed post type directly
jorgefilipecosta Oct 6, 2026
842b2b9
Remove the last Plugin marker that core no longer needs
jorgefilipecosta Oct 6, 2026
a16c791
Drop the stdClass import used once
jorgefilipecosta Oct 6, 2026
98920a1
Remove a REST comment the delete ability cannot hit
jorgefilipecosta Oct 6, 2026
d47c241
Call the updated post $post_before everywhere
jorgefilipecosta Oct 6, 2026
d5c4aaf
Word the private status error for updates too
jorgefilipecosta Oct 6, 2026
bff141f
Say what the create and update callbacks leave to write_content()
jorgefilipecosta Oct 6, 2026
9774938
Say in the experiment doc that gated abilities can change content
jorgefilipecosta Oct 6, 2026
1eb787d
Merge the three empty text field update tests
jorgefilipecosta Oct 6, 2026
2d8f04b
Drop the capability flush that add_cap() already does
jorgefilipecosta Oct 6, 2026
0b95523
Leave the co-author test's filter to tear_down()
jorgefilipecosta Oct 6, 2026
59151f9
Let an update send back the dates the post already has
jorgefilipecosta Oct 6, 2026
69c8cc6
Stop citing the author filter in parse_filter_int()'s docblock
jorgefilipecosta Oct 6, 2026
1eaa8d3
Say why the logged-out tests drop author_slug
jorgefilipecosta Oct 6, 2026
996eb94
Merge the two create tests for the publish capability
jorgefilipecosta Oct 6, 2026
1e4cfb3
Merge the create tests for parents that cannot be given
jorgefilipecosta Oct 6, 2026
113208a
Merge the delete tests for refused trashing and deletion
jorgefilipecosta Oct 6, 2026
a94b1a2
Prime the caches that permalinks read in the content query
jorgefilipecosta Oct 7, 2026
964c51f
Update the content query comments on string input
jorgefilipecosta Oct 7, 2026
b272451
Restore every loop global after rendering content query fields
jorgefilipecosta Oct 7, 2026
7c15f44
Hide users of other sites from the author slug filter on multisite
jorgefilipecosta Oct 7, 2026
17c1c25
Document duplicate slugs in hierarchical post types
jorgefilipecosta Oct 7, 2026
bb5feb6
Mark the query descriptions that core words without core/users-query
jorgefilipecosta Oct 7, 2026
b27bd9f
Align the `@param` tags in the content query
jorgefilipecosta Oct 7, 2026
10850d8
Mark the open_world annotation that core leaves out
jorgefilipecosta Oct 7, 2026
69d1b58
Document `show_in_abilities` as a boolean for post types
jorgefilipecosta Oct 7, 2026
5bdb762
Prime parent caches in the content query
jorgefilipecosta Oct 7, 2026
ea6eeca
Cover the editor password bypass for generated content query excerpts
jorgefilipecosta Oct 7, 2026
4a6cac3
Align the `@param` tags of replace_cached_post_date_columns()
jorgefilipecosta Oct 7, 2026
28f597a
Make the content query's field lists and loop globals constants
jorgefilipecosta Oct 7, 2026
4f43e81
Simplify the content query
jorgefilipecosta Oct 7, 2026
e252334
Schedule a draft without a fixed date at the date it is sent back
jorgefilipecosta Oct 7, 2026
74032ba
Label the content query ability "Query Content"
jorgefilipecosta Oct 7, 2026
a46f9dc
Start the content write ability labels with a verb
jorgefilipecosta Oct 7, 2026
339e4c7
Cover a title filter that returns a non-string
jorgefilipecosta Oct 7, 2026
a42e7ad
Port the latest content query changes from core
jorgefilipecosta Oct 7, 2026
4cb3999
Look up the current author only when an author slug is sent
jorgefilipecosta Oct 7, 2026
9d53668
Keep field names out of the write error strings
jorgefilipecosta Oct 7, 2026
971f05f
Rename check_write_permission() to check_author_permission()
jorgefilipecosta Oct 7, 2026
a97d1e9
Update the Show_In_Abilities docblock for the content abilities
jorgefilipecosta Oct 7, 2026
f71bde7
Use REST_TESTS_IMPOSSIBLY_HIGH_NUMBER for missing posts in the write …
jorgefilipecosta Oct 7, 2026
5ff7c96
Check the error code when the e2e test reads a deleted post
jorgefilipecosta Oct 7, 2026
c12678e
Keep core's content query registration and author slug tests
jorgefilipecosta Oct 7, 2026
692693c
Simplify the content write tests
jorgefilipecosta Oct 7, 2026
3e594f3
Port core's latest content query changes
jorgefilipecosta Oct 8, 2026
1c0ba09
Port core's review changes to the content abilities
jorgefilipecosta Oct 8, 2026
d8c21e5
Align the content query docs with the users and settings abilities
jorgefilipecosta Oct 8, 2026
00e6826
Port core's null dates, error params, and required ID to the content …
jorgefilipecosta Oct 9, 2026
c5e629e
Keep the content ability callbacks private
jorgefilipecosta Oct 9, 2026
7c6d3d5
Require the publish capability for publicly viewable statuses
jorgefilipecosta Oct 9, 2026
e111b4e
Keep the kses round-trip test passing on WordPress 7.2
jorgefilipecosta Oct 9, 2026
d8b0eda
Stop describing every other core ability as a closure
jorgefilipecosta Oct 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/experiments/custom-abilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Summary

The Custom Abilities experiment gates the plugin's general-purpose WordPress Abilities behind a single toggle. These are standalone abilities that are not tied to a user-facing editor feature. Because they expose site data through the Abilities API and MCP — and the set is expected to grow — they are registered only when a site owner explicitly enables this experiment, rather than always being on.
The Custom Abilities experiment gates the plugin's general-purpose WordPress Abilities behind a single toggle. These are standalone abilities that are not tied to a user-facing editor feature. They expose site data through the Abilities API and MCP, and some of them can also create, update, and delete content, including deleting it permanently instead of moving it to the Trash. Because of that — and because the set is expected to grow — they are registered only when a site owner explicitly enables this experiment, rather than always being on.

## Overview

Expand Down
1,934 changes: 1,477 additions & 457 deletions includes/Abilities/Content/Content.php

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions includes/Abilities/Gated/Content_Query.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Gated ability: content query.
* Gated ability: content query, create, update, and delete.
*
* @package WordPress\AI\Abilities\Gated
*/
Expand All @@ -16,9 +16,11 @@
defined( 'ABSPATH' ) || exit;

/**
* Gates the core/content-query ability.
* Gates the content abilities: core/content-query, core/content-create,
* core/content-update, and core/content-delete.
*
* @since 1.3.0
* @since x.x.x Also gates the create, update, and delete abilities.
*/
final class Content_Query extends Abstract_Gated_Ability {
/**
Expand Down
46 changes: 37 additions & 9 deletions includes/Abilities/Show_In_Abilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
* Class - Show_In_Abilities
*
* WordPress core does not yet ship the `show_in_abilities` flag consumed by the
* `core/settings-get` ability (and, in the future, post type and meta abilities). This
* component polyfills that flag onto a curated set of core objects so the abilities
* return data on a stock site, before/without the equivalent core change.
* `core/settings-get` and `core/content-*` abilities (and, in the future, meta abilities).
* This component polyfills that flag onto a curated set of core objects so the abilities
* work on a stock site, before/without the equivalent core change.
*
* It is intentionally object-type-agnostic: today it marks settings and post types; meta
* can be marked here the same way when those abilities land.
Expand All @@ -31,8 +31,8 @@
* — i.e. its `register_setting()` call must run before abilities init — for the ability to
* pick it up.
*
* Post types must be registered with `show_in_abilities` before `core/content-query` is
* registered so they are included in the ability's input schema.
* Post types must be registered with `show_in_abilities` before the `core/content-*`
* abilities are registered so they are included in the abilities' input schemas.
*
* @internal This class should not be used outside the plugin and there is no guarantee of backwards compatibility.
*
Expand All @@ -46,17 +46,24 @@ final class Show_In_Abilities {
*
* @since 1.1.0
* @since 1.2.0 Also marks curated post types.
* @since x.x.x Also keeps only a post type flag of `true`.
*/
public function register(): void {
add_filter( 'register_setting_args', array( $this, 'mark_setting' ), 10, 4 );
add_filter( 'register_post_type_args', array( $this, 'mark_post_type' ), 10, 2 );
add_action( 'registered_post_type', array( $this, 'normalize_post_type_flag' ) );

/*
* Core post types (post, page) are registered very early — during bootstrap and on
* `init` priority 0 — which is typically before this component runs, so the filter
* above would miss them. Mark any already-registered curated post types directly.
*/
$this->mark_registered_post_types();

// Most post types register on `init` before this component runs, so the action above misses them.
foreach ( get_post_types() as $post_type ) {
$this->normalize_post_type_flag( $post_type );
}
}

/**
Expand Down Expand Up @@ -187,16 +194,37 @@ public function mark_registered_post_types(): void {
}
}

/**
* Keeps only a `show_in_abilities` value of `true` on a registered post type.
*
* Once core declares the flag, WP_Post_Type::set_props() turns any other value into
* `false`, so other values, such as arrays, can be given a meaning later. Until then,
* core stores the registration argument as is, so this does the same after registration.
*
* @since x.x.x
*
* @param string $post_type The post type key.
*/
public function normalize_post_type_flag( string $post_type ): void {
$object = get_post_type_object( $post_type );

if ( $this->core_declares_post_type_flag() || ! ( $object instanceof \WP_Post_Type ) || ! property_exists( $object, 'show_in_abilities' ) ) {
return;
}

$object->show_in_abilities = true === $object->show_in_abilities;
}

/**
* Returns the curated core post types to expose, keyed by post type key.
*
* The value is whatever `show_in_abilities` should contain: `true`, or an array
* reserved for enabling specific operations in the future. This matches the set
* marked natively by the core `core/content-query` implementation (`post` and `page`).
* The value is whatever `show_in_abilities` should contain, which is a boolean for post
* types, as `show_in_rest` is. This matches the set marked natively by the core
* `core/content-query` implementation (`post` and `page`).
*
* @since 1.2.0
*
* @return array<string, bool|array<string, mixed>> Post types map keyed by post type key.
* @return array<string, bool> Post types map keyed by post type key.
*/
private function post_types_map(): array {
return array(
Expand Down
Loading
Loading