wp_register_ability_args
云策文档标注
概述
wp_register_ability_args 是一个 WordPress 过滤器钩子,用于在能力参数被验证和实例化之前进行修改。它允许开发者自定义能力注册时的参数数组。
关键要点
- 这是一个过滤器钩子,名称为 wp_register_ability_args。
- 它接收两个参数:$args(能力参数数组)和 $name(能力名称)。
- 参数 $args 包含多个键,如 label、description、category、execute_callback、permission_callback、input_schema、output_schema、meta、ability_class 等。
- 主要用于在 WP_Abilities_Registry::register() 中注册新能力时调整参数。
- 从 WordPress 6.9.0 版本开始引入。
原文内容
Filters the ability arguments before they are validated and used to instantiate the ability.
Parameters
-
mixed> $args { 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 $input_schema Optional. JSON Schema definition for the ability’s input.
@type array $output_schema Optional. JSON Schema definition for the ability’s output.
@type array $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. Default false.
} @type string $ability_class Optional. Custom class to instantiate instead of WP_Ability.
} $namestring-
The name of the ability, with its namespace.
Source
$args = apply_filters( 'wp_register_ability_args', $args, $name );
Changelog
| Version | Description |
|---|---|
| 6.9.0 | Introduced. |