|
@@ 1421-1433 (lines=13) @@
|
| 1418 |
|
* |
| 1419 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 1420 |
|
*/ |
| 1421 |
|
public static function disconnect_site( $request ) { |
| 1422 |
|
|
| 1423 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 1424 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1425 |
|
} |
| 1426 |
|
|
| 1427 |
|
if ( Jetpack::is_active() ) { |
| 1428 |
|
Jetpack::disconnect(); |
| 1429 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 1430 |
|
} |
| 1431 |
|
|
| 1432 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1433 |
|
} |
| 1434 |
|
|
| 1435 |
|
/** |
| 1436 |
|
* Registers the Jetpack site |
|
@@ 1590-1605 (lines=16) @@
|
| 1587 |
|
* |
| 1588 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 1589 |
|
*/ |
| 1590 |
|
public static function unlink_user( $request ) { |
| 1591 |
|
|
| 1592 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 1593 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1594 |
|
} |
| 1595 |
|
|
| 1596 |
|
if ( Connection_Manager::disconnect_user() ) { |
| 1597 |
|
return rest_ensure_response( |
| 1598 |
|
array( |
| 1599 |
|
'code' => 'success' |
| 1600 |
|
) |
| 1601 |
|
); |
| 1602 |
|
} |
| 1603 |
|
|
| 1604 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1605 |
|
} |
| 1606 |
|
|
| 1607 |
|
/** |
| 1608 |
|
* Gets current user's tracking settings. |