|
@@ 144-154 (lines=11) @@
|
| 141 |
|
* @param WP_REST_Request $request Full details about the request. |
| 142 |
|
* @return WP_Error|boolean |
| 143 |
|
*/ |
| 144 |
|
public function get_item_permissions_check( $request ) { |
| 145 |
|
if ( ! $this->get_taxonomy( $request ) ) { |
| 146 |
|
return new WP_Error( "woocommerce_rest_taxonomy_invalid", __( "Resource doesn't exist.", 'woocommerce' ), array( 'status' => 404 ) ); |
| 147 |
|
} |
| 148 |
|
|
| 149 |
|
if ( ! wc_rest_check_manager_permissions( 'attributes', 'read' ) ) { |
| 150 |
|
return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
return true; |
| 154 |
|
} |
| 155 |
|
|
| 156 |
|
/** |
| 157 |
|
* Check if a given request has access to update a attribute. |
|
@@ 162-172 (lines=11) @@
|
| 159 |
|
* @param WP_REST_Request $request Full details about the request. |
| 160 |
|
* @return WP_Error|boolean |
| 161 |
|
*/ |
| 162 |
|
public function update_item_permissions_check( $request ) { |
| 163 |
|
if ( ! $this->get_taxonomy( $request ) ) { |
| 164 |
|
return new WP_Error( "woocommerce_rest_taxonomy_invalid", __( "Resource doesn't exist.", 'woocommerce' ), array( 'status' => 404 ) ); |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
if ( ! wc_rest_check_manager_permissions( 'attributes', 'edit' ) ) { |
| 168 |
|
return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
| 169 |
|
} |
| 170 |
|
|
| 171 |
|
return true; |
| 172 |
|
} |
| 173 |
|
|
| 174 |
|
/** |
| 175 |
|
* Check if a given request has access to delete a attribute. |
|
@@ 180-190 (lines=11) @@
|
| 177 |
|
* @param WP_REST_Request $request Full details about the request. |
| 178 |
|
* @return WP_Error|boolean |
| 179 |
|
*/ |
| 180 |
|
public function delete_item_permissions_check( $request ) { |
| 181 |
|
if ( ! $this->get_taxonomy( $request ) ) { |
| 182 |
|
return new WP_Error( "woocommerce_rest_taxonomy_invalid", __( "Resource doesn't exist.", 'woocommerce' ), array( 'status' => 404 ) ); |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
if ( ! wc_rest_check_manager_permissions( 'attributes', 'delete' ) ) { |
| 186 |
|
return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you cannot delete resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
| 187 |
|
} |
| 188 |
|
|
| 189 |
|
return true; |
| 190 |
|
} |
| 191 |
|
|
| 192 |
|
/** |
| 193 |
|
* Get all attributes. |