Code Duplication    Length = 7-8 lines in 3 locations

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

@@ 289-296 (lines=8) @@
286
	 *
287
	 * @return bool|WP_Error True if user is able to disconnect the site.
288
	 */
289
	public static function connect_url_permission_callback() {
290
		if ( current_user_can( 'jetpack_connect_user' ) ) {
291
			return true;
292
		}
293
294
		return new WP_Error( 'invalid_user_permission_jetpack_disconnect', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
295
296
	}
297
298
	/**
299
	 * Verify that a user can use the link endpoint.
@@ 305-311 (lines=7) @@
302
	 *
303
	 * @return bool|WP_Error True if user is able to link to WordPress.com
304
	 */
305
	public static function link_user_permission_callback() {
306
		if ( current_user_can( 'jetpack_connect_user' ) ) {
307
			return true;
308
		}
309
310
		return new WP_Error( 'invalid_user_permission_link_user', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
311
	}
312
313
	/**
314
	 * Verify that a user can get the data about the current user.
@@ 323-329 (lines=7) @@
320
	 *
321
	 * @return bool|WP_Error True if user is able to unlink.
322
	 */
323
	public static function get_user_connection_data_permission_callback() {
324
		if ( current_user_can( 'jetpack_connect_user' ) ) {
325
			return true;
326
		}
327
328
		return new WP_Error( 'invalid_user_permission_unlink_user', self::$user_permissions_error_msg, array( 'status' => self::rest_authorization_required_code() ) );
329
	}
330
331
	/**
332
	 * Verify that a user can use the unlink endpoint.