wp_register_ability_args filter-hookWP 6.9.0

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 {
```php
An associative array of arguments for the ability.
@type string               $label                 The human-readable label for the ability.
@type string               $description           A detailed description of what the ability does.
@type string               $category              The ability category slug this ability belongs to.
@type callable             $execute_callback      A callback function to execute when the ability is invoked.
												  Receives optional mixed input and returns mixed result or WP_Error.
@type callable             $permission_callback   A callback function to check permissions before execution.
												  Receives optional mixed input and returns bool or WP_Error.
@type array<string, mixed> $input_schema          Optional. JSON Schema definition for the ability's input.
@type array<string, mixed> $output_schema         Optional. JSON Schema definition for the ability's output.
@type array<string, mixed> $meta                  {
	Optional. Additional metadata for the ability.

@type array<string, bool|string> $annotations Optional. Annotation metadata for the ability. @type bool $show_in_rest Optional. Whether to expose this ability in the REST API.

}
@type string               $ability_class         Optional. Custom class to instantiate instead of WP_Ability.

}

  • @param string $name The name of the ability, with its namespace.
  • @return array<string,
    */
    function wp_kama_register_ability_args_filter( $args, $name ){

    // filter...
    return $args;
    }

    
    
$args(array<string,)
mixed> $args {
php An associative array of arguments for the ability.
@type string               $label                 The human-readable label for the ability.
@type string               $description           A detailed description of what the ability does.
@type string               $category              The ability category slug this ability belongs to.
@type callable             $execute_callback      A callback function to execute when the ability is invoked.
												  Receives optional mixed input and returns mixed result or WP_Error.
@type callable             $permission_callback   A callback function to check permissions before execution.
												  Receives optional mixed input and returns bool or WP_Error.
@type array<string, mixed> $input_schema          Optional. JSON Schema definition for the ability's input.
@type array<string, mixed> $output_schema         Optional. JSON Schema definition for the ability's output.
@type array<string, mixed> $meta                  {
	Optional. Additional metadata for the ability.

@type array<string, bool|string> $annotations Optional. Annotation metadata for the ability. @type bool $show_in_rest Optional. Whether to expose this ability in the REST API.

}
@type string               $ability_class         Optional. Custom class to instantiate instead of WP_Ability.

}
Default: false

$name(string)
The name of the ability, with its namespace.

Changelog

Since 6.9.0 Introduced.

Where the hook is called

WP_Abilities_Registry::register()
wp_register_ability_args
wp-includes/abilities-api/class-wp-abilities-registry.php 129
$args = apply_filters( 'wp_register_ability_args', $args, $name );

Where the hook is used in WordPress

Usage not found.