Domain
1 month ago
REST
1 month ago
AbilitiesCategories.php
1 month ago
AbilitiesLoader.php
1 month ago
AbilitiesRegistry.php
1 month ago
AbilitiesRestBridge.php
1 month ago
AbilitiesCategories.php
66 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Abilities Categories class file. |
| 4 | */ |
| 5 | |
| 6 | declare( strict_types=1 ); |
| 7 | |
| 8 | namespace Automattic\WooCommerce\Internal\Abilities; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | /** |
| 13 | * Abilities Categories class for WooCommerce. |
| 14 | * |
| 15 | * Registers categories for WooCommerce abilities to improve organization |
| 16 | * and discoverability in the WordPress Abilities API v0.3.0+. |
| 17 | */ |
| 18 | class AbilitiesCategories { |
| 19 | |
| 20 | /** |
| 21 | * Initialize category registration. |
| 22 | * |
| 23 | * @internal |
| 24 | */ |
| 25 | final public static function init(): void { |
| 26 | /* |
| 27 | * Register categories when Abilities API categories are ready. |
| 28 | * Support both old (pre-6.9) and new (6.9+) action names. |
| 29 | */ |
| 30 | add_action( 'abilities_api_categories_init', array( __CLASS__, 'register_categories' ) ); |
| 31 | add_action( 'wp_abilities_api_categories_init', array( __CLASS__, 'register_categories' ) ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Register WooCommerce ability categories. |
| 36 | * |
| 37 | * @since 10.9.0 |
| 38 | */ |
| 39 | public static function register_categories(): void { |
| 40 | // Only register if the function exists. |
| 41 | if ( ! function_exists( 'wp_register_ability_category' ) ) { |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | if ( ! function_exists( 'wp_has_ability_category' ) || ! wp_has_ability_category( 'woocommerce' ) ) { |
| 46 | wp_register_ability_category( |
| 47 | 'woocommerce', |
| 48 | array( |
| 49 | 'label' => __( 'WooCommerce', 'woocommerce' ), |
| 50 | 'description' => __( 'Abilities for WooCommerce store operations, including core commerce features and extension-provided capabilities.', 'woocommerce' ), |
| 51 | ) |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | if ( ! function_exists( 'wp_has_ability_category' ) || ! wp_has_ability_category( 'woocommerce-rest' ) ) { |
| 56 | wp_register_ability_category( |
| 57 | 'woocommerce-rest', |
| 58 | array( |
| 59 | 'label' => __( 'WooCommerce REST API', 'woocommerce' ), |
| 60 | 'description' => __( 'REST API operations for store resources including products, orders, and other store data.', 'woocommerce' ), |
| 61 | ) |
| 62 | ); |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 |