wppaste
WordPress

WP_Ability_Categories_Registry

Since
6.9.0
Source
wp-includes/abilities-api/class-wp-ability-categories-registry.php:20
Manages the registration and lookup of ability categories.

Compatibility

WordPress
since 6.9.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 3 of the 5 tracked releases, added in 6.9.0.

Hooks and filters fired · 2

Every hook that fires from inside WP_Ability_Categories_Registry, in the order it appears in the class, grouped by the method that fires it.

Properties · 2

$instanceself|nullprivate static
The singleton instance of the registry.
$registered_categoriesWP_Ability_Category[]private
Holds the registered ability categories.

Methods · 8

Source code

final class WP_Ability_Categories_Registry {	/**	 * The singleton instance of the registry.	 *	 * @since 6.9.0	 * @var self|null	 */	private static $instance = null; 	/**	 * Holds the registered ability categories.	 *	 * @since 6.9.0	 * @var WP_Ability_Category[]	 */	private $registered_categories = array(); 	/**	 * Registers a new ability category.	 *	 * Do not use this method directly. Instead, use the `wp_register_ability_category()` function.	 *	 * @since 6.9.0	 *	 * @see wp_register_ability_category()	 *	 * @param string               $slug The unique slug for the ability category. Must contain only lowercase	 *                                   alphanumeric characters and dashes.	 * @param array<string, mixed> $args {	 *     An associative array of arguments for the ability category.	 *	 *     @type string               $label       The human-readable label for the ability category.	 *     @type string               $description A description of the ability category.	 *     @type array<string, mixed> $meta        Optional. Additional metadata for the ability category.	 * }	 * @return WP_Ability_Category|null The registered ability category instance on success, null on failure.	 */	public function register( string $slug, array $args ): ?WP_Ability_Category {		if ( $this->is_registered( $slug ) ) {			_doing_it_wrong(				__METHOD__,				/* translators: %s: Ability category slug. */				sprintf( __( 'Ability category "%s" is already registered.' ), esc_html( $slug ) ),				'6.9.0'			);			return null;		} 		if ( ! preg_match( '/^[a-z0-9]+(?:-[a-z0-9]+)*$/', $slug ) ) {			_doing_it_wrong(				__METHOD__,				__( 'Ability category slug must contain only lowercase alphanumeric characters and dashes.' ),				'6.9.0'			);			return null;		} 		/**		 * Filters the ability category arguments before they are validated and used to instantiate the ability category.		 *		 * @since 6.9.0		 *		 * @param array<string, mixed> $args {		 *     The arguments used to instantiate the ability category.		 *		 *     @type string               $label       The human-readable label for the ability category.		 *     @type string               $description A description of the ability category.		 *     @type array<string, mixed> $meta        Optional. Additional metadata for the ability category.		 * }		 * @param string               $slug The slug of the ability category.		 */		$args = apply_filters( 'wp_register_ability_category_args', $args, $slug ); 		try {			// WP_Ability_Category::prepare_properties() will throw an exception if the properties are invalid.			$category = new WP_Ability_Category( $slug, $args );		} catch ( InvalidArgumentException $e ) {			_doing_it_wrong(				__METHOD__,				$e->getMessage(),

Changelog

Introduced in 6.9.0. Unchanged from 6.9.7 through 7.1.0.

  1. 6.9.7
  2. 7.0.4
  3. 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/class-wp-ability-categories-registry.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.