WP_Ability
- Since
- 6.9.0
- Source
wp-includes/abilities-api/class-wp-ability.php:21
Encapsulates the properties and methods related to a specific ability in the registry.
Compatibility
- WordPress
- since 6.9.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in 3 of the 5 tracked releases, added in 6.9.0.
Hooks and filters fired · 9
Every hook that fires from inside WP_Ability, in the order it appears in the class, grouped by the method that fires it.
WP_Ability::execute()
- do_action( wp_ability_invoked )action line 783
- apply_filters( wp_pre_execute_ability )filter line 809
- do_action( wp_before_execute_ability )action line 852
- do_action( wp_after_execute_ability )action line 875
Properties · 10
$default_annotationsarray<string,protected static- The default ability annotations.
$namestringprotected- The name of the ability, with its namespace.
$labelstringprotected- The human-readable ability label.
$descriptionstringprotected- The detailed ability description.
$categorystringprotected- The ability category.
$input_schemaarray<string,protected- The optional ability input schema.
$output_schemaarray<string,protected- The optional ability output schema.
$execute_callbackcallable(mixed):protected- The ability execute callback.
$permission_callbackcallable(mixed):protected- The optional ability permission callback.
$metaarray<string,protected- The optional ability metadata.
Methods · 19
- __construct()Constructor.
- prepare_properties()Prepares and validates the properties used to instantiate the ability.
- get_name()Retrieves the name of the ability, with its namespace.
- get_label()Retrieves the human-readable label for the ability.
- get_description()Retrieves the detailed description for the ability.
- get_category()Retrieves the ability category for the ability.
- get_input_schema()Retrieves the input schema for the ability.
- get_output_schema()Retrieves the output schema for the ability.
- get_meta()Retrieves the metadata for the ability.
- get_meta_item()Retrieves a specific metadata item for the ability.
- normalize_input()Normalizes the input for the ability, applying the default value from the input schema when needed.
- validate_input()Validates input data against the input schema.
- invoke_callback()Invokes a callable, ensuring the input is passed through only if the input schema is defined.
- check_permissions()Checks whether the ability has the necessary permissions.
- do_execute()Executes the ability callback.
- validate_output()Validates output data against the output schema.
- execute()Executes the ability after input validation and running a permission check.
- __wakeup()Wakeup magic method.
- __sleep()Sleep magic method.
Source code
class WP_Ability { /** * The default value for the `show_in_rest` meta. * * @since 6.9.0 * @var bool */ protected const DEFAULT_SHOW_IN_REST = false; /** * The default value for the `public` meta. * * @since 7.1.0 * @var bool */ protected const DEFAULT_PUBLIC = false; /** * The default ability annotations. * They are not guaranteed to provide a faithful description of ability behavior. * * @since 6.9.0 * @var array<string, bool|null> */ protected static $default_annotations = array( // If true, the ability does not modify its environment. 'readonly' => null, /* * If true, the ability may perform destructive updates to its environment. * If false, the ability performs only additive updates. */ 'destructive' => null, /* * If true, calling the ability repeatedly with the same arguments will have no additional effect * on its environment. */ 'idempotent' => null, ); /** * The name of the ability, with its namespace. * Example: `my-plugin/my-ability`. * * @since 6.9.0 * @var string */ protected $name; /** * The human-readable ability label. * * @since 6.9.0 * @var string */ protected $label; /** * The detailed ability description. * * @since 6.9.0 * @var string */ protected $description; /** * The ability category. * * @since 6.9.0 * @var string */ protected $category; /** * The optional ability input schema. * * @since 6.9.0 * @var array<string, mixed> */ protected $input_schema = array();Changelog
Introduced in 6.9.0. Unchanged from 6.9.7 through 7.1.0.
Signature, return type and hooks compared across 3 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/abilities-api/class-wp-ability.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.