|
@@ 1516-1528 (lines=13) @@
|
| 1513 |
|
* |
| 1514 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 1515 |
|
*/ |
| 1516 |
|
public static function disconnect_site( $request ) { |
| 1517 |
|
|
| 1518 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 1519 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1520 |
|
} |
| 1521 |
|
|
| 1522 |
|
if ( Jetpack::is_active() ) { |
| 1523 |
|
Jetpack::disconnect(); |
| 1524 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 1525 |
|
} |
| 1526 |
|
|
| 1527 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1528 |
|
} |
| 1529 |
|
|
| 1530 |
|
/** |
| 1531 |
|
* Registers the Jetpack site |
|
@@ 1686-1701 (lines=16) @@
|
| 1683 |
|
* |
| 1684 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 1685 |
|
*/ |
| 1686 |
|
public static function unlink_user( $request ) { |
| 1687 |
|
|
| 1688 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 1689 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1690 |
|
} |
| 1691 |
|
|
| 1692 |
|
if ( Connection_Manager::disconnect_user() ) { |
| 1693 |
|
return rest_ensure_response( |
| 1694 |
|
array( |
| 1695 |
|
'code' => 'success' |
| 1696 |
|
) |
| 1697 |
|
); |
| 1698 |
|
} |
| 1699 |
|
|
| 1700 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1701 |
|
} |
| 1702 |
|
|
| 1703 |
|
/** |
| 1704 |
|
* Gets current user's tracking settings. |