Code Duplication    Length = 7-8 lines in 3 locations

_inc/lib/class.core-rest-api-endpoints.php 3 locations

@@ 304-311 (lines=8) @@
301
	 *
302
	 * @return bool|WP_Error True if user is able to disconnect the site.
303
	 */
304
	public static function connect_url_permission_callback() {
305
		if ( current_user_can( 'jetpack_connect_user' ) ) {
306
			return true;
307
		}
308
309
		return new WP_Error( 'invalid_user_permission_jetpack_disconnect', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
310
311
	}
312
313
	/**
314
	 * Verify that a user can use the link endpoint.
@@ 320-326 (lines=7) @@
317
	 *
318
	 * @return bool|WP_Error True if user is able to link to WordPress.com
319
	 */
320
	public static function link_user_permission_callback() {
321
		if ( current_user_can( 'jetpack_connect_user' ) ) {
322
			return true;
323
		}
324
325
		return new WP_Error( 'invalid_user_permission_link_user', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
326
	}
327
328
	/**
329
	 * Verify that a user can get the data about the current user.
@@ 338-344 (lines=7) @@
335
	 *
336
	 * @return bool|WP_Error True if user is able to unlink.
337
	 */
338
	public static function get_user_connection_data_permission_callback() {
339
		if ( current_user_can( 'jetpack_connect_user' ) ) {
340
			return true;
341
		}
342
343
		return new WP_Error( 'invalid_user_permission_unlink_user', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
344
	}
345
346
	/**
347
	 * Verify that a user can use the unlink endpoint.