wp_has_ability_category()
Checks if an ability category is registered.
Use this for conditional logic and feature detection before attempting to retrieve or use an ability category.
Example:
// Displays different UI based on available ability categories.
if ( wp_has_ability_category( 'premium-features' ) ) {
echo 'Premium Features Available';
} else {
echo 'Standard Features';
}
No Hooks.
Returns
true|false. true if the ability category is registered, false otherwise.
Usage
wp_has_ability_category( $slug ): bool;
- $slug(string) (required)
- The slug of the ability category to check.
Notes
Changelog
| Since 6.9.0 | Introduced. |
wp_has_ability_category() wp has ability category code WP 6.9.1
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 );
}