| @@ 67-73 (lines=7) @@ | ||
| 64 | * @param WP_REST_Request $request Full details about the request. |
|
| 65 | * @return WP_Error|boolean |
|
| 66 | */ |
|
| 67 | public function get_items_permissions_check( $request ) { |
|
| 68 | if ( ! wc_rest_check_manager_permissions( 'reports', 'read' ) ) { |
|
| 69 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 70 | } |
|
| 71 | ||
| 72 | return true; |
|
| 73 | } |
|
| 74 | ||
| 75 | /** |
|
| 76 | * Get sales reports. |
|
| @@ 60-66 (lines=7) @@ | ||
| 57 | * @param WP_REST_Request $request Full details about the request. |
|
| 58 | * @return WP_Error|boolean |
|
| 59 | */ |
|
| 60 | public function get_items_permissions_check( $request ) { |
|
| 61 | if ( ! wc_rest_check_manager_permissions( 'reports', 'read' ) ) { |
|
| 62 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 63 | } |
|
| 64 | ||
| 65 | return true; |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * Get all reports. |
|
| @@ 81-87 (lines=7) @@ | ||
| 78 | * @param WP_REST_Request $request Full details about the request. |
|
| 79 | * @return WP_Error|boolean |
|
| 80 | */ |
|
| 81 | public function get_items_permissions_check( $request ) { |
|
| 82 | if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) { |
|
| 83 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 84 | } |
|
| 85 | ||
| 86 | return true; |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| 90 | * Check if a given request has access create tax classes. |
|
| @@ 95-101 (lines=7) @@ | ||
| 92 | * @param WP_REST_Request $request Full details about the request. |
|
| 93 | * @return boolean |
|
| 94 | */ |
|
| 95 | public function create_item_permissions_check( $request ) { |
|
| 96 | if ( ! wc_rest_check_manager_permissions( 'settings', 'create' ) ) { |
|
| 97 | return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 98 | } |
|
| 99 | ||
| 100 | return true; |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * Check if a given request has access delete a tax. |
|
| @@ 109-115 (lines=7) @@ | ||
| 106 | * @param WP_REST_Request $request Full details about the request. |
|
| 107 | * @return boolean |
|
| 108 | */ |
|
| 109 | public function delete_item_permissions_check( $request ) { |
|
| 110 | if ( ! wc_rest_check_manager_permissions( 'settings', 'delete' ) ) { |
|
| 111 | return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 112 | } |
|
| 113 | ||
| 114 | return true; |
|
| 115 | } |
|
| 116 | ||
| 117 | /** |
|
| 118 | * Get all tax classes. |
|
| @@ 72-78 (lines=7) @@ | ||
| 69 | * @param WP_REST_Request $request Full details about the request. |
|
| 70 | * @return WP_Error|boolean |
|
| 71 | */ |
|
| 72 | public function get_items_permissions_check( $request ) { |
|
| 73 | if ( ! wc_rest_check_post_permissions( 'shop_webhook', 'read' ) ) { |
|
| 74 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 75 | } |
|
| 76 | ||
| 77 | return true; |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * Check if a given request has access to read a webhook develivery. |
|
| @@ 105-111 (lines=7) @@ | ||
| 102 | * @param WP_REST_Request $request Full details about the request. |
|
| 103 | * @return WP_Error|boolean |
|
| 104 | */ |
|
| 105 | public function get_items_permissions_check( $request ) { |
|
| 106 | if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) { |
|
| 107 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 108 | } |
|
| 109 | ||
| 110 | return true; |
|
| 111 | } |
|
| 112 | ||
| 113 | /** |
|
| 114 | * Check if a given request has access create taxes. |
|
| @@ 119-125 (lines=7) @@ | ||
| 116 | * @param WP_REST_Request $request Full details about the request. |
|
| 117 | * @return boolean |
|
| 118 | */ |
|
| 119 | public function create_item_permissions_check( $request ) { |
|
| 120 | if ( ! wc_rest_check_manager_permissions( 'settings', 'create' ) ) { |
|
| 121 | return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 122 | } |
|
| 123 | ||
| 124 | return true; |
|
| 125 | } |
|
| 126 | ||
| 127 | /** |
|
| 128 | * Check if a given request has access to read a tax. |
|
| @@ 133-139 (lines=7) @@ | ||
| 130 | * @param WP_REST_Request $request Full details about the request. |
|
| 131 | * @return WP_Error|boolean |
|
| 132 | */ |
|
| 133 | public function get_item_permissions_check( $request ) { |
|
| 134 | if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) { |
|
| 135 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 136 | } |
|
| 137 | ||
| 138 | return true; |
|
| 139 | } |
|
| 140 | ||
| 141 | /** |
|
| 142 | * Check if a given request has access update a tax. |
|
| @@ 147-153 (lines=7) @@ | ||
| 144 | * @param WP_REST_Request $request Full details about the request. |
|
| 145 | * @return boolean |
|
| 146 | */ |
|
| 147 | public function update_item_permissions_check( $request ) { |
|
| 148 | if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) { |
|
| 149 | return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 150 | } |
|
| 151 | ||
| 152 | return true; |
|
| 153 | } |
|
| 154 | ||
| 155 | /** |
|
| 156 | * Check if a given request has access delete a tax. |
|
| @@ 161-167 (lines=7) @@ | ||
| 158 | * @param WP_REST_Request $request Full details about the request. |
|
| 159 | * @return boolean |
|
| 160 | */ |
|
| 161 | public function delete_item_permissions_check( $request ) { |
|
| 162 | if ( ! wc_rest_check_manager_permissions( 'settings', 'delete' ) ) { |
|
| 163 | return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 164 | } |
|
| 165 | ||
| 166 | return true; |
|
| 167 | } |
|
| 168 | ||
| 169 | /** |
|
| 170 | * Check if a given request has access batch create, update and delete items. |
|
| @@ 175-181 (lines=7) @@ | ||
| 172 | * @param WP_REST_Request $request Full details about the request. |
|
| 173 | * @return boolean |
|
| 174 | */ |
|
| 175 | public function batch_items_permissions_check( $request ) { |
|
| 176 | if ( ! wc_rest_check_manager_permissions( 'settings', 'batch' ) ) { |
|
| 177 | return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to manipule this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 178 | } |
|
| 179 | ||
| 180 | return true; |
|
| 181 | } |
|
| 182 | ||
| 183 | /** |
|
| 184 | * Get all taxes. |
|
| @@ 51-57 (lines=7) @@ | ||
| 48 | * @param WP_REST_Request $request Full details about the request. |
|
| 49 | * @return WP_Error|boolean |
|
| 50 | */ |
|
| 51 | public function get_items_permissions_check( $request ) { |
|
| 52 | if ( ! wc_rest_check_post_permissions( $this->post_type, 'read' ) ) { |
|
| 53 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 54 | } |
|
| 55 | ||
| 56 | return true; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Check if a given request has access to create an item. |
|
| @@ 65-71 (lines=7) @@ | ||
| 62 | * @param WP_REST_Request $request Full details about the request. |
|
| 63 | * @return WP_Error|boolean |
|
| 64 | */ |
|
| 65 | public function create_item_permissions_check( $request ) { |
|
| 66 | if ( ! wc_rest_check_post_permissions( $this->post_type, 'create' ) ) { |
|
| 67 | return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 68 | } |
|
| 69 | ||
| 70 | return true; |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * Check if a given request has access to read an item. |
|
| @@ 127-133 (lines=7) @@ | ||
| 124 | * @param WP_REST_Request $request Full details about the request. |
|
| 125 | * @return boolean |
|
| 126 | */ |
|
| 127 | public function batch_items_permissions_check( $request ) { |
|
| 128 | if ( ! wc_rest_check_post_permissions( $this->post_type, 'batch' ) ) { |
|
| 129 | return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to manipule this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 130 | } |
|
| 131 | ||
| 132 | return true; |
|
| 133 | } |
|
| 134 | ||
| 135 | /** |
|
| 136 | * Get post types. |
|
| @@ 116-122 (lines=7) @@ | ||
| 113 | * @param WP_REST_Request $request Full details about the request. |
|
| 114 | * @return WP_Error|boolean |
|
| 115 | */ |
|
| 116 | public function get_items_permissions_check( $request ) { |
|
| 117 | if ( ! wc_rest_check_user_permissions( 'read' ) ) { |
|
| 118 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 119 | } |
|
| 120 | ||
| 121 | return true; |
|
| 122 | } |
|
| 123 | ||
| 124 | /** |
|
| 125 | * Check if a given request has access create customers. |
|
| @@ 130-136 (lines=7) @@ | ||
| 127 | * @param WP_REST_Request $request Full details about the request. |
|
| 128 | * @return boolean |
|
| 129 | */ |
|
| 130 | public function create_item_permissions_check( $request ) { |
|
| 131 | if ( ! wc_rest_check_user_permissions( 'create' ) ) { |
|
| 132 | return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 133 | } |
|
| 134 | ||
| 135 | return true; |
|
| 136 | } |
|
| 137 | ||
| 138 | /** |
|
| 139 | * Check if a given request has access to read a customer. |
|
| @@ 192-198 (lines=7) @@ | ||
| 189 | * @param WP_REST_Request $request Full details about the request. |
|
| 190 | * @return boolean |
|
| 191 | */ |
|
| 192 | public function batch_items_permissions_check( $request ) { |
|
| 193 | if ( ! wc_rest_check_user_permissions( 'batch' ) ) { |
|
| 194 | return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to manipule this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 195 | } |
|
| 196 | ||
| 197 | return true; |
|
| 198 | } |
|
| 199 | ||
| 200 | /** |
|
| 201 | * Get all customers. |
|
| @@ 116-122 (lines=7) @@ | ||
| 113 | * @param WP_REST_Request $request Full details about the request. |
|
| 114 | * @return WP_Error|boolean |
|
| 115 | */ |
|
| 116 | public function get_items_permissions_check( $request ) { |
|
| 117 | if ( ! wc_rest_check_manager_permissions( 'attributes', 'read' ) ) { |
|
| 118 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 119 | } |
|
| 120 | ||
| 121 | return true; |
|
| 122 | } |
|
| 123 | ||
| 124 | /** |
|
| 125 | * Check if a given request has access to create a attribute. |
|
| @@ 130-136 (lines=7) @@ | ||
| 127 | * @param WP_REST_Request $request Full details about the request. |
|
| 128 | * @return WP_Error|boolean |
|
| 129 | */ |
|
| 130 | public function create_item_permissions_check( $request ) { |
|
| 131 | if ( ! wc_rest_check_manager_permissions( 'attributes', 'create' ) ) { |
|
| 132 | return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you cannot create new resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 133 | } |
|
| 134 | ||
| 135 | return true; |
|
| 136 | } |
|
| 137 | ||
| 138 | /** |
|
| 139 | * Check if a given request has access to read a attribute. |
|
| @@ 198-204 (lines=7) @@ | ||
| 195 | * @param WP_REST_Request $request Full details about the request. |
|
| 196 | * @return boolean |
|
| 197 | */ |
|
| 198 | public function batch_items_permissions_check( $request ) { |
|
| 199 | if ( ! wc_rest_check_manager_permissions( 'attributes', 'batch' ) ) { |
|
| 200 | return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to manipule this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 201 | } |
|
| 202 | ||
| 203 | return true; |
|
| 204 | } |
|
| 205 | ||
| 206 | /** |
|
| 207 | * Get all attributes. |
|
| @@ 100-106 (lines=7) @@ | ||
| 97 | * @param WP_REST_Request $request Full details about the request. |
|
| 98 | * @return WP_Error|boolean |
|
| 99 | */ |
|
| 100 | public function get_items_permissions_check( $request ) { |
|
| 101 | if ( ! wc_rest_check_post_permissions( $this->post_type, 'read' ) ) { |
|
| 102 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 103 | } |
|
| 104 | ||
| 105 | return true; |
|
| 106 | } |
|
| 107 | ||
| 108 | /** |
|
| 109 | * Check if a given request has access create order notes. |
|
| @@ 114-120 (lines=7) @@ | ||
| 111 | * @param WP_REST_Request $request Full details about the request. |
|
| 112 | * @return boolean |
|
| 113 | */ |
|
| 114 | public function create_item_permissions_check( $request ) { |
|
| 115 | if ( ! wc_rest_check_post_permissions( $this->post_type, 'create' ) ) { |
|
| 116 | return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 117 | } |
|
| 118 | ||
| 119 | return true; |
|
| 120 | } |
|
| 121 | ||
| 122 | /** |
|
| 123 | * Check if a given request has access to read a order note. |
|
| @@ 171-177 (lines=7) @@ | ||
| 168 | * @param WP_REST_Request $request Full data about the request. |
|
| 169 | * @return WP_Error|boolean |
|
| 170 | */ |
|
| 171 | public function get_items_permissions_check( $request ) { |
|
| 172 | if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) { |
|
| 173 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 174 | } |
|
| 175 | ||
| 176 | return true; |
|
| 177 | } |
|
| 178 | ||
| 179 | /** |
|
| 180 | * Get the groups schema, conforming to JSON Schema. |
|
| @@ 283-289 (lines=7) @@ | ||
| 280 | * @param WP_REST_Request $request Full data about the request. |
|
| 281 | * @return WP_Error|boolean |
|
| 282 | */ |
|
| 283 | public function get_items_permissions_check( $request ) { |
|
| 284 | if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) { |
|
| 285 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 286 | } |
|
| 287 | ||
| 288 | return true; |
|
| 289 | } |
|
| 290 | ||
| 291 | /** |
|
| 292 | * Makes sure the current user has access to WRITE the settings APIs. |
|
| @@ 298-304 (lines=7) @@ | ||
| 295 | * @param WP_REST_Request $request Full data about the request. |
|
| 296 | * @return WP_Error|boolean |
|
| 297 | */ |
|
| 298 | public function update_items_permissions_check( $request ) { |
|
| 299 | if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) { |
|
| 300 | return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 301 | } |
|
| 302 | ||
| 303 | return true; |
|
| 304 | } |
|
| 305 | ||
| 306 | /** |
|
| 307 | * Filters out bad values from the settings array/filter so we |
|
| @@ 115-121 (lines=7) @@ | ||
| 112 | * @param WP_REST_Request $request Full details about the request. |
|
| 113 | * @return WP_Error|boolean |
|
| 114 | */ |
|
| 115 | public function get_items_permissions_check( $request ) { |
|
| 116 | if ( ! wc_rest_check_post_permissions( 'product', 'read' ) ) { |
|
| 117 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
| 118 | } |
|
| 119 | ||
| 120 | return true; |
|
| 121 | } |
|
| 122 | ||
| 123 | /** |
|
| 124 | * Check if a given request has access to read a product review. |
|