Code Duplication    Length = 7-8 lines in 3 locations

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

@@ 851-858 (lines=8) @@
848
	 *
849
	 * @return bool|WP_Error True if user is able to disconnect the site.
850
	 */
851
	public static function disconnect_site_permission_callback() {
852
		if ( current_user_can( 'jetpack_disconnect' ) ) {
853
			return true;
854
		}
855
856
		return new WP_Error( 'invalid_user_permission_jetpack_disconnect', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
857
858
	}
859
860
	/**
861
	 * Verify that the user can get a connect/link URL
@@ 902-908 (lines=7) @@
899
	 *
900
	 * @return bool|WP_Error True if user is able to change master user.
901
	 */
902
	public static function set_connection_owner_permission_callback() {
903
		if ( current_user_can( 'jetpack_disconnect' ) ) {
904
			return true;
905
		}
906
907
		return new WP_Error( 'invalid_user_permission_set_connection_owner', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
908
	}
909
910
	/**
911
	 * Verify that a user can use the /connection/user endpoint. Has to be a registered user and be currently linked.
@@ 979-985 (lines=7) @@
976
	 *
977
	 * @return bool Whether user has capability 'jetpack_disconnect'.
978
	 */
979
	public static function identity_crisis_mitigation_permission_check() {
980
		if ( current_user_can( 'jetpack_disconnect' ) ) {
981
			return true;
982
		}
983
984
		return new WP_Error( 'invalid_user_permission_identity_crisis', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
985
	}
986
987
	/**
988
	 * Verify that user can update Jetpack general settings.