|
@@ 651-663 (lines=13) @@
|
| 648 |
|
* |
| 649 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 650 |
|
*/ |
| 651 |
|
public static function disconnect_site( $request ) { |
| 652 |
|
|
| 653 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 654 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 655 |
|
} |
| 656 |
|
|
| 657 |
|
if ( Jetpack::is_active() ) { |
| 658 |
|
Jetpack::disconnect(); |
| 659 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 660 |
|
} |
| 661 |
|
|
| 662 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 663 |
|
} |
| 664 |
|
|
| 665 |
|
/** |
| 666 |
|
* Gets a new connect raw URL with fresh nonce. |
|
@@ 771-786 (lines=16) @@
|
| 768 |
|
* |
| 769 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 770 |
|
*/ |
| 771 |
|
public static function unlink_user( $request ) { |
| 772 |
|
|
| 773 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 774 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 775 |
|
} |
| 776 |
|
|
| 777 |
|
if ( Jetpack::unlink_user() ) { |
| 778 |
|
return rest_ensure_response( |
| 779 |
|
array( |
| 780 |
|
'code' => 'success' |
| 781 |
|
) |
| 782 |
|
); |
| 783 |
|
} |
| 784 |
|
|
| 785 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 786 |
|
} |
| 787 |
|
|
| 788 |
|
/** |
| 789 |
|
* Get site data, including for example, the site's current plan. |