wp_register_ability_args
Filters the ability arguments before they are validated and used to instantiate the ability.
Usage
add_filter( 'wp_register_ability_args', 'wp_kama_register_ability_args_filter', 10, 2 ); /** * Function for `wp_register_ability_args` filter-hook. * * @param array$args An associative array of arguments for the ability. * @param string $name The name of the ability, with its namespace. * * @return array */ function wp_kama_register_ability_args_filter( $args, $name ){ // filter... return $args; }
- $args(array<string, mixed>)
An associative array of arguments for the ability.
-
label(string)
The human-readable label for the ability. -
description(string)
A detailed description of what the ability does. -
category(string)
The ability category slug this ability belongs to. -
execute_callback(callable)
A callback function to execute when the ability is invoked. Receives optional mixed input and returns mixed result or WP_Error. -
permission_callback(callable)
A callback function to check permissions before execution. Receives optional mixed input and returns bool or WP_Error. -
mixed>(array<string,)
$meta {Optional. Additional metadata for the ability.
@type array<string, bool|string> $annotations Optional. Annotation metadata for the ability. @type bool $public Optional. Whether the ability is meant to be available to clients such as the REST API, MCP, or AI agents. Seeds the default for per-channel flags like `$show_in_rest`. @type bool $show_in_rest Optional. Whether to expose this ability in the REST API. Default is the value of `$public` when set, false otherwise.
}
Default: false - ability_class(string)
Optional. Custom class to instantiate instead of WP_Ability.
-
- $name(string)
- The name of the ability, with its namespace.
Changelog
| Since 6.9.0 | Introduced. |
Where the hook is called
wp_register_ability_args
wp-includes/abilities-api/class-wp-abilities-registry.php 139
$args = apply_filters( 'wp_register_ability_args', $args, $name );