|
@@ 1086-1098 (lines=13) @@
|
| 1083 |
|
* |
| 1084 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 1085 |
|
*/ |
| 1086 |
|
public static function disconnect_site( $request ) { |
| 1087 |
|
|
| 1088 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 1089 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1090 |
|
} |
| 1091 |
|
|
| 1092 |
|
if ( Jetpack::is_active() ) { |
| 1093 |
|
Jetpack::disconnect(); |
| 1094 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 1095 |
|
} |
| 1096 |
|
|
| 1097 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1098 |
|
} |
| 1099 |
|
|
| 1100 |
|
/** |
| 1101 |
|
* Gets a new connect raw URL with fresh nonce. |
|
@@ 1219-1234 (lines=16) @@
|
| 1216 |
|
* |
| 1217 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 1218 |
|
*/ |
| 1219 |
|
public static function unlink_user( $request ) { |
| 1220 |
|
|
| 1221 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 1222 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1223 |
|
} |
| 1224 |
|
|
| 1225 |
|
if ( Jetpack::unlink_user() ) { |
| 1226 |
|
return rest_ensure_response( |
| 1227 |
|
array( |
| 1228 |
|
'code' => 'success' |
| 1229 |
|
) |
| 1230 |
|
); |
| 1231 |
|
} |
| 1232 |
|
|
| 1233 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1234 |
|
} |
| 1235 |
|
|
| 1236 |
|
/** |
| 1237 |
|
* Gets current user's tracking settings. |