Code Duplication    Length = 7-8 lines in 3 locations

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

@@ 1011-1018 (lines=8) @@
1008
	 *
1009
	 * @return bool|WP_Error True if user is able to disconnect the site.
1010
	 */
1011
	public static function disconnect_site_permission_callback() {
1012
		if ( current_user_can( 'jetpack_disconnect' ) ) {
1013
			return true;
1014
		}
1015
1016
		return new WP_Error( 'invalid_user_permission_jetpack_disconnect', self::$user_permissions_error_msg, array( 'status' => rest_authorization_required_code() ) );
1017
1018
	}
1019
1020
	/**
1021
	 * Verify that the user can dismiss JITM messages.
@@ 1077-1083 (lines=7) @@
1074
	 *
1075
	 * @return bool|WP_Error True if user is able to change master user.
1076
	 */
1077
	public static function set_connection_owner_permission_callback() {
1078
		if ( current_user_can( 'jetpack_disconnect' ) ) {
1079
			return true;
1080
		}
1081
1082
		return new WP_Error( 'invalid_user_permission_set_connection_owner', self::$user_permissions_error_msg, array( 'status' => rest_authorization_required_code() ) );
1083
	}
1084
1085
	/**
1086
	 * Verify that a user can use the /connection/user endpoint. Has to be a registered user and be currently linked.
@@ 1154-1160 (lines=7) @@
1151
	 *
1152
	 * @return bool Whether user has capability 'jetpack_disconnect'.
1153
	 */
1154
	public static function identity_crisis_mitigation_permission_check() {
1155
		if ( current_user_can( 'jetpack_disconnect' ) ) {
1156
			return true;
1157
		}
1158
1159
		return new WP_Error( 'invalid_user_permission_identity_crisis', self::$user_permissions_error_msg, array( 'status' => rest_authorization_required_code() ) );
1160
	}
1161
1162
	/**
1163
	 * Verify that user can update Jetpack general settings.