query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s", $wpdb->esc_like( '_transient_sranywhere_' ) . '%', $wpdb->esc_like( '_transient_timeout_sranywhere_' ) . '%' ) ); wp_unschedule_hook( 'sranywhere_refresh_start' ); wp_unschedule_hook( 'sranywhere_refresh_connection' ); } /** * Ends an OAuth connection at SR Anywhere, best effort, without loading the plugin (OAuth.php, Connection::disconnect()). */ function sranywhere_uninstall_revoke() { $record = get_option( 'sranywhere_connection', array() ); if ( ! is_array( $record ) || 'oauth' !== ( $record['kind'] ?? '' ) ) { return; } require_once __DIR__ . '/includes/Config.php'; require_once __DIR__ . '/includes/Crypto.php'; $token = SRAnywhere\Crypto::open( $record['refresh'] ?? '' ); if ( null === $token ) { return; } wp_remote_post( SRAnywhere\Config::api_url() . '/api/oauth/revoke', array( 'timeout' => 5, 'redirection' => 0, 'body' => array( 'token' => $token, 'token_type_hint' => 'refresh_token', 'client_id' => (string) ( $record['client_id'] ?? '' ), ), ) ); } if ( is_multisite() ) { foreach ( get_sites( array( 'fields' => 'ids' ) ) as $sranywhere_site ) { switch_to_blog( $sranywhere_site ); sranywhere_uninstall_site(); restore_current_blog(); } } else { sranywhere_uninstall_site(); }