Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ the initial snapshot of the prototype.
`core-experimental/` abilities keep the no-promises experimental tier;
`core/` and `wordpress/` semantics are untouched.

- **Breaking:** Moved the `core/content-*` write trio back from tier `stable`
to the experimental tier: `core/content-create`, `core/content-update`, and
`core/content-delete` became `core-experimental/content-create`,
`core-experimental/content-update`, and `core-experimental/content-delete`
([issue #17](https://github.com/WordPress/abilities/issues/17); staging
decision per [PR #33](https://github.com/WordPress/abilities/pull/33)). The
core proposal ([Trac #66706](https://core.trac.wordpress.org/ticket/66706),
WordPress/wordpress-develop PR #16028) is still in review with the shape
still moving, so the trio incubates until it lands in core — when the
canonical `core/` versions sync back, superseding the experimental copies.
Per the rename protocol (NAME-LIFECYCLE.md) the manifest entries record the
previous `core/` names under `renamed_from` (stamped into each ability's
`meta.renamed_from`); the `core/` names shipped by the 0.1.0 release stop
working with the release carrying this change, and no alias period is
offered.

### Added

- Repository scaffold and tooling: Composer contract for `wordpress/abilities`
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ Full rules, the promotion path, and the rename protocol are in
| `core/content-query` | core | content | Backport of the readonly content query ability landed in WordPress core 7.2 (`core_since: 7.2`). On 7.2+ core provides it and the Registrar skips it; on 6.9–7.1 the package serves it under the same name. Requires the `show_in_abilities` support feature (polyfilled where core lacks it). |
| `core/settings-get` | core | site | Backport of the readonly settings get ability landed in WordPress core 7.2 (`core_since: 7.2`). On 7.2+ core provides it and the Registrar skips it; on 6.9–7.1 the package serves it under the same name. Requires the `setting_show_in_abilities` support feature (polyfilled where core lacks it: core's own settings are flagged and registered before the ability reads them, as on 7.2). |
| `core/users-query` | core | user | Backport of the readonly users query ability landed in WordPress core 7.2 (`core_since: 7.2`). On 7.2+ core provides it and the Registrar skips it; on 6.9–7.1 the package serves it under the same name. Needs no support feature beyond the Abilities API. |
| `core/content-create` | stable | content | Port of the content create ability from [WordPress/ai PR #1025](https://github.com/WordPress/ai/pull/1025) (`core_since: null` — flips to tier `core` when it lands in WordPress core). Creates posts of types exposed to abilities under the field names `core/content-query` returns. |
| `core/content-update` | stable | content | Port of the content update ability from [WordPress/ai PR #1025](https://github.com/WordPress/ai/pull/1025) (`core_since: null` — flips to tier `core` when it lands in WordPress core). Updates a post by ID; fields left out keep their current values. |
| `core/content-delete` | stable | content | Port of the content delete ability from [WordPress/ai PR #1025](https://github.com/WordPress/ai/pull/1025) (`core_since: null` — flips to tier `core` when it lands in WordPress core). Trashes a post by ID, or deletes it permanently with `force`. |
| `core-experimental/content-create` | experimental | content | Port of the content create ability from [WordPress/ai PR #1025](https://github.com/WordPress/ai/pull/1025) (`core_since: null` — flips to tier `core` when it lands in WordPress core; incubating under the `core-experimental/` prefix until then, with the 0.1.0 `core/` names recorded under `renamed_from`). Creates posts of types exposed to abilities under the field names `core/content-query` returns. |
| `core-experimental/content-update` | experimental | content | Port of the content update ability from [WordPress/ai PR #1025](https://github.com/WordPress/ai/pull/1025) (`core_since: null` — flips to tier `core` when it lands in WordPress core; incubating under the `core-experimental/` prefix until then, with the 0.1.0 `core/` names recorded under `renamed_from`). Updates a post by ID; fields left out keep their current values. |
| `core-experimental/content-delete` | experimental | content | Port of the content delete ability from [WordPress/ai PR #1025](https://github.com/WordPress/ai/pull/1025) (`core_since: null` — flips to tier `core` when it lands in WordPress core; incubating under the `core-experimental/` prefix until then, with the 0.1.0 `core/` names recorded under `renamed_from`). Trashes a post by ID, or deletes it permanently with `force`. |
| `core-experimental/media-query` | experimental | media | Port of the read-only media query ability from [WordPress/ai PR #1098](https://github.com/WordPress/ai/pull/1098) (`core_since: null` — flips to tier `core` when it lands in WordPress core). Reads media library items — a single item by ID, or a paginated filtered collection (`media`/`total`/`total_pages`) with totals; `fields` picks a subset, and raw fields require edit access. Uses the package-authored `media` category (core has no equivalent to copy). |
| `core-experimental/media-upload` | experimental | media | Port of the media upload ability from [WordPress/ai PR #1104](https://github.com/WordPress/ai/pull/1104) (`core_since: null` — flips to tier `core` when it lands in WordPress core). Uploads a file from base64 `data` + `filename` (with attachment fields), or downloads an image from a `url` (parent post only). Returns the new item in the edit context; `fields` picks a subset. Requires `upload_files`; the parent and author are named-field checks. A URL upload downloads from another site (`open_world: true`), capped at the site's upload size. Uses the package-authored `media` category. |
| `core-experimental/media-update` | experimental | media | Port of the media update ability from [WordPress/ai PR #1104](https://github.com/WordPress/ai/pull/1104) (`core_since: null` — flips to tier `core` when it lands in WordPress core). Updates a media item by ID with the same attachment fields (the status is validated against the attachment, so `inherit` can be kept); fields left out keep their values. Returns the updated item in the edit context. Requires edit access to the item (`edit_post` for attachments, via the same projection `core-experimental/media-query` reads with). |
Expand Down
35 changes: 20 additions & 15 deletions src/Content/Abstract_Content_Write.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
* The helpers shared with `core/content-query` (read permission, post and author
* lookup, field projection, post rendering) are extracted verbatim from this
* package's Content_Query port of core's WP_Abilities_Content, with `private`
* relaxed to `protected` so the write ability subclasses reuse them. The write
* logic itself (create, update, delete) is a faithful port of the PR, with the
* relaxed to `protected` so the write ability subclasses reuse them. Upstream
* names the abilities `core/content-create`, `core/content-update`, and
* `core/content-delete`: while the core proposal (Trac #66706 /
* WordPress/wordpress-develop PR #16028) is in review, this package ships
* them under the experimental tier's `core-experimental/` prefix (see
* NAME-LIFECYCLE.md). The write logic itself (create, update, delete) is a
* faithful port of the PR, with the
* settled divergences of the port plan: this package's dotted field paths
* (`title.raw`, `content.raw`, `excerpt.raw`, `author.slug`, `date.local`,
* `date.gmt`) everywhere the PR uses its flat renamed ones, the `default` text
Expand All @@ -33,14 +38,14 @@
use WordPress\Abilities\Abstract_Core_Ability;

/**
* Shared base for the `core/content-create`, `core/content-update`, and
* `core/content-delete` abilities.
* Shared base for the `core-experimental/content-create`, `core-experimental/content-update`, and
* `core-experimental/content-delete` abilities.
*
* Holds everything the three write abilities share: the post field definitions
* and projection of `core/content-query` (so a post can be read and written back
* unchanged), the permission and execute callbacks of each ability, and the
* input schema builders. Only the Abilities API calls the callbacks: callers go
* through the registry, such as `wp_get_ability( 'core/content-create' )->execute()`,
* through the registry, such as `wp_get_ability( 'core-experimental/content-create' )->execute()`,
* which validates the input and checks permissions before running them.
*
* @package WordPress\Abilities
Expand Down Expand Up @@ -888,7 +893,7 @@ protected function format_date( WP_Post $post, string $field, bool $gmt ): ?stri
}

/**
* Permission callback for the `core/content-create` ability.
* Permission callback for the `core-experimental/content-create` ability.
*
* The current user must be able to create posts of the requested post type. The rest
* of the input is checked during execution.
Expand All @@ -912,7 +917,7 @@ protected function check_create_permission( $input = array() ): bool {
}

/**
* Permission callback for the `core/content-update` ability.
* Permission callback for the `core-experimental/content-update` ability.
*
* The post must exist in an exposed post type (and match the `type` guard when
* given), and the current user must be able to edit it. The rest of the input is
Expand All @@ -937,7 +942,7 @@ protected function check_update_permission( $input = array() ): bool {
}

/**
* Permission callback for the `core/content-delete` ability.
* Permission callback for the `core-experimental/content-delete` ability.
*
* The post must exist in an exposed post type (and match the `type` guard when
* given), and the current user must be able to delete it. As in `core/content-query`,
Expand Down Expand Up @@ -1137,7 +1142,7 @@ protected function get_post_by_slug( string $post_type, string $slug ): ?WP_Post
}

/**
* Executes the `core/content-create` ability.
* Executes the `core-experimental/content-create` ability.
*
* {@see WP_Ability::execute()} always runs {@see self::check_create_permission()} first,
* so this re-validates the post type lookup and leaves the rest of the input to
Expand All @@ -1158,7 +1163,7 @@ protected function execute_content_create( $input = array() ) {
}

/**
* Executes the `core/content-update` ability.
* Executes the `core-experimental/content-update` ability.
*
* {@see WP_Ability::execute()} always runs {@see self::check_update_permission()} first,
* so this re-validates the post lookup and leaves the rest of the input to
Expand Down Expand Up @@ -1265,7 +1270,7 @@ protected function write_content( array $input, WP_Post_Type $post_type_object,
}

/**
* Executes the `core/content-delete` ability.
* Executes the `core-experimental/content-delete` ability.
*
* {@see WP_Ability::execute()} always runs {@see self::check_delete_permission()} first;
* this re-validates the lookup and, because the operation is destructive, checks the
Expand Down Expand Up @@ -1396,7 +1401,7 @@ protected function get_content_write_properties(): array {
}

/**
* Builds the input schema for the `core/content-create` ability.
* Builds the input schema for the `core-experimental/content-create` ability.
*
* `additionalProperties: false` rejects unknown fields instead of dropping them, so e.g.
* passing an `id` fails validation instead of silently creating a new post.
Expand Down Expand Up @@ -1424,14 +1429,14 @@ protected function get_content_create_input_schema( array $post_types ): array {
}

/**
* Builds the input schema for the `core/content-update` ability from the create schema.
* Builds the input schema for the `core-experimental/content-update` ability from the create schema.
*
* The post is identified by `id`, and `type` becomes an optional guard. The status
* keeps the create schema's enum, so clients can see and check the statuses that can be
* set. A post with an internal status, such as `trash`, keeps it when the status is left
* out; validation rejects that status before execution, even when it is the current one.
*
* @param array<string, mixed> $create_schema The input schema of the `core/content-create` ability.
* @param array<string, mixed> $create_schema The input schema of the `core-experimental/content-create` ability.
* @return array<string, mixed> The input JSON Schema.
*/
protected function get_content_update_input_schema( array $create_schema ): array {
Expand All @@ -1455,7 +1460,7 @@ protected function get_content_update_input_schema( array $create_schema ): arra
}

/**
* Builds the input schema for the `core/content-delete` ability.
* Builds the input schema for the `core-experimental/content-delete` ability.
*
* @param list<string> $post_types Exposed post type names.
* @return array<string, mixed> The input JSON Schema.
Expand Down
6 changes: 3 additions & 3 deletions src/Content/Content_Create.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Canonical WordPress abilities: `core/content-create` ability.
* Canonical WordPress abilities: `core-experimental/content-create` ability.
*
* Ported from WordPress/ai PR #1025 (https://github.com/WordPress/ai/pull/1025) by @jorgefilipecosta.
*
Expand All @@ -13,7 +13,7 @@
use WP_Error;

/**
* Registers the `core/content-create` ability, which creates a post of a post type
* Registers the `core-experimental/content-create` ability, which creates a post of a post type
* exposed to abilities. All logic is shared with the sibling write abilities in
* {@see Abstract_Content_Write}, which this class only wires into the authoring
* surface.
Expand All @@ -27,7 +27,7 @@ final class Content_Create extends Abstract_Content_Write {
* @return string
*/
protected function ability_name(): string {
return 'core/content-create';
return 'core-experimental/content-create';
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Content/Content_Delete.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Canonical WordPress abilities: `core/content-delete` ability.
* Canonical WordPress abilities: `core-experimental/content-delete` ability.
*
* Ported from WordPress/ai PR #1025 (https://github.com/WordPress/ai/pull/1025) by @jorgefilipecosta.
*
Expand All @@ -13,7 +13,7 @@
use WP_Error;

/**
* Registers the `core/content-delete` ability, which trashes a post by ID, or deletes
* Registers the `core-experimental/content-delete` ability, which trashes a post by ID, or deletes
* it permanently when `force` is true. All logic is shared with the sibling write
* abilities in {@see Abstract_Content_Write}, which this class only wires into the
* authoring surface.
Expand All @@ -27,7 +27,7 @@ final class Content_Delete extends Abstract_Content_Write {
* @return string
*/
protected function ability_name(): string {
return 'core/content-delete';
return 'core-experimental/content-delete';
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Content/Content_Update.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Canonical WordPress abilities: `core/content-update` ability.
* Canonical WordPress abilities: `core-experimental/content-update` ability.
*
* Ported from WordPress/ai PR #1025 (https://github.com/WordPress/ai/pull/1025) by @jorgefilipecosta.
*
Expand All @@ -13,7 +13,7 @@
use WP_Error;

/**
* Registers the `core/content-update` ability, which updates a post by ID. All logic
* Registers the `core-experimental/content-update` ability, which updates a post by ID. All logic
* is shared with the sibling write abilities in {@see Abstract_Content_Write}, which
* this class only wires into the authoring surface.
*
Expand All @@ -26,7 +26,7 @@ final class Content_Update extends Abstract_Content_Write {
* @return string
*/
protected function ability_name(): string {
return 'core/content-update';
return 'core-experimental/content-update';
}

/**
Expand Down
35 changes: 19 additions & 16 deletions src/Manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,42 +88,45 @@ public static function all(): array {
* The write trio below is a faithful port of WordPress/ai PR #1025
* (author @jorgefilipecosta), on the package's dotted field paths.
*
* Tier: the PR is a filed core proposal, not landed core, so the
* trio is stable (§7.2: a `core/` name is adopted at proposal
* filing). The entries flip to core with `core_since` set once
* the abilities land in an actual WordPress release.
* Tier: experimental, incubating under the `core-experimental/`
* prefix. Unlike the other incubating ports, the trio has already
* spent time one tier up: the package carried it under tier
* stable and the core/ prefix from the 0.1.0 release. They were
* returned to experimental in #33 pending finalization of the
* canonical forms in a WordPress release . `renamed_from` records
* the core/ names the 0.1.0 release carried.
*/
'core/content-create' => array(
'name' => 'core/content-create',
'core-experimental/content-create' => array(
'name' => 'core-experimental/content-create',
'class' => Content\Content_Create::class,
'category' => 'content',
'tier' => self::TIER_STABLE,
'tier' => self::TIER_EXPERIMENTAL,
'min_wp_version' => '6.9',
'core_since' => null,
'requires' => array( 'show_in_abilities' ),
'renamed_from' => null,
'renamed_from' => 'core/content-create',
'proposal' => 'https://github.com/WordPress/ai/pull/1025',
),
'core/content-update' => array(
'name' => 'core/content-update',
'core-experimental/content-update' => array(
'name' => 'core-experimental/content-update',
'class' => Content\Content_Update::class,
'category' => 'content',
'tier' => self::TIER_STABLE,
'tier' => self::TIER_EXPERIMENTAL,
'min_wp_version' => '6.9',
'core_since' => null,
'requires' => array( 'show_in_abilities' ),
'renamed_from' => null,
'renamed_from' => 'core/content-update',
'proposal' => 'https://github.com/WordPress/ai/pull/1025',
),
'core/content-delete' => array(
'name' => 'core/content-delete',
'core-experimental/content-delete' => array(
'name' => 'core-experimental/content-delete',
'class' => Content\Content_Delete::class,
'category' => 'content',
'tier' => self::TIER_STABLE,
'tier' => self::TIER_EXPERIMENTAL,
'min_wp_version' => '6.9',
'core_since' => null,
'requires' => array( 'show_in_abilities' ),
'renamed_from' => null,
'renamed_from' => 'core/content-delete',
'proposal' => 'https://github.com/WordPress/ai/pull/1025',
),
/*
Expand Down
11 changes: 6 additions & 5 deletions tests/Abilities/ContentCreateTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Tests: `core/content-create` (port of WordPress/ai PR #1025).
* Tests: `core-experimental/content-create` (port of WordPress/ai PR #1025).
*
* Runs under both wp-env matrix environments. Unlike `core/content-query`,
* which core itself provides on trunk, the write trio is a filed proposal
Expand All @@ -25,7 +25,7 @@
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

/**
* Per-ability contract tests for `core/content-create`.
* Per-ability contract tests for `core-experimental/content-create`.
*/
final class ContentCreateTest extends TestCase {

Expand Down Expand Up @@ -105,10 +105,10 @@ public function tear_down(): void {
}

/**
* The registered `core/content-create` instance, or null.
* The registered `core-experimental/content-create` instance, or null.
*/
private function get_registered(): ?object {
return WP_Abilities_Registry::get_instance()->get_registered( 'core/content-create' );
return WP_Abilities_Registry::get_instance()->get_registered( 'core-experimental/content-create' );
}

/**
Expand Down Expand Up @@ -263,7 +263,8 @@ public function test_registered_meta_and_schema(): void {
self::assertTrue( (bool) ( $meta['public'] ?? false ) );
self::assertTrue( (bool) ( $meta['show_in_rest'] ?? false ) );
self::assertSame( 'wordpress/abilities', $meta['source'] ?? null, 'The package copy provides the trio in both environments.' );
self::assertSame( Manifest::TIER_STABLE, $meta['stability'] ?? null );
self::assertSame( Manifest::TIER_EXPERIMENTAL, $meta['stability'] ?? null );
self::assertSame( 'core/content-create', $meta['renamed_from'] ?? null, 'The demoted ability records its previous core/ stable-tier name.' );

if ( method_exists( $ability, 'get_category' ) ) {
self::assertSame( 'content', $ability->get_category() );
Expand Down
Loading
Loading