|
@@ 1105-1117 (lines=13) @@
|
| 1102 |
|
* |
| 1103 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 1104 |
|
*/ |
| 1105 |
|
public static function disconnect_site( $request ) { |
| 1106 |
|
|
| 1107 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 1108 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1109 |
|
} |
| 1110 |
|
|
| 1111 |
|
if ( Jetpack::is_active() ) { |
| 1112 |
|
Jetpack::disconnect(); |
| 1113 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 1114 |
|
} |
| 1115 |
|
|
| 1116 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1117 |
|
} |
| 1118 |
|
|
| 1119 |
|
/** |
| 1120 |
|
* Gets a new connect raw URL with fresh nonce. |
|
@@ 1238-1253 (lines=16) @@
|
| 1235 |
|
* |
| 1236 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 1237 |
|
*/ |
| 1238 |
|
public static function unlink_user( $request ) { |
| 1239 |
|
|
| 1240 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 1241 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1242 |
|
} |
| 1243 |
|
|
| 1244 |
|
if ( Jetpack::unlink_user() ) { |
| 1245 |
|
return rest_ensure_response( |
| 1246 |
|
array( |
| 1247 |
|
'code' => 'success' |
| 1248 |
|
) |
| 1249 |
|
); |
| 1250 |
|
} |
| 1251 |
|
|
| 1252 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1253 |
|
} |
| 1254 |
|
|
| 1255 |
|
/** |
| 1256 |
|
* Gets current user's tracking settings. |