REST
6 months ago
AbilitiesCategories.php
6 months ago
AbilitiesRegistry.php
6 months ago
AbilitiesRestBridge.php
6 months ago
AbilitiesCategories.php
52 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 | public static function register_categories(): void { |
| 38 | // Only register if the function exists. |
| 39 | if ( ! function_exists( 'wp_register_ability_category' ) ) { |
| 40 | return; |
| 41 | } |
| 42 | |
| 43 | wp_register_ability_category( |
| 44 | 'woocommerce-rest', |
| 45 | array( |
| 46 | 'label' => __( 'WooCommerce REST API', 'woocommerce' ), |
| 47 | 'description' => __( 'REST API operations for WooCommerce resources including products, orders, and other store data.', 'woocommerce' ), |
| 48 | ) |
| 49 | ); |
| 50 | } |
| 51 | } |
| 52 |