You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/1.intro.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ It acts as a central registry, making it easier for different parts of WordPress
12
12
-**Registry:** A central, singleton object (`WP_Abilities_Registry`) that holds all registered abilities. It provides methods for registering, unregistering, finding, and querying abilities.
13
13
-**Callback:** The PHP function or method executed when an ability is called via `WP_Ability::execute()`.
14
14
-**Schema:** JSON Schema definitions for an ability's expected input (`input_schema`) and its returned output (`output_schema`). This allows for validation and helps agents understand how to use the ability.
15
-
-**Permission Callback:** An optional function that determines if the current user can execute a specific ability.
15
+
-**Permission Callback:** An optional function that determines if the current user can execute a specific ability.
16
16
-**Namespace:** The first part of an ability name (before the slash), typically matching the plugin or component name that registers the ability.
17
17
18
18
## Goals and Benefits
@@ -76,7 +76,8 @@ function my_plugin_register_ability(){
Copy file name to clipboardExpand all lines: docs/3.registering-abilities.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,9 @@ The `$args` array accepts the following keys:
32
32
-`readonly` (`bool`): Whether the ability only reads data without modifying its environment (default: `false`).
33
33
-`destructive` (`bool`): Whether the ability may perform destructive updates to its environment. If `true`, the ability may perform any type of modification, including deletions or other destructive changes. If `false`, the ability performs only additive updates (default: `true`).
34
34
-`idempotent` (`bool`): Whether calling the ability repeatedly with the same arguments will have no additional effect on its environment (default: `false`).
35
+
-`show_in_rest` (`boolean`, **Optional**): Whether to expose this ability via the REST API. Default: `false`.
36
+
- When `true`, the ability will be listed in REST API responses and can be executed via REST endpoints.
37
+
- When `false`, the ability will be hidden from REST API listings and cannot be executed via REST endpoints, but remains available for internal PHP usage.
35
38
-`meta` (`array`, **Optional**): An associative array for storing arbitrary additional metadata about the ability.
Copy file name to clipboardExpand all lines: docs/5.rest-api.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,15 @@ The WordPress Abilities API provides REST endpoints that allow external systems
6
6
7
7
Access to all Abilities REST API endpoints requires an authenticated user (see the [Authentication](#authentication) section). Access to execute individual Abilities is restricted based on the `permission_callback()` of the Ability.
8
8
9
+
## Controlling REST API Exposure
10
+
11
+
By default, registered abilities are **not** exposed via the REST API. You can control whether an individual ability appears in the REST API by using the `show_in_rest` argument when registering the ability:
12
+
13
+
-`show_in_rest => true`: The ability is listed in REST API responses and can be executed via REST endpoints.
14
+
-`show_in_rest => false` (default): The ability is hidden from REST API listings and cannot be executed via REST endpoints. The ability remains available for internal PHP usage via `wp_execute_ability()`.
15
+
16
+
Abilities with `show_in_rest => false` will return a `rest_ability_not_found` error if accessed via REST endpoints.
17
+
9
18
## Schema
10
19
11
20
The Abilities API endpoints are available under the `/wp/v2/abilities` namespace.
0 commit comments