Code Duplication    Length = 7-8 lines in 3 locations

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

@@ 787-794 (lines=8) @@
784
	 *
785
	 * @return bool|WP_Error True if user is able to disconnect the site.
786
	 */
787
	public static function disconnect_site_permission_callback() {
788
		if ( current_user_can( 'jetpack_disconnect' ) ) {
789
			return true;
790
		}
791
792
		return new WP_Error( 'invalid_user_permission_jetpack_disconnect', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
793
794
	}
795
796
	/**
797
	 * Verify that the user can get a connect/link URL
@@ 838-844 (lines=7) @@
835
	 *
836
	 * @return bool|WP_Error True if user is able to change master user.
837
	 */
838
	public static function set_connection_owner_permission_callback() {
839
		if ( current_user_can( 'jetpack_disconnect' ) ) {
840
			return true;
841
		}
842
843
		return new WP_Error( 'invalid_user_permission_set_connection_owner', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
844
	}
845
846
	/**
847
	 * Verify that a user can use the /connection/user endpoint. Has to be a registered user and be currently linked.
@@ 915-921 (lines=7) @@
912
	 *
913
	 * @return bool Whether user has capability 'jetpack_disconnect'.
914
	 */
915
	public static function identity_crisis_mitigation_permission_check() {
916
		if ( current_user_can( 'jetpack_disconnect' ) ) {
917
			return true;
918
		}
919
920
		return new WP_Error( 'invalid_user_permission_identity_crisis', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
921
	}
922
923
	/**
924
	 * Verify that user can update Jetpack general settings.