5, 'body' => array( 'client_id' => \StandChat\Connection::client_id(), 'token' => $refresh_token, 'token_type_hint' => 'refresh_token', ), ) ); $code = is_wp_error( $response ) ? 0 : (int) wp_remote_retrieve_response_code( $response ); $answered = $code > 0 && 429 !== $code && $code < 500; } if ( ! $answered ) { // Stand can't take it now, so the rest would wait in vain. break; } } } foreach ( array( 'stand_chat_settings', 'stand_chat_state', 'stand_chat_connection', 'stand_chat_token', 'stand_chat_revocations', 'stand_chat_identity_secret', 'stand_chat_cache_generation', 'stand_chat_source_removals', 'stand_chat_adding', 'stand_chat_claims' ) as $option ) { delete_option( $option ); } delete_transient( 'stand_chat_activation_redirect' ); delete_transient( 'stand_chat_api_backoff' ); global $wpdb; // Cached Stand responses and connect attempts are transients named stand_chat_*. // There is no API to list transients; delete each through the API so caches clear too. // phpcs:ignore WordPress.DB.DirectDatabaseQuery -- One-time cleanup. $stand_chat_transients = $wpdb->get_col( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '\\_transient\\_stand\\_chat\\_%'" ); foreach ( (array) $stand_chat_transients as $stand_chat_transient ) { delete_transient( substr( (string) $stand_chat_transient, strlen( '_transient_' ) ) ); } foreach ( array( '_stand_chat_source_id', '_stand_chat_source_url', '_stand_chat_read_requested' ) as $meta_key ) { delete_post_meta_by_key( $meta_key ); } // Rereads are scheduled for each page: every event of the hook goes, whatever its arguments. wp_unschedule_hook( 'stand_chat_read_again' ); wp_unschedule_hook( 'stand_chat_retry_removals' ); wp_unschedule_hook( 'stand_chat_retry_revocations' ); } if ( is_multisite() ) { // Every site, 100 at a time: get_sites() returns 100 unless told otherwise. $stand_chat_offset = 0; do { $stand_chat_blog_ids = get_sites( array( 'fields' => 'ids', 'number' => 100, 'offset' => $stand_chat_offset, 'orderby' => 'id', ) ); foreach ( $stand_chat_blog_ids as $stand_chat_blog_id ) { switch_to_blog( (int) $stand_chat_blog_id ); stand_chat_uninstall_site(); restore_current_blog(); } $stand_chat_offset += 100; $stand_chat_more = 100 === count( $stand_chat_blog_ids ); } while ( $stand_chat_more ); } else { stand_chat_uninstall_site(); }