|
@@ 930-942 (lines=13) @@
|
| 927 |
|
* |
| 928 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 929 |
|
*/ |
| 930 |
|
public static function disconnect_site( $request ) { |
| 931 |
|
|
| 932 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 933 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 934 |
|
} |
| 935 |
|
|
| 936 |
|
if ( Jetpack::is_active() ) { |
| 937 |
|
Jetpack::disconnect(); |
| 938 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 939 |
|
} |
| 940 |
|
|
| 941 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 942 |
|
} |
| 943 |
|
|
| 944 |
|
/** |
| 945 |
|
* Gets a new connect raw URL with fresh nonce. |
|
@@ 1063-1078 (lines=16) @@
|
| 1060 |
|
* |
| 1061 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 1062 |
|
*/ |
| 1063 |
|
public static function unlink_user( $request ) { |
| 1064 |
|
|
| 1065 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 1066 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1067 |
|
} |
| 1068 |
|
|
| 1069 |
|
if ( Jetpack::unlink_user() ) { |
| 1070 |
|
return rest_ensure_response( |
| 1071 |
|
array( |
| 1072 |
|
'code' => 'success' |
| 1073 |
|
) |
| 1074 |
|
); |
| 1075 |
|
} |
| 1076 |
|
|
| 1077 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1078 |
|
} |
| 1079 |
|
|
| 1080 |
|
/** |
| 1081 |
|
* Gets current user's tracking settings. |