|
@@ 1077-1089 (lines=13) @@
|
| 1074 |
|
* |
| 1075 |
|
* @return bool|WP_Error True if Jetpack successfully disconnected. |
| 1076 |
|
*/ |
| 1077 |
|
public static function disconnect_site( $request ) { |
| 1078 |
|
|
| 1079 |
|
if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) { |
| 1080 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1081 |
|
} |
| 1082 |
|
|
| 1083 |
|
if ( Jetpack::is_active() ) { |
| 1084 |
|
Jetpack::disconnect(); |
| 1085 |
|
return rest_ensure_response( array( 'code' => 'success' ) ); |
| 1086 |
|
} |
| 1087 |
|
|
| 1088 |
|
return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1089 |
|
} |
| 1090 |
|
|
| 1091 |
|
/** |
| 1092 |
|
* Gets a new connect raw URL with fresh nonce. |
|
@@ 1210-1225 (lines=16) @@
|
| 1207 |
|
* |
| 1208 |
|
* @return bool|WP_Error True if user successfully unlinked. |
| 1209 |
|
*/ |
| 1210 |
|
public static function unlink_user( $request ) { |
| 1211 |
|
|
| 1212 |
|
if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) { |
| 1213 |
|
return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); |
| 1214 |
|
} |
| 1215 |
|
|
| 1216 |
|
if ( Jetpack::unlink_user() ) { |
| 1217 |
|
return rest_ensure_response( |
| 1218 |
|
array( |
| 1219 |
|
'code' => 'success' |
| 1220 |
|
) |
| 1221 |
|
); |
| 1222 |
|
} |
| 1223 |
|
|
| 1224 |
|
return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); |
| 1225 |
|
} |
| 1226 |
|
|
| 1227 |
|
/** |
| 1228 |
|
* Gets current user's tracking settings. |