| | 13 | ## Public Functions |
| | 14 | |
| | 15 | ### Ability Management |
| | 16 | - `wp_register_ability( string $name, array $args ): ?WP_Ability` - Registers a new ability (must be called on `wp_abilities_api_init` hook) |
| | 17 | - `wp_unregister_ability( string $name ): ?WP_Ability` - Unregisters an ability |
| | 18 | - `wp_has_ability( string $name ): bool` - Checks if an ability is registered |
| | 19 | - `wp_get_ability( string $name ): ?WP_Ability` - Retrieves a registered ability |
| | 20 | - `wp_get_abilities(): array` - Retrieves all registered abilities |
| | 21 | |
| | 22 | ### Ability Category Management |
| | 23 | - `wp_register_ability_category( string $slug, array $args ): ?WP_Ability_Category` - Registers an ability category (must be called on `wp_abilities_api_categories_init` hook) |
| | 24 | - `wp_unregister_ability_category( string $slug ): ?WP_Ability_Category` - Unregisters an ability category |
| | 25 | - `wp_has_ability_category( string $slug ): bool` - Checks if an ability category is registered |
| | 26 | - `wp_get_ability_category( string $slug ): ?WP_Ability_Category` - Retrieves a registered ability category |
| | 27 | - `wp_get_ability_categories(): array` - Retrieves all registered ability categories |
| | 28 | |
| | 29 | ## Public Classes |
| | 30 | |
| | 31 | - `WP_Ability` - Encapsulates ability properties and methods (execute, check_permission, validate_input, etc.) |
| | 32 | - `WP_Ability_Category` - Encapsulates ability category properties |
| | 33 | - `WP_Abilities_Registry` - Manages ability registration and lookup (private, accessed via functions) |
| | 34 | - `WP_Ability_Categories_Registry` - Manages ability category registration (private, accessed via functions) |
| | 35 | - `WP_REST_Abilities_V1_Categories_Controller` - REST controller for listing category abilities |
| | 36 | - `WP_REST_Abilities_V1_List_Controller` - REST controller for listing abilities |
| | 37 | - `WP_REST_Abilities_V1_Run_Controller` - REST controller for executing abilities |
| | 38 | |
| | 39 | ## REST API Endpoints |
| | 40 | |
| | 41 | ### Namespace: `wp-abilities/v1` |
| | 42 | |
| | 43 | #### List Category Abilities |
| | 44 | - `GET /wp-abilities/v1/categories` - Retrieve all registered ability categories |
| | 45 | - Query parameters: `page`, `per_page` |
| | 46 | |
| | 47 | #### Get Single Category Ability |
| | 48 | - `GET /wp-abilities/v1/categories/(?P<slug>[a-z0-9]+(?:-[a-z0-9]+)*)` - Retrieve a specific ability category by name |
| | 49 | |
| | 50 | #### List Abilities |
| | 51 | - `GET /wp-abilities/v1/abilities` - Retrieve all registered abilities |
| | 52 | - Query parameters: `page`, `per_page`, `category` |
| | 53 | |
| | 54 | #### Get Single Ability |
| | 55 | - `GET /wp-abilities/v1/abilities/(?P<name>[a-zA-Z0-9\-\/]+)` - Retrieve a specific ability by name |
| | 56 | |
| | 57 | #### Execute Ability |
| | 58 | - `GET|POST|DELETE /wp-abilities/v1/abilities/(?P<name>[a-zA-Z0-9\-\/]+)/run` - Execute an ability |
| | 59 | - Supports multiple HTTP methods based on ability annotations |
| | 60 | - Validates input against ability's input schema |
| | 61 | - Validates output against ability's output schema |
| | 62 | - Performs permission checks via ability's permission callback |
| | 63 | |
| | 64 | ## Hooks |
| | 65 | |
| | 66 | ### Actions |
| | 67 | - `wp_abilities_api_categories_init` - Fired when ability categories registry is initialized (register categories here) |
| | 68 | - `wp_abilities_api_init` - Fired when abilities registry is initialized (register abilities here) |
| | 69 | - `wp_before_execute_ability` - Fired before an ability gets executed, after input validation and permissions check |
| | 70 | |
| | 71 | - `wp_after_execute_ability` - Fires immediately after an ability finished executing |
| | 72 | |
| | 73 | ### Filters |
| | 74 | - `wp_register_ability_category_args` - Filters ability category arguments before registration |
| | 75 | - `wp_register_ability_args` - Filters ability arguments before registration |
| | 76 | |