Ability categories provide a way to organize and group related abilities for better discoverability and management. Ability categories must be registered before abilities that reference them. Ability categories must be registered on the wp_abilities_api_categories_init action hook. Example: function my_plugin_register_categories() {
wp_register_ability_category(
'content-management',
array(
'label' => __( 'Content Management', 'my-plugin' ),
'description' => __( 'Abilities for managing and organizing content.', 'my-plugin' ),
)
);
}
add_action( 'wp_abilities_api_categories_init', 'my_plugin_register_categories' );
Parameters
$slugstring
The unique slug for the ability category. Must contain only lowercase alphanumeric characters and dashes (e.g., 'data-export').
$argsarray
Return
WP_Ability_Category|null
The registered ability category instance on success, null on failure.
Uses · 5
doing_action()Returns whether or not an action hook is currently being processed.
645functionwp_register_ability_category(string$slug,array$args):?WP_Ability_Category{646if(!doing_action('wp_abilities_api_categories_init')){647_doing_it_wrong(648__FUNCTION__,649sprintf(650/* translators: 1: wp_abilities_api_categories_init, 2: ability category slug. */651__('Ability categories must be registered on the %1$s action. The ability category %2$s was not registered.'),652'<code>wp_abilities_api_categories_init</code>',653'<code>'.esc_html($slug).'</code>'654),655'6.9.0'656);657returnnull;658}659660$registry=WP_Ability_Categories_Registry::get_instance();661if(null===$registry){662returnnull;663}664665return$registry->register($slug,$args);666}
History
Introduced in 6.9.0. Unchanged from 6.9.7 through 7.1.0.
Signature, return type and hooks compared across 3 parsed releases.
About this page
Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/abilities-api.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.