Edit File by line
/home/zeestwma/ceyloniy.../wp-inclu...
File: abilities-api.php
* wp_unregister_ability_category( 'deprecated-category' );
[500] Fix | Delete
* }
[501] Fix | Delete
*
[502] Fix | Delete
* @since 6.9.0
[503] Fix | Delete
*
[504] Fix | Delete
* @see WP_Ability_Categories_Registry::unregister()
[505] Fix | Delete
* @see wp_register_ability_category()
[506] Fix | Delete
*
[507] Fix | Delete
* @param string $slug The slug of the ability category to unregister.
[508] Fix | Delete
* @return WP_Ability_Category|null The unregistered ability category instance on success, `null` on failure.
[509] Fix | Delete
*/
[510] Fix | Delete
function wp_unregister_ability_category( string $slug ): ?WP_Ability_Category {
[511] Fix | Delete
$registry = WP_Ability_Categories_Registry::get_instance();
[512] Fix | Delete
if ( null === $registry ) {
[513] Fix | Delete
return null;
[514] Fix | Delete
}
[515] Fix | Delete
[516] Fix | Delete
return $registry->unregister( $slug );
[517] Fix | Delete
}
[518] Fix | Delete
[519] Fix | Delete
/**
[520] Fix | Delete
* Checks if an ability category is registered.
[521] Fix | Delete
*
[522] Fix | Delete
* Use this for conditional logic and feature detection before attempting to
[523] Fix | Delete
* retrieve or use an ability category.
[524] Fix | Delete
*
[525] Fix | Delete
* Example:
[526] Fix | Delete
*
[527] Fix | Delete
* // Displays different UI based on available ability categories.
[528] Fix | Delete
* if ( wp_has_ability_category( 'premium-features' ) ) {
[529] Fix | Delete
* echo 'Premium Features Available';
[530] Fix | Delete
* } else {
[531] Fix | Delete
* echo 'Standard Features';
[532] Fix | Delete
* }
[533] Fix | Delete
*
[534] Fix | Delete
* @since 6.9.0
[535] Fix | Delete
*
[536] Fix | Delete
* @see WP_Ability_Categories_Registry::is_registered()
[537] Fix | Delete
* @see wp_get_ability_category()
[538] Fix | Delete
*
[539] Fix | Delete
* @param string $slug The slug of the ability category to check.
[540] Fix | Delete
* @return bool `true` if the ability category is registered, `false` otherwise.
[541] Fix | Delete
*/
[542] Fix | Delete
function wp_has_ability_category( string $slug ): bool {
[543] Fix | Delete
$registry = WP_Ability_Categories_Registry::get_instance();
[544] Fix | Delete
if ( null === $registry ) {
[545] Fix | Delete
return false;
[546] Fix | Delete
}
[547] Fix | Delete
[548] Fix | Delete
return $registry->is_registered( $slug );
[549] Fix | Delete
}
[550] Fix | Delete
[551] Fix | Delete
/**
[552] Fix | Delete
* Retrieves a registered ability category.
[553] Fix | Delete
*
[554] Fix | Delete
* Returns the ability category instance for inspection or use. The instance provides access
[555] Fix | Delete
* to the ability category's configuration and metadata.
[556] Fix | Delete
*
[557] Fix | Delete
* Example:
[558] Fix | Delete
*
[559] Fix | Delete
* // Prints information about a registered ability category.
[560] Fix | Delete
* $ability_category = wp_get_ability_category( 'content-management' );
[561] Fix | Delete
* if ( $ability_category ) {
[562] Fix | Delete
* echo $ability_category->get_label() . ': ' . $ability_category->get_description();
[563] Fix | Delete
* }
[564] Fix | Delete
*
[565] Fix | Delete
* @since 6.9.0
[566] Fix | Delete
*
[567] Fix | Delete
* @see WP_Ability_Categories_Registry::get_registered()
[568] Fix | Delete
* @see wp_has_ability_category()
[569] Fix | Delete
* @see wp_get_ability_categories()
[570] Fix | Delete
*
[571] Fix | Delete
* @param string $slug The slug of the ability category.
[572] Fix | Delete
* @return WP_Ability_Category|null The ability category instance, or `null` if not registered.
[573] Fix | Delete
*/
[574] Fix | Delete
function wp_get_ability_category( string $slug ): ?WP_Ability_Category {
[575] Fix | Delete
$registry = WP_Ability_Categories_Registry::get_instance();
[576] Fix | Delete
if ( null === $registry ) {
[577] Fix | Delete
return null;
[578] Fix | Delete
}
[579] Fix | Delete
[580] Fix | Delete
return $registry->get_registered( $slug );
[581] Fix | Delete
}
[582] Fix | Delete
[583] Fix | Delete
/**
[584] Fix | Delete
* Retrieves all registered ability categories.
[585] Fix | Delete
*
[586] Fix | Delete
* Returns an array of all ability category instances currently registered in the system.
[587] Fix | Delete
* Use this for discovery, debugging, or building administrative interfaces.
[588] Fix | Delete
*
[589] Fix | Delete
* Example:
[590] Fix | Delete
*
[591] Fix | Delete
* // Prints information about all available ability categories.
[592] Fix | Delete
* $ability_categories = wp_get_ability_categories();
[593] Fix | Delete
* foreach ( $ability_categories as $ability_category ) {
[594] Fix | Delete
* echo $ability_category->get_label() . ': ' . $ability_category->get_description() . "\n";
[595] Fix | Delete
* }
[596] Fix | Delete
*
[597] Fix | Delete
* @since 6.9.0
[598] Fix | Delete
*
[599] Fix | Delete
* @see WP_Ability_Categories_Registry::get_all_registered()
[600] Fix | Delete
* @see wp_get_ability_category()
[601] Fix | Delete
*
[602] Fix | Delete
* @return WP_Ability_Category[] An array of registered ability category instances. Returns an empty array
[603] Fix | Delete
* if no ability categories are registered or if the registry is unavailable.
[604] Fix | Delete
*/
[605] Fix | Delete
function wp_get_ability_categories(): array {
[606] Fix | Delete
$registry = WP_Ability_Categories_Registry::get_instance();
[607] Fix | Delete
if ( null === $registry ) {
[608] Fix | Delete
return array();
[609] Fix | Delete
}
[610] Fix | Delete
[611] Fix | Delete
return $registry->get_all_registered();
[612] Fix | Delete
}
[613] Fix | Delete
[614] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function