@@ 101-112 (lines=12) @@ | ||
98 | * @param WP_REST_Request $request Full details about the request. |
|
99 | * @return WP_Error|boolean |
|
100 | */ |
|
101 | public function get_items_permissions_check( $request ) { |
|
102 | $permissions = $this->check_permissions( $request, 'read' ); |
|
103 | if ( is_wp_error( $permissions ) ) { |
|
104 | return $permissions; |
|
105 | } |
|
106 | ||
107 | if ( ! $permissions ) { |
|
108 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
109 | } |
|
110 | ||
111 | return true; |
|
112 | } |
|
113 | ||
114 | /** |
|
115 | * Check if a given request has access to create a term. |
|
@@ 120-131 (lines=12) @@ | ||
117 | * @param WP_REST_Request $request Full details about the request. |
|
118 | * @return WP_Error|boolean |
|
119 | */ |
|
120 | public function create_item_permissions_check( $request ) { |
|
121 | $permissions = $this->check_permissions( $request, 'create' ); |
|
122 | if ( is_wp_error( $permissions ) ) { |
|
123 | return $permissions; |
|
124 | } |
|
125 | ||
126 | if ( ! $permissions ) { |
|
127 | return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you cannot create new resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
128 | } |
|
129 | ||
130 | return true; |
|
131 | } |
|
132 | ||
133 | /** |
|
134 | * Check if a given request has access to read a term. |
|
@@ 139-150 (lines=12) @@ | ||
136 | * @param WP_REST_Request $request Full details about the request. |
|
137 | * @return WP_Error|boolean |
|
138 | */ |
|
139 | public function get_item_permissions_check( $request ) { |
|
140 | $permissions = $this->check_permissions( $request, 'read' ); |
|
141 | if ( is_wp_error( $permissions ) ) { |
|
142 | return $permissions; |
|
143 | } |
|
144 | ||
145 | if ( ! $permissions ) { |
|
146 | return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
147 | } |
|
148 | ||
149 | return true; |
|
150 | } |
|
151 | ||
152 | /** |
|
153 | * Check if a given request has access to update a term. |
|
@@ 158-169 (lines=12) @@ | ||
155 | * @param WP_REST_Request $request Full details about the request. |
|
156 | * @return WP_Error|boolean |
|
157 | */ |
|
158 | public function update_item_permissions_check( $request ) { |
|
159 | $permissions = $this->check_permissions( $request, 'edit' ); |
|
160 | if ( is_wp_error( $permissions ) ) { |
|
161 | return $permissions; |
|
162 | } |
|
163 | ||
164 | if ( ! $permissions ) { |
|
165 | return new WP_Error( 'woocommerce_rest_cannot_update', __( 'Sorry, you cannot update resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
166 | } |
|
167 | ||
168 | return true; |
|
169 | } |
|
170 | ||
171 | /** |
|
172 | * Check if a given request has access to delete a term. |
|
@@ 177-188 (lines=12) @@ | ||
174 | * @param WP_REST_Request $request Full details about the request. |
|
175 | * @return WP_Error|boolean |
|
176 | */ |
|
177 | public function delete_item_permissions_check( $request ) { |
|
178 | $permissions = $this->check_permissions( $request, 'delete' ); |
|
179 | if ( is_wp_error( $permissions ) ) { |
|
180 | return $permissions; |
|
181 | } |
|
182 | ||
183 | if ( ! $permissions ) { |
|
184 | return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you cannot delete resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
185 | } |
|
186 | ||
187 | return true; |
|
188 | } |
|
189 | ||
190 | /** |
|
191 | * Check if a given request has access batch create, update and delete items. |
|
@@ 196-207 (lines=12) @@ | ||
193 | * @param WP_REST_Request $request Full details about the request. |
|
194 | * @return boolean |
|
195 | */ |
|
196 | public function batch_items_permissions_check( $request ) { |
|
197 | $permissions = $this->check_permissions( $request, 'batch' ); |
|
198 | if ( is_wp_error( $permissions ) ) { |
|
199 | return $permissions; |
|
200 | } |
|
201 | ||
202 | if ( ! $permissions ) { |
|
203 | return new WP_Error( 'woocommerce_rest_cannot_batch', __( 'Sorry, you are not allowed to manipule this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); |
|
204 | } |
|
205 | ||
206 | return true; |
|
207 | } |
|
208 | ||
209 | /** |
|
210 | * Check permissions. |