Skip to content
Merged
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ The entries below describe the current prototype state._
category cannot be deleted (core's capability mapping denies the cap, and
`wp_delete_term()` refuses the term). Rides the same
`taxonomy_show_in_abilities` opt-in and content category as the query.
- `show_in_rest` exposure flag on the three tier-core backports
(`core/content-query`, `core/settings-get`, `core/users-query`): their
`ability_meta()` now sets the flag explicitly under a `// Package:` marker,
so the abilities stay exposed over core's REST abilities routes on every
supported WordPress (6.9+) — core's own registration omits the flag and
relies on `meta.public` seeding it, which WordPress 7.1+ only does. The same
accommodation the AI plugin's synced copies carry with their `// Plugin:`
marker, made once in the package; the coreify round-trip gate tolerates
exactly this marked line and nothing more (a `PKG_META_ACCOMMODATIONS` map:
`--reverse` re-injects the flag into regenerated backports, forward drops it
behind `// Package:`-verified markers), and the trio tests pin
`meta.show_in_rest === true` with the high-level `public` meta unchanged.
### Removed

- `wp/post-create` — the self-authored experimental write-ability prototype
Expand Down
15 changes: 12 additions & 3 deletions src/Content/Content_Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,23 +213,32 @@ protected function make_permission_callback(): callable {
}

/**
* The authored ability meta, exactly as core registers it.
* The authored ability meta: core-verbatim, plus one marked package accommodation.
*
* Core also carries no `required_capabilities` on this ability: the permission callback
* gates the request as a whole (an authenticated user, an exposed post type, and the
* capabilities for the requested statuses), and execute_content_query() adds the
* row-level read checks, so the static floor stays empty here too.
*
* The `show_in_rest` key below is the one addition (see its `// Package:` marker):
* core's registration omits the flag and relies on `public` seeding it, which
* WordPress 7.1+ only does, so the flag is set explicitly to stay exposed over the
* REST abilities routes on every supported WordPress (6.9+).
*
* @return array<string, mixed> The ability meta.
*/
protected function ability_meta(): array {
return array(
'annotations' => array(
'annotations' => array(
'readonly' => true,
'destructive' => false,
'idempotent' => true,
),
'public' => true,
'public' => true,
// Package: set explicitly so the ability is exposed over REST on all
// supported WordPress versions; core's registration relies on the
// `public` flag seeding `show_in_rest`, which WordPress 7.1+ only does.
'show_in_rest' => true,
);
}

Expand Down
3 changes: 3 additions & 0 deletions src/Media/Media_Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ protected function ability_meta(): array {
'open_world' => false,
),
'show_in_rest' => true,
'mcp' => array(
'public' => true,
),
);
}
}
3 changes: 3 additions & 0 deletions src/Media/Media_Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ protected function ability_meta(): array {
'open_world' => false,
),
'show_in_rest' => true,
'mcp' => array(
'public' => true,
),
);
}

Expand Down
3 changes: 3 additions & 0 deletions src/Media/Media_Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ protected function ability_meta(): array {
'open_world' => false,
),
'show_in_rest' => true,
'mcp' => array(
'public' => true,
),
);
}
}
3 changes: 3 additions & 0 deletions src/Media/Media_Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ protected function ability_meta(): array {
'open_world' => true,
),
'show_in_rest' => true,
'mcp' => array(
'public' => true,
),
);
}
}
15 changes: 12 additions & 3 deletions src/Settings/Settings_Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,27 @@ protected function make_permission_callback(): ?callable {
}

/**
* The authored ability meta, exactly as core registers it.
* The authored ability meta: core-verbatim, plus one marked package accommodation.
*
* The `show_in_rest` key below is the one addition (see its `// Package:` marker):
* core's registration omits the flag and relies on `public` seeding it, which
* WordPress 7.1+ only does, so the flag is set explicitly to stay exposed over the
* REST abilities routes on every supported WordPress (6.9+).
*
* @return array<string, mixed> The ability meta.
*/
protected function ability_meta(): array {
return array(
'annotations' => array(
'annotations' => array(
'readonly' => true,
'destructive' => false,
'idempotent' => true,
),
'public' => true,
'public' => true,
// Package: set explicitly so the ability is exposed over REST on all
// supported WordPress versions; core's registration relies on the
// `public` flag seeding `show_in_rest`, which WordPress 7.1+ only does.
'show_in_rest' => true,
);
}

Expand Down
3 changes: 3 additions & 0 deletions src/Terms/Term_Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ protected function ability_meta(): array {
'open_world' => false,
),
'show_in_rest' => true,
'mcp' => array(
'public' => true,
),
);
}
}
3 changes: 3 additions & 0 deletions src/Terms/Term_Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ protected function ability_meta(): array {
'open_world' => false,
),
'show_in_rest' => true,
'mcp' => array(
'public' => true,
),
);
}
}
3 changes: 3 additions & 0 deletions src/Terms/Term_Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ protected function ability_meta(): array {
'open_world' => false,
),
'show_in_rest' => true,
'mcp' => array(
'public' => true,
),
);
}
}
3 changes: 3 additions & 0 deletions src/Terms/Terms_Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ protected function ability_meta(): array {
'open_world' => false,
),
'show_in_rest' => true,
'mcp' => array(
'public' => true,
),
);
}

