= 6 && substr($host, -6) === '.local') || (strlen($host) >= 5 && substr($host, -5) === '.test') || (bool) preg_match('/^(10\.|192\.168\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)/', $host); wp_remote_post( $api_base . '/v1/integrations/woocommerce/disconnect', [ 'timeout' => 10, 'redirection' => 2, 'reject_unsafe_urls' => !$is_local, 'sslverify' => !$is_local, 'headers' => ['Content-Type' => 'application/json'], 'body' => wp_json_encode([ 'store_url' => rtrim(home_url('/'), '/'), 'webhook_secret' => $secret, ]), 'blocking' => true, ] ); } $options = [ 'agenti_api_base', 'agenti_public_key', 'agenti_webhook_secret', 'agenti_connection_id', 'agenti_bot_color', 'agenti_widget_enabled', 'agenti_store_connected', 'agenti_last_full_sync_at', 'agenti_last_full_sync_count', 'agenti_last_full_sync_failed', 'agenti_last_full_sync_skipped', 'agenti_options_migrated', ]; foreach ($options as $option) { delete_option($option); } $timestamp = wp_next_scheduled('agenti_daily_heartbeat'); if ($timestamp) { wp_unschedule_event($timestamp, 'agenti_daily_heartbeat'); } $full = wp_next_scheduled('agenti_full_catalog_sync'); if ($full) { wp_unschedule_event($full, 'agenti_full_catalog_sync'); } // Clear per-user dismiss + pending connect transients for current installs. global $wpdb; if (isset($wpdb) && $wpdb instanceof wpdb) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = 'agenti_dismiss_connect_notice'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s", $wpdb->esc_like('_transient_agenti_pending_') . '%', $wpdb->esc_like('_transient_timeout_agenti_pending_') . '%', $wpdb->esc_like('_transient_agenti_activation_') . '%', $wpdb->esc_like('_transient_timeout_agenti_activation_') . '%' ) ); }