Code Duplication    Length = 7-8 lines in 3 locations

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

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