wp_unregister_ability_category()WP 6.9.0

Removes a registered ability category from the global registry.

It can be called at any time after registration. If the category is not found, the function triggers an _doing_it_wrong() notice and returns null.

No Hooks.

Returns

WP_Ability_Category|null.

  • WP_Ability_Category - the removed category.
  • null - if the category is not registered or the registry is unavailable.

Usage

wp_unregister_ability_category( $slug ): ?WP_Ability_Category;
$slug(string) (required)
Slug of the category to remove.

Examples

#1 Deleting the ability category

function my_plugin_unregister_ability_category(): void {
	if ( wp_has_ability_category( 'deprecated-category' ) ) {
		wp_unregister_ability_category( 'deprecated-category' );
	}
}

add_action(
	'wp_abilities_api_categories_init',
	'my_plugin_unregister_ability_category',
	20
);

Notes

Changelog

Since 6.9.0 Introduced.

wp_unregister_ability_category() code WP 7.0.4

function wp_unregister_ability_category( string $slug ): ?WP_Ability_Category {
	$registry = WP_Ability_Categories_Registry::get_instance();
	if ( null === $registry ) {
		return null;
	}

	return $registry->unregister( $slug );
}