Code Duplication    Length = 7-8 lines in 3 locations

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

@@ 312-319 (lines=8) @@
309
	 *
310
	 * @return bool|WP_Error True if user is able to disconnect the site.
311
	 */
312
	public static function connect_url_permission_callback() {
313
		if ( current_user_can( 'jetpack_connect_user' ) ) {
314
			return true;
315
		}
316
317
		return new WP_Error( 'invalid_user_permission_jetpack_disconnect', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
318
319
	}
320
321
	/**
322
	 * Verify that a user can use the link endpoint.
@@ 328-334 (lines=7) @@
325
	 *
326
	 * @return bool|WP_Error True if user is able to link to WordPress.com
327
	 */
328
	public static function link_user_permission_callback() {
329
		if ( current_user_can( 'jetpack_connect_user' ) ) {
330
			return true;
331
		}
332
333
		return new WP_Error( 'invalid_user_permission_link_user', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
334
	}
335
336
	/**
337
	 * Verify that a user can get the data about the current user.
@@ 346-352 (lines=7) @@
343
	 *
344
	 * @return bool|WP_Error True if user is able to unlink.
345
	 */
346
	public static function get_user_connection_data_permission_callback() {
347
		if ( current_user_can( 'jetpack_connect_user' ) ) {
348
			return true;
349
		}
350
351
		return new WP_Error( 'invalid_user_permission_unlink_user', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
352
	}
353
354
	/**
355
	 * Verify that a user can use the unlink endpoint.