|
@@ 1317-1329 (lines=13) @@
|
| 1314 |
|
* |
| 1315 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 1316 |
|
*/ |
| 1317 |
|
public static function disconnect_site( $request ) { |
| 1318 |
|
|
| 1319 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 1320 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1321 |
|
} |
| 1322 |
|
|
| 1323 |
|
if ( Jetpack::is_active() ) { |
| 1324 |
|
Jetpack::disconnect(); |
| 1325 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 1326 |
|
} |
| 1327 |
|
|
| 1328 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1329 |
|
} |
| 1330 |
|
|
| 1331 |
|
/** |
| 1332 |
|
* Registers the Jetpack site |
|
@@ 1486-1501 (lines=16) @@
|
| 1483 |
|
* |
| 1484 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 1485 |
|
*/ |
| 1486 |
|
public static function unlink_user( $request ) { |
| 1487 |
|
|
| 1488 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 1489 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1490 |
|
} |
| 1491 |
|
|
| 1492 |
|
if ( Connection_Manager::disconnect_user() ) { |
| 1493 |
|
return rest_ensure_response( |
| 1494 |
|
array( |
| 1495 |
|
'code' => 'success' |
| 1496 |
|
) |
| 1497 |
|
); |
| 1498 |
|
} |
| 1499 |
|
|
| 1500 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1501 |
|
} |
| 1502 |
|
|
| 1503 |
|
/** |
| 1504 |
|
* Gets current user's tracking settings. |