Code Duplication    Length = 7-7 lines in 19 locations

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

@@ 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_user_permissions( '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 create customers.
@@ 129-135 (lines=7) @@
126
	 * @param  WP_REST_Request $request Full details about the request.
127
	 * @return boolean
128
	 */
129
	public function create_item_permissions_check( $request ) {
130
		if ( ! wc_rest_check_user_permissions( 'create' ) ) {
131
			return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
132
		}
133
134
		return true;
135
	}
136
137
	/**
138
	 * Check if a given request has access to read a customer.

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.