Code Duplication    Length = 13-16 lines in 2 locations

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

@@ 635-647 (lines=13) @@
632
	 *
633
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
634
	 */
635
	public static function disconnect_site( $request ) {
636
637
		if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) {
638
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
639
		}
640
641
		if ( Jetpack::is_active() ) {
642
			Jetpack::disconnect();
643
			return rest_ensure_response( array( 'code' => 'success' ) );
644
		}
645
646
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
647
	}
648
649
	/**
650
	 * Gets a new connect raw URL with fresh nonce.
@@ 755-770 (lines=16) @@
752
	 *
753
	 * @return bool|WP_Error True if user successfully unlinked.
754
	 */
755
	public static function unlink_user( $request ) {
756
757
		if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) {
758
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
759
		}
760
761
		if ( Jetpack::unlink_user() ) {
762
			return rest_ensure_response(
763
				array(
764
					'code' => 'success'
765
				)
766
			);
767
		}
768
769
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
770
	}
771
772
	/**
773
	 * Get site data, including for example, the site's current plan.