| @@ 34-93 (lines=60) @@ | ||
| 31 | /** |
|
| 32 | * Register the routes for terms. |
|
| 33 | */ |
|
| 34 | public function register_routes() { |
|
| 35 | register_rest_route( $this->namespace, '/' . $this->rest_base, array( |
|
| 36 | array( |
|
| 37 | 'methods' => WP_REST_Server::READABLE, |
|
| 38 | 'callback' => array( $this, 'get_items' ), |
|
| 39 | 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 40 | 'args' => $this->get_collection_params(), |
|
| 41 | ), |
|
| 42 | array( |
|
| 43 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 44 | 'callback' => array( $this, 'create_item' ), |
|
| 45 | 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 46 | 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( |
|
| 47 | 'name' => array( |
|
| 48 | 'required' => true, |
|
| 49 | ), |
|
| 50 | ) ), |
|
| 51 | ), |
|
| 52 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 53 | )); |
|
| 54 | ||
| 55 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( |
|
| 56 | array( |
|
| 57 | 'methods' => WP_REST_Server::READABLE, |
|
| 58 | 'callback' => array( $this, 'get_item' ), |
|
| 59 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 60 | 'args' => array( |
|
| 61 | 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 62 | ), |
|
| 63 | ), |
|
| 64 | array( |
|
| 65 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 66 | 'callback' => array( $this, 'update_item' ), |
|
| 67 | 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 68 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 69 | ), |
|
| 70 | array( |
|
| 71 | 'methods' => WP_REST_Server::DELETABLE, |
|
| 72 | 'callback' => array( $this, 'delete_item' ), |
|
| 73 | 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 74 | 'args' => array( |
|
| 75 | 'force' => array( |
|
| 76 | 'default' => false, |
|
| 77 | 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), |
|
| 78 | ), |
|
| 79 | ), |
|
| 80 | ), |
|
| 81 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 82 | ) ); |
|
| 83 | ||
| 84 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( |
|
| 85 | array( |
|
| 86 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 87 | 'callback' => array( $this, 'batch_items' ), |
|
| 88 | 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 89 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 90 | ), |
|
| 91 | 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 92 | ) ); |
|
| 93 | } |
|
| 94 | ||
| 95 | /** |
|
| 96 | * Check if a given request has access to read the terms. |
|
| @@ 56-115 (lines=60) @@ | ||
| 53 | /** |
|
| 54 | * Register the routes for coupons. |
|
| 55 | */ |
|
| 56 | public function register_routes() { |
|
| 57 | register_rest_route( $this->namespace, '/' . $this->rest_base, array( |
|
| 58 | array( |
|
| 59 | 'methods' => WP_REST_Server::READABLE, |
|
| 60 | 'callback' => array( $this, 'get_items' ), |
|
| 61 | 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 62 | 'args' => $this->get_collection_params(), |
|
| 63 | ), |
|
| 64 | array( |
|
| 65 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 66 | 'callback' => array( $this, 'create_item' ), |
|
| 67 | 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 68 | 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( |
|
| 69 | 'code' => array( |
|
| 70 | 'required' => true, |
|
| 71 | ), |
|
| 72 | ) ), |
|
| 73 | ), |
|
| 74 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 75 | ) ); |
|
| 76 | ||
| 77 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( |
|
| 78 | array( |
|
| 79 | 'methods' => WP_REST_Server::READABLE, |
|
| 80 | 'callback' => array( $this, 'get_item' ), |
|
| 81 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 82 | 'args' => array( |
|
| 83 | 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 84 | ), |
|
| 85 | ), |
|
| 86 | array( |
|
| 87 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 88 | 'callback' => array( $this, 'update_item' ), |
|
| 89 | 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 90 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 91 | ), |
|
| 92 | array( |
|
| 93 | 'methods' => WP_REST_Server::DELETABLE, |
|
| 94 | 'callback' => array( $this, 'delete_item' ), |
|
| 95 | 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 96 | 'args' => array( |
|
| 97 | 'force' => array( |
|
| 98 | 'default' => false, |
|
| 99 | 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), |
|
| 100 | ), |
|
| 101 | ), |
|
| 102 | ), |
|
| 103 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 104 | ) ); |
|
| 105 | ||
| 106 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( |
|
| 107 | array( |
|
| 108 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 109 | 'callback' => array( $this, 'batch_items' ), |
|
| 110 | 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 111 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 112 | ), |
|
| 113 | 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 114 | ) ); |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * Query args. |
|
| @@ 62-118 (lines=57) @@ | ||
| 59 | /** |
|
| 60 | * Register the routes for orders. |
|
| 61 | */ |
|
| 62 | public function register_routes() { |
|
| 63 | register_rest_route( $this->namespace, '/' . $this->rest_base, array( |
|
| 64 | array( |
|
| 65 | 'methods' => WP_REST_Server::READABLE, |
|
| 66 | 'callback' => array( $this, 'get_items' ), |
|
| 67 | 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 68 | 'args' => $this->get_collection_params(), |
|
| 69 | ), |
|
| 70 | array( |
|
| 71 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 72 | 'callback' => array( $this, 'create_item' ), |
|
| 73 | 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 74 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), |
|
| 75 | ), |
|
| 76 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 77 | ) ); |
|
| 78 | ||
| 79 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( |
|
| 80 | array( |
|
| 81 | 'methods' => WP_REST_Server::READABLE, |
|
| 82 | 'callback' => array( $this, 'get_item' ), |
|
| 83 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 84 | 'args' => array( |
|
| 85 | 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 86 | ), |
|
| 87 | ), |
|
| 88 | array( |
|
| 89 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 90 | 'callback' => array( $this, 'update_item' ), |
|
| 91 | 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 92 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 93 | ), |
|
| 94 | array( |
|
| 95 | 'methods' => WP_REST_Server::DELETABLE, |
|
| 96 | 'callback' => array( $this, 'delete_item' ), |
|
| 97 | 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 98 | 'args' => array( |
|
| 99 | 'force' => array( |
|
| 100 | 'default' => false, |
|
| 101 | 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), |
|
| 102 | ), |
|
| 103 | 'reassign' => array(), |
|
| 104 | ), |
|
| 105 | ), |
|
| 106 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 107 | ) ); |
|
| 108 | ||
| 109 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( |
|
| 110 | array( |
|
| 111 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 112 | 'callback' => array( $this, 'batch_items' ), |
|
| 113 | 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 114 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 115 | ), |
|
| 116 | 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 117 | ) ); |
|
| 118 | } |
|
| 119 | ||
| 120 | /** |
|
| 121 | * Expands an order item to get its data. |
|
| @@ 49-108 (lines=60) @@ | ||
| 46 | /** |
|
| 47 | * Register the routes for product attributes. |
|
| 48 | */ |
|
| 49 | public function register_routes() { |
|
| 50 | register_rest_route( $this->namespace, '/' . $this->rest_base, array( |
|
| 51 | array( |
|
| 52 | 'methods' => WP_REST_Server::READABLE, |
|
| 53 | 'callback' => array( $this, 'get_items' ), |
|
| 54 | 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 55 | 'args' => $this->get_collection_params(), |
|
| 56 | ), |
|
| 57 | array( |
|
| 58 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 59 | 'callback' => array( $this, 'create_item' ), |
|
| 60 | 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 61 | 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( |
|
| 62 | 'name' => array( |
|
| 63 | 'required' => true, |
|
| 64 | ), |
|
| 65 | ) ), |
|
| 66 | ), |
|
| 67 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 68 | )); |
|
| 69 | ||
| 70 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( |
|
| 71 | array( |
|
| 72 | 'methods' => WP_REST_Server::READABLE, |
|
| 73 | 'callback' => array( $this, 'get_item' ), |
|
| 74 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 75 | 'args' => array( |
|
| 76 | 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 77 | ), |
|
| 78 | ), |
|
| 79 | array( |
|
| 80 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 81 | 'callback' => array( $this, 'update_item' ), |
|
| 82 | 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 83 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 84 | ), |
|
| 85 | array( |
|
| 86 | 'methods' => WP_REST_Server::DELETABLE, |
|
| 87 | 'callback' => array( $this, 'delete_item' ), |
|
| 88 | 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 89 | 'args' => array( |
|
| 90 | 'force' => array( |
|
| 91 | 'default' => false, |
|
| 92 | 'description' => __( 'Required to be true, as resource does not support trashing.', 'woocommerce' ), |
|
| 93 | ), |
|
| 94 | ), |
|
| 95 | ), |
|
| 96 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 97 | ) ); |
|
| 98 | ||
| 99 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( |
|
| 100 | array( |
|
| 101 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 102 | 'callback' => array( $this, 'batch_items' ), |
|
| 103 | 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 104 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 105 | ), |
|
| 106 | 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 107 | ) ); |
|
| 108 | } |
|
| 109 | ||
| 110 | /** |
|
| 111 | * Check if a given request has access to read the attributes. |
|
| @@ 57-113 (lines=57) @@ | ||
| 54 | /** |
|
| 55 | * Register the routes for products. |
|
| 56 | */ |
|
| 57 | public function register_routes() { |
|
| 58 | register_rest_route( $this->namespace, '/' . $this->rest_base, array( |
|
| 59 | array( |
|
| 60 | 'methods' => WP_REST_Server::READABLE, |
|
| 61 | 'callback' => array( $this, 'get_items' ), |
|
| 62 | 'permission_callback' => array( $this, 'get_items_permissions_check' ), |
|
| 63 | 'args' => $this->get_collection_params(), |
|
| 64 | ), |
|
| 65 | array( |
|
| 66 | 'methods' => WP_REST_Server::CREATABLE, |
|
| 67 | 'callback' => array( $this, 'create_item' ), |
|
| 68 | 'permission_callback' => array( $this, 'create_item_permissions_check' ), |
|
| 69 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), |
|
| 70 | ), |
|
| 71 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 72 | ) ); |
|
| 73 | ||
| 74 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( |
|
| 75 | array( |
|
| 76 | 'methods' => WP_REST_Server::READABLE, |
|
| 77 | 'callback' => array( $this, 'get_item' ), |
|
| 78 | 'permission_callback' => array( $this, 'get_item_permissions_check' ), |
|
| 79 | 'args' => array( |
|
| 80 | 'context' => $this->get_context_param( array( 'default' => 'view' ) ), |
|
| 81 | ), |
|
| 82 | ), |
|
| 83 | array( |
|
| 84 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 85 | 'callback' => array( $this, 'update_item' ), |
|
| 86 | 'permission_callback' => array( $this, 'update_item_permissions_check' ), |
|
| 87 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 88 | ), |
|
| 89 | array( |
|
| 90 | 'methods' => WP_REST_Server::DELETABLE, |
|
| 91 | 'callback' => array( $this, 'delete_item' ), |
|
| 92 | 'permission_callback' => array( $this, 'delete_item_permissions_check' ), |
|
| 93 | 'args' => array( |
|
| 94 | 'force' => array( |
|
| 95 | 'default' => false, |
|
| 96 | 'description' => __( 'Whether to bypass trash and force deletion.', 'woocommerce' ), |
|
| 97 | ), |
|
| 98 | 'reassign' => array(), |
|
| 99 | ), |
|
| 100 | ), |
|
| 101 | 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 102 | ) ); |
|
| 103 | ||
| 104 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/batch', array( |
|
| 105 | array( |
|
| 106 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 107 | 'callback' => array( $this, 'batch_items' ), |
|
| 108 | 'permission_callback' => array( $this, 'batch_items_permissions_check' ), |
|
| 109 | 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), |
|
| 110 | ), |
|
| 111 | 'schema' => array( $this, 'get_public_batch_schema' ), |
|
| 112 | ) ); |
|
| 113 | } |
|
| 114 | ||
| 115 | /** |
|
| 116 | * Get post types. |
|