@@ 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. |
@@ 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( 'product', '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. |
@@ 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. |
@@ 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. |
@@ 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. |