|
@@ 718-730 (lines=13) @@
|
| 715 |
|
* |
| 716 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 717 |
|
*/ |
| 718 |
|
public static function disconnect_site( $request ) { |
| 719 |
|
|
| 720 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 721 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 722 |
|
} |
| 723 |
|
|
| 724 |
|
if ( Jetpack::is_active() ) { |
| 725 |
|
Jetpack::disconnect(); |
| 726 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 727 |
|
} |
| 728 |
|
|
| 729 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 730 |
|
} |
| 731 |
|
|
| 732 |
|
/** |
| 733 |
|
* Gets a new connect raw URL with fresh nonce. |
|
@@ 838-853 (lines=16) @@
|
| 835 |
|
* |
| 836 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 837 |
|
*/ |
| 838 |
|
public static function unlink_user( $request ) { |
| 839 |
|
|
| 840 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 841 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 842 |
|
} |
| 843 |
|
|
| 844 |
|
if ( Jetpack::unlink_user() ) { |
| 845 |
|
return rest_ensure_response( |
| 846 |
|
array( |
| 847 |
|
'code' => 'success' |
| 848 |
|
) |
| 849 |
|
); |
| 850 |
|
} |
| 851 |
|
|
| 852 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 853 |
|
} |
| 854 |
|
|
| 855 |
|
/** |
| 856 |
|
* Fetch site data from .com including the site's current plan. |