|
@@ 787-799 (lines=13) @@
|
| 784 |
|
* |
| 785 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 786 |
|
*/ |
| 787 |
|
public static function disconnect_site( $request ) { |
| 788 |
|
|
| 789 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 790 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 791 |
|
} |
| 792 |
|
|
| 793 |
|
if ( Jetpack::is_active() ) { |
| 794 |
|
Jetpack::disconnect(); |
| 795 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 796 |
|
} |
| 797 |
|
|
| 798 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 799 |
|
} |
| 800 |
|
|
| 801 |
|
/** |
| 802 |
|
* Gets a new connect raw URL with fresh nonce. |
|
@@ 920-935 (lines=16) @@
|
| 917 |
|
* |
| 918 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 919 |
|
*/ |
| 920 |
|
public static function unlink_user( $request ) { |
| 921 |
|
|
| 922 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 923 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 924 |
|
} |
| 925 |
|
|
| 926 |
|
if ( Jetpack::unlink_user() ) { |
| 927 |
|
return rest_ensure_response( |
| 928 |
|
array( |
| 929 |
|
'code' => 'success' |
| 930 |
|
) |
| 931 |
|
); |
| 932 |
|
} |
| 933 |
|
|
| 934 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 935 |
|
} |
| 936 |
|
|
| 937 |
|
/** |
| 938 |
|
* Gets current user's tracking settings. |