Code Duplication    Length = 7-7 lines in 23 locations

includes/api/class-wc-rest-order-notes-controller.php 2 locations

@@ 93-99 (lines=7) @@
90
	 * @param  WP_REST_Request $request Full details about the request.
91
	 * @return WP_Error|boolean
92
	 */
93
	public function get_items_permissions_check( $request ) {
94
		if ( ! wc_rest_check_post_permissions( 'shop_order', 'read' ) ) {
95
			return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
96
		}
97
98
		return true;
99
	}
100
101
	/**
102
	 * Check if a given request has access create order notes.
@@ 107-113 (lines=7) @@
104
	 * @param  WP_REST_Request $request Full details about the request.
105
	 * @return boolean
106
	 */
107
	public function create_item_permissions_check( $request ) {
108
		if ( ! wc_rest_check_post_permissions( 'shop_order', 'create' ) ) {
109
			return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
110
		}
111
112
		return true;
113
	}
114
115
	/**
116
	 * Check if a given request has access to read a order note.

includes/api/class-wc-rest-product-attributes-controller.php 2 locations

@@ 106-112 (lines=7) @@
103
	 * @param  WP_REST_Request $request Full details about the request.
104
	 * @return WP_Error|boolean
105
	 */
106
	public function get_items_permissions_check( $request ) {
107
		if ( ! wc_rest_check_manager_permissions( 'attributes', 'read' ) ) {
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 attribute.
@@ 120-126 (lines=7) @@
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
		if ( ! wc_rest_check_manager_permissions( 'attributes', 'create' ) ) {
122
			return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you cannot create new resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
123
		}
124
125
		return true;
126
	}
127
128
	/**
129
	 * Check if a given request has access to read a attribute.

includes/api/class-wc-rest-product-reviews-controller.php 1 location

@@ 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.

includes/api/class-wc-rest-report-sales-controller.php 1 location

@@ 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.

includes/api/class-wc-rest-reports-controller.php 1 location

@@ 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.

includes/api/class-wc-rest-tax-classes-controller.php 3 locations

@@ 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 tax classes.', '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.

includes/api/class-wc-rest-webhook-deliveries.php 1 location

@@ 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.

includes/api/class-wc-rest-taxes-controller.php 6 locations

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

includes/abstracts/abstract-wc-rest-posts-controller.php 3 locations

@@ 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 a single item.

includes/api/class-wc-rest-customers-controller.php 3 locations

@@ 125-131 (lines=7) @@
122
	 * @param  WP_REST_Request $request Full details about the request.
123
	 * @return WP_Error|boolean
124
	 */
125
	public function get_items_permissions_check( $request ) {
126
		if ( ! wc_rest_check_user_permissions( 'read' ) ) {
127
			return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
128
		}
129
130
		return true;
131
	}
132
133
	/**
134
	 * Check if a given request has access create customers.
@@ 139-145 (lines=7) @@
136
	 * @param  WP_REST_Request $request Full details about the request.
137
	 * @return boolean
138
	 */
139
	public function create_item_permissions_check( $request ) {
140
		if ( ! wc_rest_check_user_permissions( 'create' ) ) {
141
			return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
142
		}
143
144
		return true;
145
	}
146
147
	/**
148
	 * Check if a given request has access to read a customer.
@@ 201-207 (lines=7) @@
198
	 * @param  WP_REST_Request $request Full details about the request.
199
	 * @return boolean
200
	 */
201
	public function batch_items_permissions_check( $request ) {
202
		if ( ! wc_rest_check_user_permissions( 'batch' ) ) {
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
	 * Get all customers.