|
@@ 1193-1205 (lines=13) @@
|
| 1190 |
|
* |
| 1191 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 1192 |
|
*/ |
| 1193 |
|
public static function disconnect_site( $request ) { |
| 1194 |
|
|
| 1195 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 1196 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1197 |
|
} |
| 1198 |
|
|
| 1199 |
|
if ( Jetpack::is_active() ) { |
| 1200 |
|
Jetpack::disconnect(); |
| 1201 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 1202 |
|
} |
| 1203 |
|
|
| 1204 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1205 |
|
} |
| 1206 |
|
|
| 1207 |
|
/** |
| 1208 |
|
* Registers the Jetpack site |
|
@@ 1359-1374 (lines=16) @@
|
| 1356 |
|
* |
| 1357 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 1358 |
|
*/ |
| 1359 |
|
public static function unlink_user( $request ) { |
| 1360 |
|
|
| 1361 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 1362 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1363 |
|
} |
| 1364 |
|
|
| 1365 |
|
if ( Connection_Manager::disconnect_user() ) { |
| 1366 |
|
return rest_ensure_response( |
| 1367 |
|
array( |
| 1368 |
|
'code' => 'success' |
| 1369 |
|
) |
| 1370 |
|
); |
| 1371 |
|
} |
| 1372 |
|
|
| 1373 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1374 |
|
} |
| 1375 |
|
|
| 1376 |
|
/** |
| 1377 |
|
* Gets current user's tracking settings. |