Expand Down
15 changes: 12 additions & 3 deletions src/Users/Users_Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,27 @@ protected function make_permission_callback(): callable {
}

/**
* The authored ability meta, exactly as core registers it.
* The authored ability meta: core-verbatim, plus one marked package accommodation.
*
* The `show_in_rest` key below is the one addition (see its `// Package:` marker):
* core's registration omits the flag and relies on `public` seeding it, which
* WordPress 7.1+ only does, so the flag is set explicitly to stay exposed over the
* REST abilities routes on every supported WordPress (6.9+).
*
* @return array<string, mixed> The ability meta.
*/
protected function ability_meta(): array {
return array(
'annotations' => array(
'annotations' => array(
'readonly' => true,
'destructive' => false,
'idempotent' => true,
),
'public' => true,
'public' => true,
// Package: set explicitly so the ability is exposed over REST on all
// supported WordPress versions; core's registration relies on the
// `public` flag seeding `show_in_rest`, which WordPress 7.1+ only does.
'show_in_rest' => true,
);
}

Expand Down
6 changes: 6 additions & 0 deletions tests/Abilities/ContentQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ public function test_registered_once_with_core_annotations(): void {
$meta['annotations'] ?? null
);
self::assertTrue( (bool) ( $meta['public'] ?? false ) );
self::assertSame(
true,
$meta['show_in_rest'] ?? null,
'The ability stays exposed over the REST abilities routes on every supported WordPress: core seeds show_in_rest from `public` on 7.1+ only, so the package copy ships the flag explicitly (the `// Package:` meta accommodation).'
);
self::assertSame( true, $ability->get_meta_item( 'public', null ), 'The high-level public meta stays true.' );

if ( empty( $meta['source'] ) ) {
// Trunk env: core provides the name; the package copy must have skipped.
Expand Down
6 changes: 6 additions & 0 deletions tests/Abilities/MediaDeleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ public function test_registers_the_delete_ability(): void {
self::assertSame( 'Media Delete', $ability->get_label(), 'The ability should use the PR\'s label.' );
self::assertSame( 'media', $ability->get_category(), 'The ability should use the package-authored media category.' );
self::assertTrue( (bool) ( $meta['show_in_rest'] ?? false ), 'The ability should be exposed in REST.' );
self::assertSame(
array( 'public' => true ),
$meta['mcp'] ?? null,
'The mcp meta opts the ability in for MCP-tool exposure; the high-level public meta is unchanged.'
);
self::assertFalse( $ability->get_meta_item( 'public', false ), 'The high-level public meta is unchanged.' );

$annotations = $meta['annotations'] ?? array();
self::assertFalse( (bool) ( $annotations['readonly'] ?? true ), 'Deleting writes the library.' );
Expand Down
6 changes: 6 additions & 0 deletions tests/Abilities/MediaQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ public function test_registered_once_with_annotations_and_provenance(): void {
self::assertSame( 'Media Query', $ability->get_label(), 'The ability should use the PR\'s label.' );
self::assertSame( 'media', $ability->get_category(), 'The ability should use the package-authored media category.' );
self::assertTrue( (bool) ( $meta['show_in_rest'] ?? false ), 'The ability should be exposed in REST.' );
self::assertSame(
array( 'public' => true ),
$meta['mcp'] ?? null,
'The mcp meta opts the ability in for MCP-tool exposure; the high-level public meta is unchanged.'
);
self::assertFalse( $ability->get_meta_item( 'public', false ), 'The high-level public meta is unchanged.' );
self::assertSame(
array(
'readonly' => true,
Expand Down
6 changes: 6 additions & 0 deletions tests/Abilities/MediaUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ public function test_registers_the_update_ability(): void {
self::assertSame( 'Media Update', $ability->get_label(), 'The ability should use the PR\'s label.' );
self::assertSame( 'media', $ability->get_category(), 'The ability should use the package-authored media category.' );
self::assertTrue( (bool) ( $meta['show_in_rest'] ?? false ), 'The ability should be exposed in REST.' );
self::assertSame(
array( 'public' => true ),
$meta['mcp'] ?? null,
'The mcp meta opts the ability in for MCP-tool exposure; the high-level public meta is unchanged.'
);
self::assertFalse( $ability->get_meta_item( 'public', false ), 'The high-level public meta is unchanged.' );

$annotations = $meta['annotations'] ?? array();
self::assertFalse( (bool) ( $annotations['readonly'] ?? true ), 'Updating writes the item.' );
Expand Down
6 changes: 6 additions & 0 deletions tests/Abilities/MediaUploadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ public function test_registers_the_upload_ability(): void {
self::assertSame( 'Media Upload', $ability->get_label(), 'The ability should use the PR\'s label.' );
self::assertSame( 'media', $ability->get_category(), 'The ability should use the package-authored media category.' );
self::assertTrue( (bool) ( $meta['show_in_rest'] ?? false ), 'The ability should be exposed in REST.' );
self::assertSame(
array( 'public' => true ),
$meta['mcp'] ?? null,
'The mcp meta opts the ability in for MCP-tool exposure; the high-level public meta is unchanged.'
);
self::assertFalse( $ability->get_meta_item( 'public', false ), 'The high-level public meta is unchanged.' );

$annotations = $meta['annotations'] ?? array();
self::assertFalse( (bool) ( $annotations['readonly'] ?? true ), 'Uploading writes the library.' );
Expand Down
6 changes: 6 additions & 0 deletions tests/Abilities/SettingsGetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ public function test_registered_once_with_core_annotations(): void {
$meta['annotations'] ?? null
);
self::assertTrue( (bool) ( $meta['public'] ?? false ) );
self::assertSame(
true,
$meta['show_in_rest'] ?? null,
'The ability stays exposed over the REST abilities routes on every supported WordPress: core seeds show_in_rest from `public` on 7.1+ only, so the package copy ships the flag explicitly (the `// Package:` meta accommodation).'
);
self::assertSame( true, $ability->get_meta_item( 'public', null ), 'The high-level public meta stays true.' );

if ( empty( $meta['source'] ) ) {
// Trunk env: core provides the name; the package copy must have skipped.
Expand Down
2 changes: 2 additions & 0 deletions tests/Abilities/TermWritesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ public function test_registered_once_with_the_pr_contract(): void {
foreach ( array( $create, $update, $delete ) as $ability ) {
self::assertSame( 'content', $ability->get_category(), 'The write abilities share the query\'s content category.' );
self::assertTrue( $ability->get_meta_item( 'show_in_rest', false ), 'The write abilities should be exposed in REST.' );
self::assertSame( array( 'public' => true ), $ability->get_meta_item( 'mcp', array() ), 'The mcp meta opts the write abilities in for MCP-tool exposure.' );
self::assertFalse( $ability->get_meta_item( 'public', false ), 'The write abilities\' high-level public meta is unchanged.' );
}

$create_annotations = $create->get_meta_item( 'annotations', array() );
Expand Down
6 changes: 6 additions & 0 deletions tests/Abilities/TermsQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ public function test_registered_once_with_annotations_and_provenance(): void {
self::assertSame( 'Terms Query', $ability->get_label(), 'The ability should use the PR\'s label.' );
self::assertSame( 'content', $ability->get_category(), 'The ability should use the content category.' );
self::assertTrue( (bool) ( $meta['show_in_rest'] ?? false ), 'The ability should be exposed in REST.' );
self::assertSame(
array( 'public' => true ),
$meta['mcp'] ?? null,
'The mcp meta opts the ability in for MCP-tool exposure; the high-level public meta is unchanged.'
);
self::assertFalse( $ability->get_meta_item( 'public', false ), 'The high-level public meta is unchanged.' );
self::assertSame(
array(
'readonly' => true,
Expand Down
6 changes: 6 additions & 0 deletions tests/Abilities/UsersQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ public function test_registered_once_with_core_annotations(): void {
$meta['annotations'] ?? null
);
self::assertTrue( (bool) ( $meta['public'] ?? false ) );
self::assertSame(
true,
$meta['show_in_rest'] ?? null,
'The ability stays exposed over the REST abilities routes on every supported WordPress: core seeds show_in_rest from `public` on 7.1+ only, so the package copy ships the flag explicitly (the `// Package:` meta accommodation).'
);
self::assertSame( true, $ability->get_meta_item( 'public', null ), 'The high-level public meta stays true.' );

if ( empty( $meta['source'] ) ) {
// Trunk env: core provides the name; the package copy must have skipped.
Expand Down
Loading
Loading