Code Duplication    Length = 7-7 lines in 18 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-taxes-controller.php 5 locations

@@ 95-101 (lines=7) @@
92
	 * @param  WP_REST_Request $request Full details about the request.
93
	 * @return WP_Error|boolean
94
	 */
95
	public function get_items_permissions_check( $request ) {
96
		if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) {
97
			return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot list taxes.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
98
		}
99
100
		return true;
101
	}
102
103
	/**
104
	 * Check if a given request has access create taxes.
@@ 109-115 (lines=7) @@
106
	 * @param  WP_REST_Request $request Full details about the request.
107
	 * @return boolean
108
	 */
109
	public function create_item_permissions_check( $request ) {
110
		if ( ! wc_rest_check_manager_permissions( 'settings', 'create' ) ) {
111
			return new WP_Error( 'woocommerce_rest_cannot_create', __( 'Sorry, you are not allowed to create resources.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
112
		}
113
114
		return true;
115
	}
116
117
	/**
118
	 * Check if a given request has access to read a tax.
@@ 123-129 (lines=7) @@
120
	 * @param  WP_REST_Request $request Full details about the request.
121
	 * @return WP_Error|boolean
122
	 */
123
	public function get_item_permissions_check( $request ) {
124
		if ( ! wc_rest_check_manager_permissions( 'settings', 'read' ) ) {
125
			return new WP_Error( 'woocommerce_rest_cannot_view', __( 'Sorry, you cannot view this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
126
		}
127
128
		return true;
129
	}
130
131
	/**
132
	 * Check if a given request has access update a tax.
@@ 137-143 (lines=7) @@
134
	 * @param  WP_REST_Request $request Full details about the request.
135
	 * @return boolean
136
	 */
137
	public function update_item_permissions_check( $request ) {
138
		if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) {
139
			return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you are not allowed to edit this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
140
		}
141
142
		return true;
143
	}
144
145
	/**
146
	 * Check if a given request has access delete a tax.
@@ 151-157 (lines=7) @@
148
	 * @param  WP_REST_Request $request Full details about the request.
149
	 * @return boolean
150
	 */
151
	public function delete_item_permissions_check( $request ) {
152
		if ( ! wc_rest_check_manager_permissions( 'settings', 'delete' ) ) {
153
			return new WP_Error( 'woocommerce_rest_cannot_delete', __( 'Sorry, you are not allowed to delete this resource.', 'woocommerce' ), array( 'status' => rest_authorization_required_code() ) );
154
		}
155
156
		return true;
157
	}
158
159
	/**
160
	 * Get all taxes.

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.