wp_has_ability_category( string $slug ): bool

Checks if an ability category is registered.

Description

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';
}

See also

Parameters

$slugstringrequired
The slug of the ability category to check.

Return

bool true if the ability category is registered, false otherwise.

Source

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 );
}

Changelog

VersionDescription
6.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.