|
@@ 516-529 (lines=14) @@
|
| 513 |
|
* @since 4.3.0 |
| 514 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 515 |
|
*/ |
| 516 |
|
public static function disconnect_site( $data ) { |
| 517 |
|
$param = $data->get_json_params(); |
| 518 |
|
|
| 519 |
|
if ( ! isset( $param['isActive'] ) || $param['isActive'] !== false ) { |
| 520 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 521 |
|
} |
| 522 |
|
|
| 523 |
|
if ( Jetpack::is_active() ) { |
| 524 |
|
Jetpack::disconnect(); |
| 525 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 526 |
|
} |
| 527 |
|
|
| 528 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 529 |
|
} |
| 530 |
|
|
| 531 |
|
/** |
| 532 |
|
* Gets a new connect raw URL with fresh nonce. |
|
@@ 648-664 (lines=17) @@
|
| 645 |
|
* |
| 646 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 647 |
|
*/ |
| 648 |
|
public static function unlink_user( $data ) { |
| 649 |
|
$param = $data->get_json_params(); |
| 650 |
|
|
| 651 |
|
if ( ! isset( $param['linked'] ) || $param['linked'] !== false ) { |
| 652 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 653 |
|
} |
| 654 |
|
|
| 655 |
|
if ( Jetpack::unlink_user() ) { |
| 656 |
|
return rest_ensure_response( |
| 657 |
|
array( |
| 658 |
|
'code' => 'success' |
| 659 |
|
) |
| 660 |
|
); |
| 661 |
|
} |
| 662 |
|
|
| 663 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 664 |
|
} |
| 665 |
|
|
| 666 |
|
/** |
| 667 |
|
* Get site data, including for example, the site's current plan. |