wp_get_ability()
Retrieves a registered ability.
Returns the ability instance for inspection or use. The instance provides access to the ability's configuration, metadata, and execution methods.
Example:
// Prints information about a registered ability.
$ability = wp_get_ability( 'my-plugin/export-data' );
if ( $ability ) {
echo $ability->get_label() . ': ' . $ability->get_description();
}
No Hooks.
Returns
WP_Ability|null. The registered ability instance, or null if not registered.
Usage
wp_get_ability( $name ): ?WP_Ability;
- $name(string) (required)
- The name of the ability, including namespace prefix (e.g., 'my-plugin/my-ability').
Notes
Changelog
| Since 6.9.0 | Introduced. |
wp_get_ability() wp get ability code WP 7.0
function wp_get_ability( string $name ): ?WP_Ability {
$registry = WP_Abilities_Registry::get_instance();
if ( null === $registry ) {
return null;
}
return $registry->get_registered( $name );
}