|
@@ 1099-1111 (lines=13) @@
|
| 1096 |
|
* |
| 1097 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 1098 |
|
*/ |
| 1099 |
|
public static function disconnect_site( $request ) { |
| 1100 |
|
|
| 1101 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 1102 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1103 |
|
} |
| 1104 |
|
|
| 1105 |
|
if ( Jetpack::is_active() ) { |
| 1106 |
|
Jetpack::disconnect(); |
| 1107 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 1108 |
|
} |
| 1109 |
|
|
| 1110 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1111 |
|
} |
| 1112 |
|
|
| 1113 |
|
/** |
| 1114 |
|
* Registers the Jetpack site |
|
@@ 1258-1273 (lines=16) @@
|
| 1255 |
|
* |
| 1256 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 1257 |
|
*/ |
| 1258 |
|
public static function unlink_user( $request ) { |
| 1259 |
|
|
| 1260 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 1261 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1262 |
|
} |
| 1263 |
|
|
| 1264 |
|
if ( Connection_Manager::disconnect_user() ) { |
| 1265 |
|
return rest_ensure_response( |
| 1266 |
|
array( |
| 1267 |
|
'code' => 'success' |
| 1268 |
|
) |
| 1269 |
|
); |
| 1270 |
|
} |
| 1271 |
|
|
| 1272 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1273 |
|
} |
| 1274 |
|
|
| 1275 |
|
/** |
| 1276 |
|
* Gets current user's tracking settings. |