Utility method to retrieve the main instance of the registry class.
Description
The instance will be created if it does not exist yet.
Source
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;
}
Hooks
- do_action( ‘wp_abilities_api_categories_init’,
WP_Ability_Categories_Registry $instance ) Fires when preparing ability categories registry.
Changelog
| Version | Description |
|---|---|
| 6.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.