entity type, category (null keeps the core's), and whether * `id` names the target. The plural `products-*` / `orders-*` writes and * reads are the REST-derived abilities of 10.9 to 11.2; 11.3 removed them. * * @var array */ private const MAP = array( 'woocommerce/order-add-note' => array( 'order_note', 'create', true ), 'woocommerce/order-update-status' => array( 'order', 'update', true ), 'woocommerce/orders-create' => array( 'order', 'create', false ), 'woocommerce/orders-update' => array( 'order', 'update', true ), 'woocommerce/orders-get' => array( 'order', null, true ), 'woocommerce/orders-list' => array( 'order', null, false ), 'woocommerce/orders-query' => array( 'order', null, false ), 'woocommerce/order-notes-query' => array( 'order_note', null, false ), 'woocommerce/product-create' => array( 'product', 'create', false ), 'woocommerce/products-create' => array( 'product', 'create', false ), 'woocommerce/product-update' => array( 'product', 'update', true ), 'woocommerce/products-update' => array( 'product', 'update', true ), 'woocommerce/product-delete' => array( 'product', 'delete', true ), 'woocommerce/products-delete' => array( 'product', 'delete', true ), 'woocommerce/products-get' => array( 'product', null, true ), 'woocommerce/products-list' => array( 'product', null, false ), 'woocommerce/products-query' => array( 'product', null, false ), ); /** * Classify an ability or MCP action, or leave it to the core. * * @param ActionDescriptor $action The core's descriptor. */ public function __invoke( ActionDescriptor $action ): ?Classification { if ( null === $action->ability_name || ! isset( self::MAP[ $action->ability_name ] ) ) { return null; } list( $entity_type, $category, $targets ) = self::MAP[ $action->ability_name ]; $entity_id = $targets ? WcBatchExpander::id( $action->input['id'] ?? null ) : null; // A note to the customer is an email; a forced delete skips the trash. $customer = 'order_note' === $entity_type && 'create' === $category && WcRouteClassifier::truthy( $action->input['customer_note'] ?? null ); $permanent = 'delete' === $category && WcRouteClassifier::truthy( $action->input['force'] ?? null ); return new Classification( $entity_type, $category, $entity_id, $customer || $permanent ? true : null ); } }