wp_has_ability_category()WP 6.9.0

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

Хуков нет.

Возвращает

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

Использование

wp_has_ability_category( $slug ): bool;
$slug(строка) (обязательный)
The slug of the ability category to check.

Заметки

Список изменений

С версии 6.9.0 Введена.

Код wp_has_ability_category() WP 6.9

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