wp_has_ability_category()
Checks whether the specified ability category is registered.
Use it before retrieving or using a category.
Use wp_get_ability_category() to retrieve the registered category.
No Hooks.
Returns
true|false.
true- the category is registered.false- the category is not registered or the registry is unavailable.
Usage
wp_has_ability_category( $slug ): bool;
- $slug(string) (required)
- Slug of the ability category to check.
Examples
#1 Category check before retrieving it
if ( wp_has_ability_category( 'content-management' ) ) {
$category = wp_get_ability_category( 'content-management' );
}Notes
Changelog
| Since 6.9.0 | Introduced. |
wp_has_ability_category() wp has ability category code WP 7.0.4
function wp_has_ability_category( string $slug ): bool {
$registry = WP_Ability_Categories_Registry::get_instance();
if ( null === $registry ) {
return false;
}
return $registry->is_registered( $slug );
}