WP_Ability_Categories_Registry::get_instancepublic staticWP 6.9.0

Utility method to retrieve the main instance of the registry class.

The instance will be created if it does not exist yet.

Method of the class: WP_Ability_Categories_Registry{}

Hooks from the method

Returns

WP_Ability_Categories_Registry|null. The main registry instance, or null when init action has not fired.

Usage

$result = WP_Ability_Categories_Registry::get_instance(): ?self;

Changelog

Since 6.9.0 Introduced.

WP_Ability_Categories_Registry::get_instance() code WP 7.0

public static function get_instance(): ?self {
	if ( ! did_action( 'init' ) ) {
		_doing_it_wrong(
			__METHOD__,
			sprintf(
				// translators: %s: init action.
				__( 'Ability API should not be initialized before the %s action has fired.' ),
				'<code>init</code>'
			),
			'6.9.0'
		);
		return null;
	}

	if ( null === self::$instance ) {
		self::$instance = new self();

		/**
		 * Fires when preparing ability categories registry.
		 *
		 * Ability categories should be registered on this action to ensure they're available when needed.
		 *
		 * @since 6.9.0
		 *
		 * @param WP_Ability_Categories_Registry $instance Ability categories registry object.
		 */
		do_action( 'wp_abilities_api_categories_init', self::$instance );
	}

	return self::$instance;
}