registry = $registry; } /** * Register hooks for both Abilities API variants. */ public function setup(): void { add_action( 'wp_abilities_api_categories_init', array( $this, 'register_categories' ) ); add_action( 'wp_abilities_api_init', array( $this, 'register_tools' ) ); add_action( 'abilities_api_init', array( $this, 'register_tools' ) ); } /** * Register ability categories required by our tools. * * The wp_register_ability_category() function is a WP 6.9+ core function. On WP 6.8 the * Abilities API is loaded as a standalone package that provides the same * function. The function_exists() guard ensures graceful degradation when * neither source is available. */ public function register_categories(): void { if ( ! function_exists( 'wp_register_ability_category' ) ) { return; } wp_register_ability_category( 'site-management', array( 'label' => __( 'Site Management', 'airo-wp' ), 'description' => __( 'Abilities for managing the WordPress site.', 'airo-wp' ), ) ); wp_register_ability_category( 'plugin-management', array( 'label' => __( 'Plugin Management', 'airo-wp' ), 'description' => __( 'Abilities for managing WordPress plugins.', 'airo-wp' ), ) ); wp_register_ability_category( 'theme-management', array( 'label' => __( 'Theme Management', 'airo-wp' ), 'description' => __( 'Abilities for managing WordPress themes.', 'airo-wp' ), ) ); wp_register_ability_category( 'content-management', array( 'label' => __( 'Content Management', 'airo-wp' ), 'description' => __( 'Abilities for managing WordPress content.', 'airo-wp' ), ) ); wp_register_ability_category( 'media-management', array( 'label' => __( 'Media Management', 'airo-wp' ), 'description' => __( 'Abilities for managing WordPress media.', 'airo-wp' ), ) ); } /** * Call register() on each tool. */ public function register_tools(): void { foreach ( $this->registry->all() as $tool ) { $tool->register(); } } }