|
@@ 1383-1395 (lines=13) @@
|
| 1380 |
|
* |
| 1381 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 1382 |
|
*/ |
| 1383 |
|
public static function disconnect_site( $request ) { |
| 1384 |
|
|
| 1385 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 1386 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1387 |
|
} |
| 1388 |
|
|
| 1389 |
|
if ( Jetpack::is_active() ) { |
| 1390 |
|
Jetpack::disconnect(); |
| 1391 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 1392 |
|
} |
| 1393 |
|
|
| 1394 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1395 |
|
} |
| 1396 |
|
|
| 1397 |
|
/** |
| 1398 |
|
* Registers the Jetpack site |
|
@@ 1553-1568 (lines=16) @@
|
| 1550 |
|
* |
| 1551 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 1552 |
|
*/ |
| 1553 |
|
public static function unlink_user( $request ) { |
| 1554 |
|
|
| 1555 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 1556 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1557 |
|
} |
| 1558 |
|
|
| 1559 |
|
if ( Connection_Manager::disconnect_user() ) { |
| 1560 |
|
return rest_ensure_response( |
| 1561 |
|
array( |
| 1562 |
|
'code' => 'success' |
| 1563 |
|
) |
| 1564 |
|
); |
| 1565 |
|
} |
| 1566 |
|
|
| 1567 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1568 |
|
} |
| 1569 |
|
|
| 1570 |
|
/** |
| 1571 |
|
* Gets current user's tracking settings. |