Plugin Directory

Changeset 3363913


Ignore:
Timestamp:
09/18/2025 10:54:00 AM (7 months ago)
Author:
newcodebyte
Message:

Update to 1.6.4 (fixed)

Location:
chatbot-ai-free-models
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • chatbot-ai-free-models/tags/1.6.4/chatbot-admin.php

    r3363841 r3363913  
    563563                MAX(CASE WHEN msg.sender = 'User' THEN msg.ip ELSE NULL END) as ip
    564564            FROM $conversations_table as conv
    565             JOIN $messages_table as msg ON conv.id = msg.conversation_id
     565            LEFT JOIN $messages_table as msg ON conv.id = msg.conversation_id
    566566            GROUP BY conv.id
     567            HAVING COUNT(msg.id) > 0
    567568            ORDER BY conv.start_date DESC
    568569        ";
     
    593594                }
    594595
    595                 // --- LOGICA CORRETTA PER CLASSE E TOOLTIP ---
    596596                $row_class = 'conversation-row';
    597597                if (isset($row['is_read']) && intval($row['is_read']) === 0) {
  • chatbot-ai-free-models/tags/1.6.4/wp-chatbot.php

    r3363841 r3363913  
    7272// =========================================================================
    7373
    74 /**
    75  * Registra le funzioni da eseguire all'attivazione del plugin e nel backend.
    76  */
    77 function newcodebyte_chatbot_on_deactivate() {
    78     delete_transient('newcodebyte_chatbot_db_checked');
    79 }
    80 
    81 register_activation_hook(__FILE__, 'newcodebyte_chatbot_install_or_update');
    8274add_action('admin_init', 'newcodebyte_chatbot_install_or_update');
    8375add_action('admin_notices', 'newcodebyte_chatbot_db_check_notice');
     
    9082
    9183function newcodebyte_chatbot_install_or_update() {
    92     if (get_transient('newcodebyte_chatbot_db_checked')) {
    93         return;
    94     }
    95 
    96     global $wpdb;
    97     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    98 
    99     $messages_table_name = $wpdb->prefix . 'newcodebyte_chatbot_messages';
    100     $sql_messages = "CREATE TABLE $messages_table_name (
    101         id mediumint(9) NOT NULL AUTO_INCREMENT,
    102         conversation_id bigint(20) NOT NULL,
    103         user_name tinytext,
    104         user_email varchar(100),
    105         ip varchar(100) NOT NULL DEFAULT '',
    106         date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    107         sender varchar(50) NOT NULL DEFAULT '',
    108         message text NOT NULL,
    109         is_read tinyint(1) NOT NULL DEFAULT 0,
    110         PRIMARY KEY  (id),
    111         KEY conv_id_idx (conversation_id),
    112         KEY is_read_idx (is_read)
    113     );";
    114     dbDelta($sql_messages);
    115 
    116     $conversations_table_name = $wpdb->prefix . 'newcodebyte_chatbot_conversations';
    117     $sql_conversations = "CREATE TABLE $conversations_table_name (
    118         id bigint(20) NOT NULL AUTO_INCREMENT,
    119         start_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    120         PRIMARY KEY  (id)
    121     );";
    122     dbDelta($sql_conversations);
    123 
    124     set_transient('newcodebyte_chatbot_db_checked', 'yes', HOUR_IN_SECONDS);
     84    // Ottieni la versione del DB che abbiamo salvato l'ultima volta
     85    $current_db_version = get_option('newcodebyte_chatbot_db_version', '1.0');
     86    // Definisci la versione attuale del nostro schema DB
     87    $target_db_version = '1.1'; // Abbiamo introdotto la tabella 'conversations'
     88
     89    // Esegui l'aggiornamento solo se la versione del DB è obsoleta
     90    if (version_compare($current_db_version, $target_db_version, '<')) {
     91       
     92        global $wpdb;
     93        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     94
     95        $messages_table = $wpdb->prefix . 'newcodebyte_chatbot_messages';
     96        $conversations_table = $wpdb->prefix . 'newcodebyte_chatbot_conversations';
     97        $charset_collate = $wpdb->get_charset_collate();
     98
     99        // Usa dbDelta per la tabella dei messaggi (aggiorna la colonna conversation_id)
     100        $sql_messages = "CREATE TABLE {$messages_table} (
     101            id mediumint(9) NOT NULL AUTO_INCREMENT,
     102            conversation_id bigint(20) NOT NULL,
     103            user_name tinytext,
     104            user_email varchar(100),
     105            ip varchar(100) NOT NULL DEFAULT '',
     106            date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
     107            sender varchar(50) NOT NULL DEFAULT '',
     108            message text NOT NULL,
     109            is_read tinyint(1) NOT NULL DEFAULT 0,
     110            PRIMARY KEY  (id),
     111            KEY conv_id_idx (conversation_id),
     112            KEY is_read_idx (is_read)
     113        ) $charset_collate;";
     114        dbDelta($sql_messages);
     115
     116        // Usa una query manuale e diretta per la tabella delle conversazioni (più affidabile)
     117        if ($wpdb->get_var("SHOW TABLES LIKE '{$conversations_table}'") != $conversations_table) {
     118            $sql_conversations = "CREATE TABLE {$conversations_table} (
     119                id bigint(20) NOT NULL AUTO_INCREMENT,
     120                start_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
     121                PRIMARY KEY  (id)
     122            ) $charset_collate;";
     123            $wpdb->query($sql_conversations);
     124        }
     125
     126        // Aggiorna la versione del DB per non rieseguire questo codice
     127        update_option('newcodebyte_chatbot_db_version', $target_db_version);
     128    }
    125129}
    126130
  • chatbot-ai-free-models/trunk/chatbot-admin.php

    r3363876 r3363913  
    550550        <?php
    551551        global $wpdb;
    552         $table_name = $wpdb->prefix . 'newcodebyte_chatbot_messages';
    553 
    554         // Query per raggruppare i messaggi in conversazioni, leggendo dalla tabella MySQL.
     552        $messages_table = $wpdb->prefix . 'newcodebyte_chatbot_messages';
     553        $conversations_table = $wpdb->prefix . 'newcodebyte_chatbot_conversations';
     554
    555555        $conversations_query = "
    556556            SELECT
    557                 conversation_id,
    558                 MAX(CASE WHEN user_name IS NOT NULL AND user_name != '' THEN user_name ELSE NULL END) as user_name,
    559                 MAX(CASE WHEN user_email IS NOT NULL AND user_email != '' THEN user_email ELSE NULL END) as user_email,
    560                 MAX(CASE WHEN sender = 'User' THEN ip ELSE NULL END) as ip,
    561                 MIN(date) as start_date,
    562                 COUNT(id) as message_count
    563             FROM $table_name
    564             WHERE conversation_id IS NOT NULL AND conversation_id != ''
    565             GROUP BY conversation_id
    566             ORDER BY MIN(date) DESC
     557                conv.id as conversation_id,
     558                conv.start_date,
     559                MIN(msg.is_read) as is_read,
     560                COUNT(msg.id) as message_count,
     561                MAX(CASE WHEN msg.user_name IS NOT NULL AND msg.user_name != '' THEN msg.user_name ELSE NULL END) as user_name,
     562                MAX(CASE WHEN msg.user_email IS NOT NULL AND msg.user_email != '' THEN msg.user_email ELSE NULL END) as user_email,
     563                MAX(CASE WHEN msg.sender = 'User' THEN msg.ip ELSE NULL END) as ip
     564            FROM $conversations_table as conv
     565            LEFT JOIN $messages_table as msg ON conv.id = msg.conversation_id
     566            GROUP BY conv.id
     567            HAVING COUNT(msg.id) > 0
     568            ORDER BY conv.start_date DESC
    567569        ";
    568570       
    569         // Eseguiamo la query in modo sicuro
    570571        $conversations = $wpdb->get_results($conversations_query, ARRAY_A);
    571572
     
    578579
    579580                if (!empty($row['user_name'])) {
    580                     $display_name = '<strong>' . esc_html($row['user_name']) . '</strong>';
     581                    $display_name = esc_html($row['user_name']);
    581582                }
    582583
     
    585586                        $user_details = '<br><small>' . esc_html($row['user_email']) . '</small>';
    586587                    } else {
    587                         $display_name = '<strong>' . esc_html($row['user_email']) . '</strong>';
     588                        $display_name = esc_html($row['user_email']);
    588589                    }
    589590                }
    590591
    591592                if (!$display_name) {
    592                     $display_name = '<strong>' . esc_html__('Anonymous User', 'chatbot-ai-free-models') . '</strong>';
     593                    $display_name = esc_html__('Anonymous User', 'chatbot-ai-free-models');
     594                }
     595
     596                $row_class = 'conversation-row';
     597                if (isset($row['is_read']) && intval($row['is_read']) === 0) {
     598                    $row_class .= ' unread';
    593599                }
    594600        ?>
    595                 <tr class="conversation-row" data-conv-id="<?php echo esc_attr($row['conversation_id']); ?>" title="<?php esc_attr_e('Click to view messages', 'chatbot-ai-free-models'); ?>" >
     601                <tr class="<?php echo esc_attr($row_class); ?>" data-conv-id="<?php echo esc_attr($row['conversation_id']); ?>" title="<?php esc_attr_e('Click to view messages', 'chatbot-ai-free-models'); ?>" >
    596602                    <td><?php echo $display_name . $user_details; ?></td>
    597603                    <td><?php echo esc_html($row['ip']); ?></td>
    598604                    <td><?php echo esc_html($row['start_date']); ?></td>
    599605                    <td><?php echo esc_html($row['message_count']); ?></td>
    600                     <td><?php echo esc_html($row['conversation_id']); ?></td>
     606                    <td><?php echo 'Chat_' . esc_html($row['conversation_id']); ?></td>
    601607                </tr>
    602608                <tr class="messages-container" id="messages-for-<?php echo esc_attr($row['conversation_id']); ?>" style="display: none;">
  • chatbot-ai-free-models/trunk/css/chatbot.css

    r3363876 r3363913  
    660660    box-shadow: none;
    661661}
     662
     663/*
     664=====================================================
     665  Stili per Conversazioni Non Lette nel Pannello Admin
     666=====================================================
     667*/
     668#chatbot-conversations-table tr.unread td {
     669    font-weight: bold;
     670}
     671
     672#chatbot-conversations-table tr.unread:hover td {
     673    background-color: #cfcfcf; /* Sfondo leggermente rosato al passaggio del mouse */
     674}
  • chatbot-ai-free-models/trunk/js/chatbot-admin.js

    r3363876 r3363913  
    55        // Definiamo una sola costante per accedere all'oggetto globale. LA USIAMO OVUNQUE.
    66        const adminVars = chatbot_admin_vars;
    7 
    8         // Rimuoviamo la riga "const { ... }" che creava confusione.
    97
    108        function updateCounter(textareaIdPrefix, charactersSpanID, tokensSpanID) {
     
    265263            var $innerBox = $messagesContainer.find('.inner-messages-box');
    266264
     265            // 1. Se la riga è non letta, invia una chiamata AJAX separata per marcarla come letta.
     266            if ($this.hasClass('unread')) {
     267                $this.removeClass('unread');
     268
     269                $.ajax({
     270                    url: adminVars.ajaxurl,
     271                    type: 'POST',
     272                    data: {
     273                        action: 'newcodebyte_chatbot_mark_as_read',
     274                        nonce: adminVars.get_messages_nonce,
     275                        conversation_id: convId
     276                    },
     277                    success: function(response) {
     278                        if (!response.success) {
     279                           $this.addClass('unread');
     280                        }
     281                    },
     282                    error: function(xhr) {
     283                        $this.addClass('unread');
     284                    }
     285                });
     286            }
     287
     288            // 2. Gestisci la visualizzazione dei messaggi (apri/chiudi).
    267289            if ($messagesContainer.is(':visible')) {
    268290                $messagesContainer.slideUp(200);
     
    273295            $('.messages-container').not($messagesContainer).slideUp(200);
    274296            $('.conversation-row').not($this).css('cursor', 'zoom-in').removeClass('is-open');
    275 
    276297            $messagesContainer.slideDown(200);
    277298            $this.css('cursor', 'zoom-out').addClass('is-open');
    278299
     300            // 3. Se i messaggi non sono ancora stati caricati, esegui la chiamata AJAX per caricarli.
    279301            if (!$innerBox.hasClass('loaded')) {
    280302                $.ajax({
     
    287309                    },
    288310                    beforeSend: function() {
    289                         $innerBox.html('<div class="loading-messages">Loading messages...</div>');
     311                        // CORREZIONE: Usa la variabile passata da wp_localize_script
     312                        $innerBox.html('<div class="loading-messages">' + adminVars.loading_messages + '</div>');
    290313                    },
    291314                    success: function(response) {
     
    296319                        }
    297320                    },
    298                     error: function() {
     321                    error: function(xhr) {
    299322                        $innerBox.html('<div class="error-messages">An error occurred while loading messages.</div>');
    300323                    }
  • chatbot-ai-free-models/trunk/js/chatbot.js

    r3363876 r3363913  
    157157        }
    158158
    159         function getConversationId() {
    160             if (currentConversationId) return currentConversationId;
    161             let storedId = null;
    162             try {
    163                 storedId = sessionStorage.getItem('newcodebyteChatbotConversationId');
    164             } catch (e) {
    165                 console.warn('Chatbot: sessionStorage not accessible.');
    166             }
    167 
    168             if (!storedId) {
    169                 storedId = 'chat_' + Date.now();
    170                 try {
    171                     sessionStorage.setItem('newcodebyteChatbotConversationId', storedId);
    172                 } catch (e) {
    173                     console.warn('Chatbot: Could not save ID to sessionStorage.');
    174                 }
    175             }
    176             currentConversationId = storedId;
    177             return currentConversationId;
    178         }
     159function getConversationId() {
     160    if (currentConversationId) return currentConversationId;
     161   
     162    try {
     163        currentConversationId = sessionStorage.getItem('newcodebyteChatbotConversationId');
     164    } catch (e) {
     165        console.warn('Chatbot: sessionStorage not accessible.');
     166    }
     167   
     168    return currentConversationId;
     169}
    179170
    180171        $(window).on('resize scroll', function() {
     
    222213        }
    223214
    224         function sendMessageToServer(message) {
    225             var conversationId = getConversationId();
    226             var ajaxData = {
    227                 action: 'newcodebyte_chatbot_send_message',
    228                 message: message,
    229                 conversation_id: conversationId,
    230                 newcodebyte_chatbot_message_nonce: chatbot_ajax.newcodebyte_chatbot_message_nonce
    231             };
     215function sendMessageToServer(message) {
     216    var conversationId = getConversationId(); // Potrebbe essere null
     217    var ajaxData = {
     218        action: 'newcodebyte_chatbot_send_message',
     219        message: message,
     220        conversation_id: conversationId, // Invia l'ID o null
     221        newcodebyte_chatbot_message_nonce: chatbot_ajax.newcodebyte_chatbot_message_nonce
     222    };
    232223
    233224            if (userInfo) {
     
    248239        }
    249240
    250         function handleServerResponse(response) {
    251             $('.chat-message.loading').remove();
     241function handleServerResponse(response) {
     242    $('.chat-message.loading').remove();
     243   
     244    if (response.success && response.data.conversation_id) {
     245        currentConversationId = response.data.conversation_id;
     246        try {
     247            sessionStorage.setItem('newcodebyteChatbotConversationId', currentConversationId);
     248        } catch (e) {
     249            console.warn('Chatbot: Could not save ID to sessionStorage.');
     250        }
     251    }
    252252           
    253253            if (!response || !response.success || typeof response.data === 'undefined' || typeof response.data.message === 'undefined') {
  • chatbot-ai-free-models/trunk/languages/chatbot-ai-free-models-it_IT.po

    r3363876 r3363913  
    22msgstr ""
    33"Project-Id-Version: Chatbot AI Free\n"
    4 "POT-Creation-Date: 2025-08-21 16:03+0200\n"
    5 "PO-Revision-Date: 2025-08-21 16:13+0200\n"
     4"POT-Creation-Date: 2025-09-18 11:13+0200\n"
     5"PO-Revision-Date: 2025-09-18 11:17+0200\n"
    66"Last-Translator: \n"
    77"Language-Team: \n"
     
    3232#: chatbot-admin.php:67 chatbot-admin.php:123 chatbot-admin.php:186
    3333#: chatbot-admin.php:214 chatbot-admin.php:228 chatbot-admin.php:238
    34 #: wp-chatbot.php:268 wp-chatbot.php:533 wp-chatbot.php:557
     34#: wp-chatbot.php:286 wp-chatbot.php:546 wp-chatbot.php:571
    3535msgid "Security check failed."
    3636msgstr "Controllo di sicurezza fallito."
     
    4141msgstr "Errore"
    4242
    43 #: chatbot-admin.php:74 chatbot-admin.php:256 wp-chatbot.php:227
     43#: chatbot-admin.php:74 chatbot-admin.php:256 wp-chatbot.php:245
    4444msgid "Hello! How can I assist you today?"
    4545msgstr "Ciao! Come posso aiutarti oggi?"
     
    312312msgstr "Descrizione Form"
    313313
    314 #: chatbot-admin.php:499 chatbot-admin.php:523 chatbot-admin.php:682
    315 #: chatbot-admin.php:755 chatbot-admin.php:781 chatbot-admin.php:839
     314#: chatbot-admin.php:499 chatbot-admin.php:523 chatbot-admin.php:688
     315#: chatbot-admin.php:761 chatbot-admin.php:787 chatbot-admin.php:845
    316316msgid "Save settings"
    317317msgstr "Salva impostazioni"
     
    369369msgstr "Nessun messaggio trovato."
    370370
    371 #: chatbot-admin.php:592 wp-chatbot.php:716
     371#: chatbot-admin.php:592 wp-chatbot.php:733
    372372msgid "Anonymous User"
    373373msgstr "Utente Anonimo"
    374374
    375 #: chatbot-admin.php:595
     375#: chatbot-admin.php:601
    376376msgid "Click to view messages"
    377377msgstr "Clicca per vedere i messaggi"
    378378
    379 #: chatbot-admin.php:605
     379#: chatbot-admin.php:611 wp-chatbot.php:859
    380380msgid "Loading messages..."
    381381msgstr "Caricamento dei messaggi..."
    382382
    383 #: chatbot-admin.php:623
     383#: chatbot-admin.php:629
    384384msgid "Header background color"
    385385msgstr "Colore di sfondo dell'intestazione"
    386386
    387 #: chatbot-admin.php:627
     387#: chatbot-admin.php:633
    388388msgid "Header text color"
    389389msgstr "Colore del testo dell'intestazione"
    390390
    391 #: chatbot-admin.php:631
     391#: chatbot-admin.php:637
    392392msgid "Chatbox background color"
    393393msgstr "Colore di sfondo della chatbox"
    394394
    395 #: chatbot-admin.php:635
     395#: chatbot-admin.php:641
    396396msgid "User message background color"
    397397msgstr "Colore di sfondo del messaggio utente"
    398398
    399 #: chatbot-admin.php:639
     399#: chatbot-admin.php:645
    400400msgid "User message text color"
    401401msgstr "Colore del testo del messaggio utente"
    402402
    403 #: chatbot-admin.php:643
     403#: chatbot-admin.php:649
    404404msgid "Bot message background color"
    405405msgstr "Colore di sfondo del messaggio del bot"
    406406
    407 #: chatbot-admin.php:647
     407#: chatbot-admin.php:653
    408408msgid "Bot message text color"
    409409msgstr "Colore del testo del messaggio del bot"
    410410
    411 #: chatbot-admin.php:651
     411#: chatbot-admin.php:657
    412412msgid "Send button background color"
    413413msgstr "Colore di sfondo del pulsante di invio"
    414414
    415 #: chatbot-admin.php:655
     415#: chatbot-admin.php:661
    416416msgid "Send button text color"
    417417msgstr "Colore del testo del pulsante di invio"
    418418
    419 #: chatbot-admin.php:660
     419#: chatbot-admin.php:666
    420420msgid "Chat Window Height"
    421421msgstr "Altezza della Finestra di Chat"
    422422
    423 #: chatbot-admin.php:664
     423#: chatbot-admin.php:670
    424424msgid ""
    425425"Set the height of the chat window on desktop. Default: 600px. (Min: 300, "
     
    429429"(Minimo: 300, Massimo: 1000)"
    430430
    431 #: chatbot-admin.php:668
     431#: chatbot-admin.php:674
    432432msgid "Chatbot Position"
    433433msgstr "Posizione Chatbot"
    434434
    435 #: chatbot-admin.php:672
     435#: chatbot-admin.php:678
    436436msgid "Bottom Right"
    437437msgstr "Basso a destra"
    438438
    439 #: chatbot-admin.php:675
     439#: chatbot-admin.php:681
    440440msgid "Bottom Left"
    441441msgstr "Basso a sinistra"
    442442
    443 #: chatbot-admin.php:678
     443#: chatbot-admin.php:684
    444444msgid "Choose which corner of the screen the chatbot button should appear in."
    445445msgstr ""
    446446"Scegli in quale angolo dello schermo deve apparire il pulsante del chatbot."
    447447
    448 #: chatbot-admin.php:691
     448#: chatbot-admin.php:697
    449449msgid "User Avatar"
    450450msgstr "Avatar Utente"
    451451
    452 #: chatbot-admin.php:695
     452#: chatbot-admin.php:701
    453453msgid "User Avatar Preview"
    454454msgstr "Anteprima Avatar Utente"
    455455
    456 #: chatbot-admin.php:700 chatbot-admin.php:716 chatbot-admin.php:732
    457 #: chatbot-admin.php:748
     456#: chatbot-admin.php:706 chatbot-admin.php:722 chatbot-admin.php:738
     457#: chatbot-admin.php:754
    458458msgid "Upload Image"
    459459msgstr "Carica Immagine"
    460460
    461 #: chatbot-admin.php:703 chatbot-admin.php:719 chatbot-admin.php:735
    462 #: chatbot-admin.php:751
     461#: chatbot-admin.php:709 chatbot-admin.php:725 chatbot-admin.php:741
     462#: chatbot-admin.php:757
    463463msgid "Accepted formats: JPG, PNG, GIF"
    464464msgstr "Formati accettati: JPG, PNG, GIF"
    465465
    466 #: chatbot-admin.php:707
     466#: chatbot-admin.php:713
    467467msgid "Bot Avatar"
    468468msgstr "Avatar Bot"
    469469
    470 #: chatbot-admin.php:711
     470#: chatbot-admin.php:717
    471471msgid "Bot Avatar Preview"
    472472msgstr "Anteprima Avatar Bot"
    473473
    474 #: chatbot-admin.php:723
     474#: chatbot-admin.php:729
    475475msgid "Chat Open Icon"
    476476msgstr "Icona Chat Aperta"
    477477
    478 #: chatbot-admin.php:727
     478#: chatbot-admin.php:733
    479479msgid "Chat Open Icon Preview"
    480480msgstr "Anteprima Icona Chat Aperta"
    481481
    482 #: chatbot-admin.php:739
     482#: chatbot-admin.php:745
    483483msgid "Chat Closed Icon"
    484484msgstr "Icona Chat Chiusa"
    485485
    486 #: chatbot-admin.php:743
     486#: chatbot-admin.php:749
    487487msgid "Chat Closed Icon Preview"
    488488msgstr "Anteprima Icona Chat Chiusa"
    489489
    490 #: chatbot-admin.php:764
     490#: chatbot-admin.php:770
    491491msgid "Notification Sound"
    492492msgstr "Suono di Notifica"
    493493
    494 #: chatbot-admin.php:768
     494#: chatbot-admin.php:774
    495495msgid "Upload Sound"
    496496msgstr "Carica Suono"
    497497
    498 #: chatbot-admin.php:773
     498#: chatbot-admin.php:779
    499499msgid "Current sound file:"
    500500msgstr "File audio attuale:"
    501501
    502 #: chatbot-admin.php:777
     502#: chatbot-admin.php:783
    503503msgid ""
    504504"Upload a custom sound for new notifications (MP3, WAV, or OGG format). If no "
     
    508508"OGG). Se non viene caricato alcun suono, verrà utilizzato quello predefinito."
    509509
    510 #: chatbot-admin.php:786
     510#: chatbot-admin.php:792
    511511msgid "Chatbot AI Free Models - Guide"
    512512msgstr "Chatbot AI Free Models - Guida"
    513513
    514 #: chatbot-admin.php:787
     514#: chatbot-admin.php:793
    515515msgid ""
    516516"Thank you for installing Chatbot AI Free Models! This guide will help you "
     
    520520"configurare il plugin e a ottenere il massimo da esso."
    521521
    522 #: chatbot-admin.php:788
     522#: chatbot-admin.php:794
    523523msgid "Basic Configuration"
    524524msgstr "Configurazione di base"
    525525
    526 #: chatbot-admin.php:789
     526#: chatbot-admin.php:795
    527527msgid ""
    528528"Get an API Key: This plugin uses the OpenRouter API. Get your free API key at"
     
    531531"tua chiave API gratuita su"
    532532
    533 #: chatbot-admin.php:789
     533#: chatbot-admin.php:795
    534534msgid ""
    535535"OpenRouter offers access to over 300 models, including ChatGPT, Claude, "
     
    545545"senza complicazioni!"
    546546
    547 #: chatbot-admin.php:790
     547#: chatbot-admin.php:796
    548548msgid ""
    549549"Enter your API Key: Go to the \"Settings\" tab and enter your OpenRouter API "
     
    553553"tua chiave API OpenRouter nel campo \"Chiave API\"."
    554554
    555 #: chatbot-admin.php:791
     555#: chatbot-admin.php:797
    556556msgid ""
    557557"Choose a Model: Select an AI model from the \"Model\" dropdown. Free models "
     
    566566"indipendentemente dal provider originale."
    567567
    568 #: chatbot-admin.php:792
     568#: chatbot-admin.php:798
    569569msgid ""
    570570"Provide Context: In the \"Information for responses\" field, enter "
     
    575575"rispondere alle query degli utenti in modo più accurato."
    576576
    577 #: chatbot-admin.php:793
     577#: chatbot-admin.php:799
    578578msgid ""
    579579"Set the bot's behavior: In the \"Behavior type\" field, enter instructions "
     
    583583"inserisci istruzioni sul comportamento del bot."
    584584
    585 #: chatbot-admin.php:794
     585#: chatbot-admin.php:800
    586586msgid ""
    587587"Save Settings: Click \"Save settings\". Remember to refresh your website "
     
    594594"correttamente a causa della cache."
    595595
    596 #: chatbot-admin.php:795
     596#: chatbot-admin.php:801
    597597msgid "Customization"
    598598msgstr "Personalizzazione"
    599599
    600 #: chatbot-admin.php:796
     600#: chatbot-admin.php:802
    601601msgid ""
    602602"You can customize the appearance of the chatbot in the \"Style\" and \"Images"
     
    606606"\"."
    607607
    608 #: chatbot-admin.php:797
     608#: chatbot-admin.php:803
    609609msgid ""
    610610"Style: Change the colors of the header, chatbox, messages, and send button."
     
    613613"pulsante di invio."
    614614
    615 #: chatbot-admin.php:798
     615#: chatbot-admin.php:804
    616616msgid ""
    617617"Images: Change the avatars for the user and bot, and the icons for the chat "
     
    621621"della chat."
    622622
    623 #: chatbot-admin.php:799
     623#: chatbot-admin.php:805
    624624msgid ""
    625625"Sounds: In the tab \"Sounds\", you can change the default sound when opening "
     
    630630"un file audio in formato MP3."
    631631
    632 #: chatbot-admin.php:800
     632#: chatbot-admin.php:806
    633633msgid "Troubleshooting"
    634634msgstr "Risoluzione dei problemi"
    635635
    636 #: chatbot-admin.php:801
     636#: chatbot-admin.php:807
    637637msgid ""
    638638"Changes not appearing? After making changes, press Ctrl+F5 (or Cmd+Shift+R "
     
    643643"del browser."
    644644
    645 #: chatbot-admin.php:802
     645#: chatbot-admin.php:808
    646646msgid ""
    647647"Bot not responding? Check your API key and make sure it's valid. Also, check "
     
    652652"se ci sono problemi noti."
    653653
    654 #: chatbot-admin.php:803
     654#: chatbot-admin.php:809
    655655msgid "Managing Messages"
    656656msgstr "Gestione dei messaggi"
    657657
    658 #: chatbot-admin.php:804
     658#: chatbot-admin.php:810
    659659msgid "You can view and export the messages in the \"Messages\" tab."
    660660msgstr "Puoi visualizzare ed esportare i messaggi nella scheda \"Messaggi\"."
    661661
    662 #: chatbot-admin.php:805
     662#: chatbot-admin.php:811
    663663msgid "View: See all chat messages."
    664664msgstr "Visualizza: visualizza tutti i messaggi della chat."
    665665
    666 #: chatbot-admin.php:806
     666#: chatbot-admin.php:812
    667667msgid "Export: Export the messages in various formats (TXT, CSV, MD, HTML)."
    668668msgstr "Esporta: esporta i messaggi in vari formati (TXT, CSV, MD, HTML)."
    669669
    670 #: chatbot-admin.php:807
     670#: chatbot-admin.php:813
    671671msgid "Delete: Delete all chat messages."
    672672msgstr "Elimina: elimina tutti i messaggi della chat."
    673673
    674 #: chatbot-admin.php:808
     674#: chatbot-admin.php:814
    675675msgid "Saving messages"
    676676msgstr "Salvataggio messaggi"
    677677
    678 #: chatbot-admin.php:809
     678#: chatbot-admin.php:815
    679679msgid "You can enable or disable saving messages in the \"Messages\" tab."
    680680msgstr ""
     
    682682"\"Messaggi\"."
    683683
    684 #: chatbot-admin.php:810
     684#: chatbot-admin.php:816
    685685msgid ""
    686686"If enabled, all chat messages and IP will be saved in the database. If "
     
    690690"database. Se disabilitato, nessun messaggio della chat verrà salvato."
    691691
    692 #: chatbot-admin.php:811
     692#: chatbot-admin.php:817
    693693msgid ""
    694694"Important: If you enable message saving, be sure to update your privacy "
     
    698698"la tua politica sulla privacy per riflettere questa pratica di raccolta dati."
    699699
    700 #: chatbot-admin.php:812
     700#: chatbot-admin.php:818
    701701msgid "Enabling \"Powered by NewCodeByte\""
    702702msgstr "Abilitazione di \"Powered by NewCodeByte\""
    703703
    704 #: chatbot-admin.php:813
     704#: chatbot-admin.php:819
    705705msgid ""
    706706"Enabling \"Powered by NewCodeByte\" helps me support the development of this "
     
    712712"favore considera di abilitarlo!"
    713713
    714 #: chatbot-admin.php:816
     714#: chatbot-admin.php:822
    715715#, php-format
    716716msgid ""
     
    721721"supportarmi con una donazione su Buy Me a Coffee tramite %s."
    722722
    723 #: chatbot-admin.php:817
     723#: chatbot-admin.php:823
    724724msgid "Buy Me a Coffee"
    725725msgstr "Buy Me a Coffee"
    726726
    727 #: chatbot-admin.php:819
     727#: chatbot-admin.php:825
    728728msgid ""
    729729"All donations are greatly appreciated and will help me continue to improve "
     
    733733"migliorare e mantenere questo plugin."
    734734
    735 #: chatbot-admin.php:827
     735#: chatbot-admin.php:833
    736736msgid "Show \"Powered by NewCodeByte\"?"
    737737msgstr "Mostrare \"Powered by NewCodeByte\"?"
    738738
    739 #: chatbot-admin.php:834
     739#: chatbot-admin.php:840
    740740msgid "Yes, show the link to support the plugin."
    741741msgstr "Sì, mostra il link per supportare il plugin."
    742742
    743 #: chatbot-admin.php:849
     743#: chatbot-admin.php:855
    744744msgid ""
    745745"Boost visitor engagement with a powerful AI Chatbot for WordPress. "
     
    755755"una singola chiave API facile da usare."
    756756
    757 #: chatbot-admin.php:859
     757#: chatbot-admin.php:865
    758758msgid ""
    759759"The complete manager for external links. Opens in new tabs, handles dynamic "
     
    768768"scelta professionale per i siti moderni."
    769769
    770 #: chatbot-admin.php:869
     770#: chatbot-admin.php:875
    771771msgid ""
    772772"Your all-in-one suite for total link control and site maintenance. Manage "
     
    782782"link rotti dal tuo sito. La scelta professionale per ottimizzare la tua SEO."
    783783
    784 #: wp-chatbot.php:137
     784#: wp-chatbot.php:144
    785785msgid "Chatbot AI - Action Required:"
    786786msgstr "Chatbot AI - Azione Richiesta:"
    787787
    788 #: wp-chatbot.php:138
     788#: wp-chatbot.php:145
    789789msgid ""
    790790"The chatbot database setup is incomplete. Please deactivate and reactivate "
     
    795795"l'installazione."
    796796
    797 #: wp-chatbot.php:152
     797#: wp-chatbot.php:159 wp-chatbot.php:490 wp-chatbot.php:870
     798msgid "Chatbot"
     799msgstr "Chatbot"
     800
     801#: wp-chatbot.php:170
    798802msgid "Chatbot Settings"
    799803msgstr "Impostazioni Chatbot"
    800804
    801 #: wp-chatbot.php:153 wp-chatbot.php:475 wp-chatbot.php:852
    802 msgid "Chatbot"
    803 msgstr "Chatbot"
    804 
    805 #: wp-chatbot.php:224 wp-chatbot.php:489 wp-chatbot.php:862
     805#: wp-chatbot.php:242 wp-chatbot.php:504 wp-chatbot.php:880
    806806msgid "Type your message..."
    807807msgstr "Scrivi un messaggio..."
    808808
    809 #: wp-chatbot.php:225 wp-chatbot.php:490 wp-chatbot.php:863
     809#: wp-chatbot.php:243 wp-chatbot.php:505 wp-chatbot.php:881
    810810msgid "Send"
    811811msgstr "Invia"
    812812
    813 #: wp-chatbot.php:226
     813#: wp-chatbot.php:244
    814814msgid "There was an error."
    815815msgstr "Si è verificato un errore."
    816816
    817 #: wp-chatbot.php:230
     817#: wp-chatbot.php:248
    818818msgid "Before we start chatting"
    819819msgstr "Prima di iniziare a chattare"
    820820
    821 #: wp-chatbot.php:231
     821#: wp-chatbot.php:249
    822822msgid "Please provide the following information:"
    823823msgstr "Per favore, inserisci le seguenti informazioni:"
    824824
    825 #: wp-chatbot.php:232
     825#: wp-chatbot.php:250
    826826msgid "Name"
    827827msgstr "Nome"
    828828
    829 #: wp-chatbot.php:233
     829#: wp-chatbot.php:251
    830830msgid "Email"
    831831msgstr "Email"
    832832
    833 #: wp-chatbot.php:234
     833#: wp-chatbot.php:252
    834834msgid "Start Chat"
    835835msgstr "Avvia Chat"
    836836
    837 #: wp-chatbot.php:235
     837#: wp-chatbot.php:253
    838838msgid "Please fill in all required fields."
    839839msgstr "Per favore, compila tutti i campi obbligatori."
    840840
    841 #: wp-chatbot.php:248
     841#: wp-chatbot.php:266
    842842msgid "Have a question? Ask me!"
    843843msgstr "Hai una domanda? Chiedi pure!"
    844844
    845 #: wp-chatbot.php:340 wp-chatbot.php:454 wp-chatbot.php:471
     845#: wp-chatbot.php:355 wp-chatbot.php:469 wp-chatbot.php:486
    846846msgid "Sorry, I was unable to get a response from the server."
    847847msgstr ""
    848848"Siamo spiacenti, non è stato possibile ottenere una risposta dal server."
    849849
    850 #: wp-chatbot.php:341
     850#: wp-chatbot.php:356
    851851msgid "API Error:"
    852852msgstr "Errore API:"
    853853
    854 #: wp-chatbot.php:397
     854#: wp-chatbot.php:412
    855855#, php-format
    856856msgid ""
     
    867867"%3$s"
    868868
    869 #: wp-chatbot.php:413
     869#: wp-chatbot.php:428
    870870msgid "You are a helpful assistant."
    871871msgstr "Sei un assistente molto disponibile."
    872872
    873 #: wp-chatbot.php:467
     873#: wp-chatbot.php:482
    874874#, php-format
    875875msgid "API Error: %s"
    876876msgstr "Errore API: %s"
    877877
    878 #: wp-chatbot.php:497 wp-chatbot.php:867
     878#: wp-chatbot.php:512 wp-chatbot.php:885
    879879#, php-format
    880880msgid "Powered by %s"
    881881msgstr "Powered by %s"
    882882
    883 #: wp-chatbot.php:529 wp-chatbot.php:553
     883#: wp-chatbot.php:542 wp-chatbot.php:567
    884884msgid "You do not have permission to perform this action."
    885885msgstr "Non hai l'autorizzazione per eseguire questa azione."
    886886
    887 #: wp-chatbot.php:544
     887#: wp-chatbot.php:559
    888888msgid "All messages have been deleted."
    889889msgstr "Tutti i messaggi sono stati eliminati."
    890890
    891 #: wp-chatbot.php:561
     891#: wp-chatbot.php:575
    892892msgid "Export format not specified."
    893893msgstr "Formato di esportazione non specificato."
    894894
    895 #: wp-chatbot.php:568
     895#: wp-chatbot.php:582
    896896msgid "Invalid format specified."
    897897msgstr "Formato di esportazione non specificato."
    898898
    899 #: wp-chatbot.php:834
     899#: wp-chatbot.php:851
    900900msgid "Are you sure you want to delete all messages?"
    901901msgstr "Sei sicuro di voler eliminare tutti i messaggi?"
    902902
    903 #: wp-chatbot.php:835
     903#: wp-chatbot.php:852
    904904msgid "Error while deleting messages."
    905905msgstr "Errore durante l'eliminazione dei messaggi."
    906906
    907 #: wp-chatbot.php:836
     907#: wp-chatbot.php:853
    908908msgid "Select an export format."
    909909msgstr "Seleziona un formato di esportazione."
    910910
    911 #: wp-chatbot.php:837
     911#: wp-chatbot.php:854
    912912msgid "Error loading the image."
    913913msgstr "Errore durante il caricamento dell'immagine."
    914914
    915 #: wp-chatbot.php:838
     915#: wp-chatbot.php:855
    916916msgid "Choose an Image"
    917917msgstr "Scegli una Immagine"
    918918
    919 #: wp-chatbot.php:839
     919#: wp-chatbot.php:856
    920920msgid "Use this Image"
    921921msgstr "Usa questa Immagine"
     922
     923#: wp-chatbot.php:1034
     924#, php-format
     925msgid "You have %d unread conversation."
     926msgid_plural "You have %d unread conversations."
     927msgstr[0] "Hai %d conversazione non letta."
     928msgstr[1] "Hai %d conversazioni non lette."
    922929
    923930#. Plugin Name of the plugin/theme
  • chatbot-ai-free-models/trunk/languages/chatbot-ai-free-models.pot

    r3363876 r3363913  
    33msgstr ""
    44"Project-Id-Version: Chatbot AI Free\n"
    5 "POT-Creation-Date: 2025-08-21 16:03+0200\n"
     5"POT-Creation-Date: 2025-09-18 11:13+0200\n"
    66"PO-Revision-Date: 2025-02-06 12:35+0100\n"
    77"Last-Translator: \n"
     
    3232#: chatbot-admin.php:67 chatbot-admin.php:123 chatbot-admin.php:186
    3333#: chatbot-admin.php:214 chatbot-admin.php:228 chatbot-admin.php:238
    34 #: wp-chatbot.php:268 wp-chatbot.php:533 wp-chatbot.php:557
     34#: wp-chatbot.php:286 wp-chatbot.php:546 wp-chatbot.php:571
    3535msgid "Security check failed."
    3636msgstr ""
     
    4141msgstr ""
    4242
    43 #: chatbot-admin.php:74 chatbot-admin.php:256 wp-chatbot.php:227
     43#: chatbot-admin.php:74 chatbot-admin.php:256 wp-chatbot.php:245
    4444msgid "Hello! How can I assist you today?"
    4545msgstr ""
     
    281281msgstr ""
    282282
    283 #: chatbot-admin.php:499 chatbot-admin.php:523 chatbot-admin.php:682
    284 #: chatbot-admin.php:755 chatbot-admin.php:781 chatbot-admin.php:839
     283#: chatbot-admin.php:499 chatbot-admin.php:523 chatbot-admin.php:688
     284#: chatbot-admin.php:761 chatbot-admin.php:787 chatbot-admin.php:845
    285285msgid "Save settings"
    286286msgstr ""
     
    336336msgstr ""
    337337
    338 #: chatbot-admin.php:592 wp-chatbot.php:716
     338#: chatbot-admin.php:592 wp-chatbot.php:733
    339339msgid "Anonymous User"
    340340msgstr ""
    341341
    342 #: chatbot-admin.php:595
     342#: chatbot-admin.php:601
    343343msgid "Click to view messages"
    344344msgstr ""
    345345
    346 #: chatbot-admin.php:605
     346#: chatbot-admin.php:611 wp-chatbot.php:859
    347347msgid "Loading messages..."
    348348msgstr ""
    349349
    350 #: chatbot-admin.php:623
     350#: chatbot-admin.php:629
    351351msgid "Header background color"
    352352msgstr ""
    353353
    354 #: chatbot-admin.php:627
     354#: chatbot-admin.php:633
    355355msgid "Header text color"
    356356msgstr ""
    357357
    358 #: chatbot-admin.php:631
     358#: chatbot-admin.php:637
    359359msgid "Chatbox background color"
    360360msgstr ""
    361361
    362 #: chatbot-admin.php:635
     362#: chatbot-admin.php:641
    363363msgid "User message background color"
    364364msgstr ""
    365365
    366 #: chatbot-admin.php:639
     366#: chatbot-admin.php:645
    367367msgid "User message text color"
    368368msgstr ""
    369369
    370 #: chatbot-admin.php:643
     370#: chatbot-admin.php:649
    371371msgid "Bot message background color"
    372372msgstr ""
    373373
    374 #: chatbot-admin.php:647
     374#: chatbot-admin.php:653
    375375msgid "Bot message text color"
    376376msgstr ""
    377377
    378 #: chatbot-admin.php:651
     378#: chatbot-admin.php:657
    379379msgid "Send button background color"
    380380msgstr ""
    381381
    382 #: chatbot-admin.php:655
     382#: chatbot-admin.php:661
    383383msgid "Send button text color"
    384384msgstr ""
    385385
    386 #: chatbot-admin.php:660
     386#: chatbot-admin.php:666
    387387msgid "Chat Window Height"
    388388msgstr ""
    389389
    390 #: chatbot-admin.php:664
     390#: chatbot-admin.php:670
    391391msgid ""
    392392"Set the height of the chat window on desktop. Default: 600px. (Min: 300, "
     
    394394msgstr ""
    395395
    396 #: chatbot-admin.php:668
     396#: chatbot-admin.php:674
    397397msgid "Chatbot Position"
    398398msgstr ""
    399399
    400 #: chatbot-admin.php:672
     400#: chatbot-admin.php:678
    401401msgid "Bottom Right"
    402402msgstr ""
    403403
    404 #: chatbot-admin.php:675
     404#: chatbot-admin.php:681
    405405msgid "Bottom Left"
    406406msgstr ""
    407407
    408 #: chatbot-admin.php:678
     408#: chatbot-admin.php:684
    409409msgid "Choose which corner of the screen the chatbot button should appear in."
    410410msgstr ""
    411411
    412 #: chatbot-admin.php:691
     412#: chatbot-admin.php:697
    413413msgid "User Avatar"
    414414msgstr ""
    415415
    416 #: chatbot-admin.php:695
     416#: chatbot-admin.php:701
    417417msgid "User Avatar Preview"
    418418msgstr ""
    419419
    420 #: chatbot-admin.php:700 chatbot-admin.php:716 chatbot-admin.php:732
    421 #: chatbot-admin.php:748
     420#: chatbot-admin.php:706 chatbot-admin.php:722 chatbot-admin.php:738
     421#: chatbot-admin.php:754
    422422msgid "Upload Image"
    423423msgstr ""
    424424
    425 #: chatbot-admin.php:703 chatbot-admin.php:719 chatbot-admin.php:735
    426 #: chatbot-admin.php:751
     425#: chatbot-admin.php:709 chatbot-admin.php:725 chatbot-admin.php:741
     426#: chatbot-admin.php:757
    427427msgid "Accepted formats: JPG, PNG, GIF"
    428428msgstr ""
    429429
    430 #: chatbot-admin.php:707
     430#: chatbot-admin.php:713
    431431msgid "Bot Avatar"
    432432msgstr ""
    433433
    434 #: chatbot-admin.php:711
     434#: chatbot-admin.php:717
    435435msgid "Bot Avatar Preview"
    436436msgstr ""
    437437
    438 #: chatbot-admin.php:723
     438#: chatbot-admin.php:729
    439439msgid "Chat Open Icon"
    440440msgstr ""
    441441
    442 #: chatbot-admin.php:727
     442#: chatbot-admin.php:733
    443443msgid "Chat Open Icon Preview"
    444444msgstr ""
    445445
    446 #: chatbot-admin.php:739
     446#: chatbot-admin.php:745
    447447msgid "Chat Closed Icon"
    448448msgstr ""
    449449
    450 #: chatbot-admin.php:743
     450#: chatbot-admin.php:749
    451451msgid "Chat Closed Icon Preview"
    452452msgstr ""
    453453
    454 #: chatbot-admin.php:764
     454#: chatbot-admin.php:770
    455455msgid "Notification Sound"
    456456msgstr ""
    457457
    458 #: chatbot-admin.php:768
     458#: chatbot-admin.php:774
    459459msgid "Upload Sound"
    460460msgstr ""
    461461
    462 #: chatbot-admin.php:773
     462#: chatbot-admin.php:779
    463463msgid "Current sound file:"
    464464msgstr ""
    465465
    466 #: chatbot-admin.php:777
     466#: chatbot-admin.php:783
    467467msgid ""
    468468"Upload a custom sound for new notifications (MP3, WAV, or OGG format). If no "
     
    470470msgstr ""
    471471
    472 #: chatbot-admin.php:786
     472#: chatbot-admin.php:792
    473473msgid "Chatbot AI Free Models - Guide"
    474474msgstr ""
    475475
    476 #: chatbot-admin.php:787
     476#: chatbot-admin.php:793
    477477msgid ""
    478478"Thank you for installing Chatbot AI Free Models! This guide will help you "
     
    480480msgstr ""
    481481
    482 #: chatbot-admin.php:788
     482#: chatbot-admin.php:794
    483483msgid "Basic Configuration"
    484484msgstr ""
    485485
    486 #: chatbot-admin.php:789
     486#: chatbot-admin.php:795
    487487msgid ""
    488488"Get an API Key: This plugin uses the OpenRouter API. Get your free API key at"
    489489msgstr ""
    490490
    491 #: chatbot-admin.php:789
     491#: chatbot-admin.php:795
    492492msgid ""
    493493"OpenRouter offers access to over 300 models, including ChatGPT, Claude, "
     
    498498msgstr ""
    499499
    500 #: chatbot-admin.php:790
     500#: chatbot-admin.php:796
    501501msgid ""
    502502"Enter your API Key: Go to the \"Settings\" tab and enter your OpenRouter API "
     
    504504msgstr ""
    505505
    506 #: chatbot-admin.php:791
     506#: chatbot-admin.php:797
    507507msgid ""
    508508"Choose a Model: Select an AI model from the \"Model\" dropdown. Free models "
     
    512512msgstr ""
    513513
    514 #: chatbot-admin.php:792
     514#: chatbot-admin.php:798
    515515msgid ""
    516516"Provide Context: In the \"Information for responses\" field, enter "
     
    518518msgstr ""
    519519
    520 #: chatbot-admin.php:793
     520#: chatbot-admin.php:799
    521521msgid ""
    522522"Set the bot's behavior: In the \"Behavior type\" field, enter instructions "
     
    524524msgstr ""
    525525
    526 #: chatbot-admin.php:794
     526#: chatbot-admin.php:800
    527527msgid ""
    528528"Save Settings: Click \"Save settings\". Remember to refresh your website "
     
    531531msgstr ""
    532532
    533 #: chatbot-admin.php:795
     533#: chatbot-admin.php:801
    534534msgid "Customization"
    535535msgstr ""
    536536
    537 #: chatbot-admin.php:796
     537#: chatbot-admin.php:802
    538538msgid ""
    539539"You can customize the appearance of the chatbot in the \"Style\" and \"Images"
     
    541541msgstr ""
    542542
    543 #: chatbot-admin.php:797
     543#: chatbot-admin.php:803
    544544msgid ""
    545545"Style: Change the colors of the header, chatbox, messages, and send button."
    546546msgstr ""
    547547
    548 #: chatbot-admin.php:798
     548#: chatbot-admin.php:804
    549549msgid ""
    550550"Images: Change the avatars for the user and bot, and the icons for the chat "
     
    552552msgstr ""
    553553
    554 #: chatbot-admin.php:799
     554#: chatbot-admin.php:805
    555555msgid ""
    556556"Sounds: In the tab \"Sounds\", you can change the default sound when opening "
     
    558558msgstr ""
    559559
    560 #: chatbot-admin.php:800
     560#: chatbot-admin.php:806
    561561msgid "Troubleshooting"
    562562msgstr ""
    563563
    564 #: chatbot-admin.php:801
     564#: chatbot-admin.php:807
    565565msgid ""
    566566"Changes not appearing? After making changes, press Ctrl+F5 (or Cmd+Shift+R "
     
    568568msgstr ""
    569569
    570 #: chatbot-admin.php:802
     570#: chatbot-admin.php:808
    571571msgid ""
    572572"Bot not responding? Check your API key and make sure it's valid. Also, check "
     
    574574msgstr ""
    575575
    576 #: chatbot-admin.php:803
     576#: chatbot-admin.php:809
    577577msgid "Managing Messages"
    578578msgstr ""
    579579
    580 #: chatbot-admin.php:804
     580#: chatbot-admin.php:810
    581581msgid "You can view and export the messages in the \"Messages\" tab."
    582582msgstr ""
    583583
    584 #: chatbot-admin.php:805
     584#: chatbot-admin.php:811
    585585msgid "View: See all chat messages."
    586586msgstr ""
    587587
    588 #: chatbot-admin.php:806
     588#: chatbot-admin.php:812
    589589msgid "Export: Export the messages in various formats (TXT, CSV, MD, HTML)."
    590590msgstr ""
    591591
    592 #: chatbot-admin.php:807
     592#: chatbot-admin.php:813
    593593msgid "Delete: Delete all chat messages."
    594594msgstr ""
    595595
    596 #: chatbot-admin.php:808
     596#: chatbot-admin.php:814
    597597msgid "Saving messages"
    598598msgstr ""
    599599
    600 #: chatbot-admin.php:809
     600#: chatbot-admin.php:815
    601601msgid "You can enable or disable saving messages in the \"Messages\" tab."
    602602msgstr ""
    603603
    604 #: chatbot-admin.php:810
     604#: chatbot-admin.php:816
    605605msgid ""
    606606"If enabled, all chat messages and IP will be saved in the database. If "
     
    608608msgstr ""
    609609
    610 #: chatbot-admin.php:811
     610#: chatbot-admin.php:817
    611611msgid ""
    612612"Important: If you enable message saving, be sure to update your privacy "
     
    614614msgstr ""
    615615
    616 #: chatbot-admin.php:812
     616#: chatbot-admin.php:818
    617617msgid "Enabling \"Powered by NewCodeByte\""
    618618msgstr ""
    619619
    620 #: chatbot-admin.php:813
     620#: chatbot-admin.php:819
    621621msgid ""
    622622"Enabling \"Powered by NewCodeByte\" helps me support the development of this "
     
    625625msgstr ""
    626626
    627 #: chatbot-admin.php:816
     627#: chatbot-admin.php:822
    628628#, php-format
    629629msgid ""
     
    632632msgstr ""
    633633
    634 #: chatbot-admin.php:817
     634#: chatbot-admin.php:823
    635635msgid "Buy Me a Coffee"
    636636msgstr ""
    637637
    638 #: chatbot-admin.php:819
     638#: chatbot-admin.php:825
    639639msgid ""
    640640"All donations are greatly appreciated and will help me continue to improve "
     
    642642msgstr ""
    643643
    644 #: chatbot-admin.php:827
     644#: chatbot-admin.php:833
    645645msgid "Show \"Powered by NewCodeByte\"?"
    646646msgstr ""
    647647
    648 #: chatbot-admin.php:834
     648#: chatbot-admin.php:840
    649649msgid "Yes, show the link to support the plugin."
    650650msgstr ""
    651651
    652 #: chatbot-admin.php:849
     652#: chatbot-admin.php:855
    653653msgid ""
    654654"Boost visitor engagement with a powerful AI Chatbot for WordPress. "
     
    659659msgstr ""
    660660
    661 #: chatbot-admin.php:859
     661#: chatbot-admin.php:865
    662662msgid ""
    663663"The complete manager for external links. Opens in new tabs, handles dynamic "
     
    667667msgstr ""
    668668
    669 #: chatbot-admin.php:869
     669#: chatbot-admin.php:875
    670670msgid ""
    671671"Your all-in-one suite for total link control and site maintenance. Manage "
     
    676676msgstr ""
    677677
    678 #: wp-chatbot.php:137
     678#: wp-chatbot.php:144
    679679msgid "Chatbot AI - Action Required:"
    680680msgstr ""
    681681
    682 #: wp-chatbot.php:138
     682#: wp-chatbot.php:145
    683683msgid ""
    684684"The chatbot database setup is incomplete. Please deactivate and reactivate "
     
    686686msgstr ""
    687687
    688 #: wp-chatbot.php:152
     688#: wp-chatbot.php:159 wp-chatbot.php:490 wp-chatbot.php:870
     689msgid "Chatbot"
     690msgstr ""
     691
     692#: wp-chatbot.php:170
    689693msgid "Chatbot Settings"
    690694msgstr ""
    691695
    692 #: wp-chatbot.php:153 wp-chatbot.php:475 wp-chatbot.php:852
    693 msgid "Chatbot"
    694 msgstr ""
    695 
    696 #: wp-chatbot.php:224 wp-chatbot.php:489 wp-chatbot.php:862
     696#: wp-chatbot.php:242 wp-chatbot.php:504 wp-chatbot.php:880
    697697msgid "Type your message..."
    698698msgstr ""
    699699
    700 #: wp-chatbot.php:225 wp-chatbot.php:490 wp-chatbot.php:863
     700#: wp-chatbot.php:243 wp-chatbot.php:505 wp-chatbot.php:881
    701701msgid "Send"
    702702msgstr ""
    703703
    704 #: wp-chatbot.php:226
     704#: wp-chatbot.php:244
    705705msgid "There was an error."
    706706msgstr ""
    707707
    708 #: wp-chatbot.php:230
     708#: wp-chatbot.php:248
    709709msgid "Before we start chatting"
    710710msgstr ""
    711711
    712 #: wp-chatbot.php:231
     712#: wp-chatbot.php:249
    713713msgid "Please provide the following information:"
    714714msgstr ""
    715715
    716 #: wp-chatbot.php:232
     716#: wp-chatbot.php:250
    717717msgid "Name"
    718718msgstr ""
    719719
    720 #: wp-chatbot.php:233
     720#: wp-chatbot.php:251
    721721msgid "Email"
    722722msgstr ""
    723723
    724 #: wp-chatbot.php:234
     724#: wp-chatbot.php:252
    725725msgid "Start Chat"
    726726msgstr ""
    727727
    728 #: wp-chatbot.php:235
     728#: wp-chatbot.php:253
    729729msgid "Please fill in all required fields."
    730730msgstr ""
    731731
    732 #: wp-chatbot.php:248
     732#: wp-chatbot.php:266
    733733msgid "Have a question? Ask me!"
    734734msgstr ""
    735735
    736 #: wp-chatbot.php:340 wp-chatbot.php:454 wp-chatbot.php:471
     736#: wp-chatbot.php:355 wp-chatbot.php:469 wp-chatbot.php:486
    737737msgid "Sorry, I was unable to get a response from the server."
    738738msgstr ""
    739739
    740 #: wp-chatbot.php:341
     740#: wp-chatbot.php:356
    741741msgid "API Error:"
    742742msgstr ""
    743743
    744 #: wp-chatbot.php:397
     744#: wp-chatbot.php:412
    745745#, php-format
    746746msgid ""
     
    752752msgstr ""
    753753
    754 #: wp-chatbot.php:413
     754#: wp-chatbot.php:428
    755755msgid "You are a helpful assistant."
    756756msgstr ""
    757757
    758 #: wp-chatbot.php:467
     758#: wp-chatbot.php:482
    759759#, php-format
    760760msgid "API Error: %s"
    761761msgstr ""
    762762
    763 #: wp-chatbot.php:497 wp-chatbot.php:867
     763#: wp-chatbot.php:512 wp-chatbot.php:885
    764764#, php-format
    765765msgid "Powered by %s"
    766766msgstr ""
    767767
    768 #: wp-chatbot.php:529 wp-chatbot.php:553
     768#: wp-chatbot.php:542 wp-chatbot.php:567
    769769msgid "You do not have permission to perform this action."
    770770msgstr ""
    771771
    772 #: wp-chatbot.php:544
     772#: wp-chatbot.php:559
    773773msgid "All messages have been deleted."
    774774msgstr ""
    775775
    776 #: wp-chatbot.php:561
     776#: wp-chatbot.php:575
    777777msgid "Export format not specified."
    778778msgstr ""
    779779
    780 #: wp-chatbot.php:568
     780#: wp-chatbot.php:582
    781781msgid "Invalid format specified."
    782782msgstr ""
    783783
    784 #: wp-chatbot.php:834
     784#: wp-chatbot.php:851
    785785msgid "Are you sure you want to delete all messages?"
    786786msgstr ""
    787787
    788 #: wp-chatbot.php:835
     788#: wp-chatbot.php:852
    789789msgid "Error while deleting messages."
    790790msgstr ""
    791791
    792 #: wp-chatbot.php:836
     792#: wp-chatbot.php:853
    793793msgid "Select an export format."
    794794msgstr ""
    795795
    796 #: wp-chatbot.php:837
     796#: wp-chatbot.php:854
    797797msgid "Error loading the image."
    798798msgstr ""
    799799
    800 #: wp-chatbot.php:838
     800#: wp-chatbot.php:855
    801801msgid "Choose an Image"
    802802msgstr ""
    803803
    804 #: wp-chatbot.php:839
     804#: wp-chatbot.php:856
    805805msgid "Use this Image"
    806806msgstr ""
     807
     808#: wp-chatbot.php:1034
     809#, php-format
     810msgid "You have %d unread conversation."
     811msgid_plural "You have %d unread conversations."
     812msgstr[0] ""
     813msgstr[1] ""
    807814
    808815#. Plugin Name of the plugin/theme
  • chatbot-ai-free-models/trunk/readme.txt

    r3363876 r3363913  
    44Requires PHP: 7.4
    55Tested up to: 6.8.2
    6 Stable tag: 1.6.3
     6Stable tag: 1.6.4
    77Tags: ai chatbot, chatbot, live chat, virtual assistant, customer support
    88License: GPLv2 or later
     
    118118A: Third, if the issue persists, try switching to a different model. Free models can sometimes experience high traffic and connection problems, so experimenting with alternative models might resolve the issue.
    119119
     120**Q: How do I know if there are new messages?**
     121A: Yes, the plugin includes an automatic notification system to alert you of new, unread conversations. Here’s how it works:
     122
     123* **Notification Badge in the Menu:** When a user starts a new conversation, a **red notification badge** with a number will appear next to the 'Chatbot' menu item in your WordPress admin sidebar. This number does not represent individual messages, but rather the **total number of conversations** that contain at least one unread message.
     124
     125* **Detailed Tooltip:** If you hover your mouse over the "Chatbot" menu item, a tooltip will provide more details (e.g., "You have 2 unread conversations").
     126
     127* **Highlighting in the Table:** Once you navigate to the 'Messages' tab, unread conversations are easy to spot because the entire row is displayed in **bold text**.
     128
     129* **How to Mark as Read:** To mark a conversation as 'read' and decrease the notification counter, simply **click on the conversation's row** to view its messages. The action is automatic, and the bold styling will disappear.
     130
    120131== External Services ==
    121132
     
    129140
    130141== Changelog ==
     142
     143= 1.6.4 =
     144* New: Unread conversation notifications! A red badge will now appear on the 'Chatbot' admin menu item, showing the count of unread conversations.
     145* New: Conversation IDs are now clean and sequential (e.g., Chat_1, Chat_2) instead of the long, timestamp-based string.
     146* Enhancement: The admin message list has been improved. Unread conversations are now highlighted in bold for easy identification.
     147* Enhancement: Added a descriptive tooltip to the admin menu badge, showing the exact number of unread conversations on hover.
     148* Dev: Major refactor of the database schema. A new conversations table has been introduced to manage conversations more robustly and enable sequential IDs.
    131149
    132150= 1.6.3 =
  • chatbot-ai-free-models/trunk/wp-chatbot.php

    r3363876 r3363913  
    33Plugin Name: Chatbot AI Free Models
    44Description: Easily integrate advanced AI chatbots into your WordPress site with a single API key. Use free models like Llama, DeepSeek, Mixtral, and others, or access premium models like ChatGPT and Claude for more power. Simple management, unlimited messages, and all conversations saved for easy review.
    5 Version: 1.6.3
     5Version: 1.6.4
    66Author: NewCodeByte
    77Author URI: https://newcodebyte.altervista.org
     
    7272// =========================================================================
    7373
    74 /**
    75  * Registra le funzioni da eseguire all'attivazione del plugin e nel backend.
    76  */
    77 register_activation_hook(__FILE__, 'newcodebyte_chatbot_install_or_update');
    7874add_action('admin_init', 'newcodebyte_chatbot_install_or_update');
    7975add_action('admin_notices', 'newcodebyte_chatbot_db_check_notice');
     
    8480 * che la tabella del database esista.
    8581 */
     82
    8683function newcodebyte_chatbot_install_or_update() {
    87     // Usiamo un transient per evitare di eseguire dbDelta ad ogni caricamento di pagina
    88     if (get_transient('newcodebyte_chatbot_db_checked')) {
    89         return;
    90     }
    91 
    92     global $wpdb;
    93     $table_name = $wpdb->prefix . 'newcodebyte_chatbot_messages';
    94    
    95     // Controlla se la tabella esiste. Se esiste già, non facciamo nulla,
    96     // perché dbDelta aggiornerà lo schema se necessario.
    97     // La logica di creazione viene eseguita solo se la tabella manca.
    98     $charset_collate = $wpdb->get_charset_collate();
    99     $sql = "CREATE TABLE $table_name (
    100         id mediumint(9) NOT NULL AUTO_INCREMENT,
    101         conversation_id varchar(255) DEFAULT '' NOT NULL,
    102         user_name tinytext,
    103         user_email varchar(100),
    104         ip varchar(100) DEFAULT '' NOT NULL,
    105         date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
    106         sender varchar(50) DEFAULT '' NOT NULL,
    107         message text NOT NULL,
    108         PRIMARY KEY  (id),
    109         INDEX conv_id_idx (conversation_id)
    110     ) $charset_collate;";
    111 
    112     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    113     dbDelta($sql);
    114 
    115     // Imposta un transient che scade dopo un'ora. Questo è efficiente
    116     // e permette di riprovare in caso di problemi.
    117     set_transient('newcodebyte_chatbot_db_checked', 'yes', HOUR_IN_SECONDS);
     84    // Ottieni la versione del DB che abbiamo salvato l'ultima volta
     85    $current_db_version = get_option('newcodebyte_chatbot_db_version', '1.0');
     86    // Definisci la versione attuale del nostro schema DB
     87    $target_db_version = '1.1'; // Abbiamo introdotto la tabella 'conversations'
     88
     89    // Esegui l'aggiornamento solo se la versione del DB è obsoleta
     90    if (version_compare($current_db_version, $target_db_version, '<')) {
     91       
     92        global $wpdb;
     93        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     94
     95        $messages_table = $wpdb->prefix . 'newcodebyte_chatbot_messages';
     96        $conversations_table = $wpdb->prefix . 'newcodebyte_chatbot_conversations';
     97        $charset_collate = $wpdb->get_charset_collate();
     98
     99        // Usa dbDelta per la tabella dei messaggi (aggiorna la colonna conversation_id)
     100        $sql_messages = "CREATE TABLE {$messages_table} (
     101            id mediumint(9) NOT NULL AUTO_INCREMENT,
     102            conversation_id bigint(20) NOT NULL,
     103            user_name tinytext,
     104            user_email varchar(100),
     105            ip varchar(100) NOT NULL DEFAULT '',
     106            date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
     107            sender varchar(50) NOT NULL DEFAULT '',
     108            message text NOT NULL,
     109            is_read tinyint(1) NOT NULL DEFAULT 0,
     110            PRIMARY KEY  (id),
     111            KEY conv_id_idx (conversation_id),
     112            KEY is_read_idx (is_read)
     113        ) $charset_collate;";
     114        dbDelta($sql_messages);
     115
     116        // Usa una query manuale e diretta per la tabella delle conversazioni (più affidabile)
     117        if ($wpdb->get_var("SHOW TABLES LIKE '{$conversations_table}'") != $conversations_table) {
     118            $sql_conversations = "CREATE TABLE {$conversations_table} (
     119                id bigint(20) NOT NULL AUTO_INCREMENT,
     120                start_date datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
     121                PRIMARY KEY  (id)
     122            ) $charset_collate;";
     123            $wpdb->query($sql_conversations);
     124        }
     125
     126        // Aggiorna la versione del DB per non rieseguire questo codice
     127        update_option('newcodebyte_chatbot_db_version', $target_db_version);
     128    }
    118129}
    119130
     
    149160// Funzione per creare la pagina di configurazione
    150161function newcodebyte_chatbot_add_admin_page() {
     162    $unread_count = newcodebyte_chatbot_get_unread_count();
     163    $menu_title = __( 'Chatbot', 'chatbot-ai-free-models' );
     164
     165    if ($unread_count > 0) {
     166        $badge = sprintf(
     167            ' <span class="awaiting-mod" style="background-color: #d63638;"><span class="pending-count">%d</span></span>',
     168            $unread_count
     169        );
     170        $menu_title .= $badge;
     171    }
     172
    151173    add_menu_page(
    152174        __( 'Chatbot Settings', 'chatbot-ai-free-models' ),
    153         __( 'Chatbot', 'chatbot-ai-free-models' ),
     175        $menu_title, // USA IL TITOLO CON IL BADGE
    154176        'manage_options',
    155177        'newcodebyte-chatbot-settings',
     
    273295        return;
    274296    }
    275     if ( !isset($_POST['conversation_id']) || trim(wp_unslash($_POST['conversation_id'])) === '' ) {
    276         wp_send_json_error(['message' => 'Conversation ID is required.'], 400);
    277         return;
    278     }
    279 
     297
     298    global $wpdb;
    280299    $newcodebyte_message = sanitize_text_field( wp_unslash( $_POST['message'] ) );
    281     $newcodebyte_conversation_id = sanitize_text_field( wp_unslash( $_POST['conversation_id'] ) );
     300    $newcodebyte_conversation_id = isset($_POST['conversation_id']) ? absint($_POST['conversation_id']) : 0;
     301
     302    if (empty($newcodebyte_conversation_id)) {
     303        $conversations_table = $wpdb->prefix . 'newcodebyte_chatbot_conversations';
     304        $wpdb->insert(
     305            $conversations_table,
     306            ['start_date' => current_time('mysql')],
     307            ['%s']
     308        );
     309        $newcodebyte_conversation_id = $wpdb->insert_id;
     310    }
     311
    282312    $user_name = isset($_POST['name']) ? sanitize_text_field(wp_unslash($_POST['name'])) : null;
    283313    $user_email = isset($_POST['email']) ? sanitize_email(wp_unslash($_POST['email'])) : null;
     
    305335    $_SESSION[ $session_history_key ][ $newcodebyte_conversation_id ] = $current_session_history;
    306336
    307     // ================== SALVATAGGIO MESSAGGIO UTENTE ==================
    308337    $save_messages = get_option('newcodebyte_chatbot_save_messages', '0');
    309338    if ($save_messages === '1') {
    310         global $wpdb;
    311339        $table_name = $wpdb->prefix . 'newcodebyte_chatbot_messages';
    312         // Inseriamo il messaggio dell'utente nella tabella.
    313340        $data_to_insert = [
    314341            'ip'              => $newcodebyte_ip,
     
    321348        ];
    322349       
    323         // Specifica i formati dei dati per la sicurezza.
    324         $data_formats = [
    325             '%s', // ip
    326             '%s', // date
    327             '%s', // sender
    328             '%s', // message
    329             '%s', // conversation_id
    330             '%s', // user_name
    331             '%s', // user_email
    332         ];
     350        $data_formats = ['%s', '%s', '%s', '%s', '%d', '%s', '%s'];
    333351       
    334352        $wpdb->insert($table_name, $data_to_insert, $data_formats);
     353        delete_transient('newcodebyte_chatbot_unread_count');
    335354    }
    336355
     
    344363        $_SESSION[ $session_history_key ][ $newcodebyte_conversation_id ][] = ['role' => 'assistant', 'content' => $newcodebyte_bot_response];
    345364       
    346         // ================== SALVATAGGIO MESSAGGIO BOT ==================
     365        // Se il salvataggio è attivo, salva anche la risposta del bot.
    347366        if ($save_messages === '1') {
    348             global $wpdb;
    349367            $table_name = $wpdb->prefix . 'newcodebyte_chatbot_messages';
    350            
    351             // Inseriamo la risposta del bot.
    352368            $wpdb->insert(
    353369                $table_name,
     
    356372                    'sender'          => 'Bot',
    357373                    'message'         => $newcodebyte_bot_response,
    358                     'conversation_id' => $newcodebyte_conversation_id,
    359                     // ip, user_name, e user_email sono nulli di default
     374                    'conversation_id' => $newcodebyte_conversation_id
    360375                ],
    361376                [
     
    363378                    '%s', // sender
    364379                    '%s', // message
    365                     '%s', // conversation_id
     380                    '%d'  // conversation_id (corretto a %d per il numero)
    366381                ]
    367382            );
    368383        }
     384        // --- FINE BLOCCO REINSERITO ---
    369385    }
    370386
     
    372388        wp_send_json_error(array('message' => $newcodebyte_bot_response));
    373389    } else {
    374         wp_send_json_success(array('message' => $newcodebyte_bot_response));
     390        wp_send_json_success(array(
     391            'message' => $newcodebyte_bot_response,
     392            'conversation_id' => $newcodebyte_conversation_id
     393        ));
    375394    }
    376395}
     
    483502    $position_class = 'chatbot-position-' . esc_attr($position);   
    484503    ?>
    485     <div id="chatbox" class="<?php echo $position_class; ?>" data-version-ncb="1.6.3">
     504    <div id="chatbox" class="<?php echo $position_class; ?>" data-version-ncb="1.6.4">
    486505        <div id="chatbox-header"><?php echo esc_html($newcodebyte_chatbot_title); ?><span id="chatbox-close">x</span></div>
    487506        <div id="chatbox-content"></div>
     
    522541
    523542add_action('wp_ajax_newcodebyte_chatbot_delete_messages', 'newcodebyte_chatbot_delete_messages');
    524 // in wp-chatbot.php
    525543
    526544function newcodebyte_chatbot_delete_messages() {
    527     // Sicurezza (invariato)
    528545    if ( ! current_user_can( 'manage_options' ) ) {
    529546        wp_send_json_error( ['message' => esc_html__( 'You do not have permission to perform this action.', 'chatbot-ai-free-models' )] );
     
    535552    }
    536553   
    537     // ======== INIZIO MODIFICA ========
    538554    global $wpdb;
    539555    $table_name = $wpdb->prefix . 'newcodebyte_chatbot_messages';
     
    542558    $wpdb->query("TRUNCATE TABLE $table_name");
    543559   
     560    // Questo assicura che la notifica nel menu scompaia immediatamente.
     561    delete_transient('newcodebyte_chatbot_unread_count');
     562   
    544563    wp_send_json_success( ['message' => __( 'All messages have been deleted.', 'chatbot-ai-free-models' )] );
    545     // ========= FINE MODIFICA =========
    546564}
    547565
     
    696714add_action('wp_ajax_newcodebyte_chatbot_get_conversation_messages', 'newcodebyte_chatbot_get_conversation_messages');
    697715
    698 // in wp-chatbot.php
    699 
    700716function newcodebyte_chatbot_get_conversation_messages() {
     717    if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field($_POST['nonce']), 'newcodebyte_chatbot_admin_nonce')) {
     718        wp_send_json_error(['message' => 'Security check failed.'], 403);
     719        return;
     720    }
     721   
    701722    if (!current_user_can('manage_options')) {
    702723        wp_send_json_error(['message' => 'Permission denied.'], 403);
    703724    }
    704     check_ajax_referer('newcodebyte_chatbot_admin_nonce', 'nonce');
    705 
     725
     726    // ... il resto della funzione rimane invariato ...
    706727    $conversation_id = isset($_POST['conversation_id']) ? sanitize_text_field($_POST['conversation_id']) : '';
    707728    if (empty($conversation_id)) {
     
    712733    $table_name = $wpdb->prefix . 'newcodebyte_chatbot_messages';
    713734   
    714     // Recupera le info utente
     735    // ... il resto della funzione rimane invariato ...
    715736    $user_info = $wpdb->get_row($wpdb->prepare("SELECT user_name, user_email FROM $table_name WHERE conversation_id = %s AND (user_name IS NOT NULL AND user_name != '') LIMIT 1", $conversation_id), ARRAY_A);
    716737    $user_display_name = __('Anonymous User', 'chatbot-ai-free-models');
     
    807828    // 2. Rimuovi la nuova tabella personalizzata dal database MySQL
    808829    global $wpdb;
    809     $table_name = $wpdb->prefix . 'newcodebyte_chatbot_messages';
    810     $wpdb->query("DROP TABLE IF EXISTS $table_name");
    811 
    812     // NOTA: Non cancelliamo deliberatamente il file chatbot.db per permettere
    813     // agli utenti che aggiornano di recuperare la loro vecchia cronologia.
     830    $messages_table = $wpdb->prefix . 'newcodebyte_chatbot_messages';
     831    $conversations_table = $wpdb->prefix . 'newcodebyte_chatbot_conversations';
     832    $wpdb->query("DROP TABLE IF EXISTS $messages_table");
     833    $wpdb->query("DROP TABLE IF EXISTS $conversations_table");
    814834}
    815835
     
    825845        plugins_url( 'js/chatbot-admin.js', __FILE__ ),
    826846        array( 'jquery', 'wp-color-picker', 'media-upload' ),
    827         '1.0', // Considera di aggiornare la versione se fai modifiche significative
     847        '1.3', // Considera di aggiornare la versione se fai modifiche significative
    828848        true
    829849    );
     850
    830851    wp_localize_script( 'chatbot-admin-js', 'chatbot_admin_vars', array(
    831852        'ajaxurl'             => admin_url( 'admin-ajax.php' ),
     
    839860        'media_uploader_button_text' => esc_html__( 'Use this Image', 'chatbot-ai-free-models' ), // Per il pulsante del media uploader
    840861        'chatbot_delete_nonce' => wp_create_nonce('newcodebyte_chatbot_delete_messages'),
    841         'get_messages_nonce' => wp_create_nonce('newcodebyte_chatbot_admin_nonce')
     862        'get_messages_nonce' => wp_create_nonce('newcodebyte_chatbot_admin_nonce'),
     863        'loading_messages'    => esc_html__( 'Loading messages...', 'chatbot-ai-free-models' )
    842864    ) );
    843865}
     
    936958}
    937959add_shortcode('newcodebyte_chatbot', 'newcodebyte_chatbot_shortcode_handler');
     960
     961/**
     962 * Recupera il numero di conversazioni non lette.
     963 * Usa un transient per non interrogare il DB ad ogni caricamento di pagina.
     964 *
     965 * @return int Numero di conversazioni non lette.
     966 */
     967function newcodebyte_chatbot_get_unread_count() {
     968    $cache_key = 'newcodebyte_chatbot_unread_count';
     969    $unread_count = get_transient($cache_key);
     970
     971    if (false === $unread_count) {
     972        global $wpdb;
     973        $table_name = $wpdb->prefix . 'newcodebyte_chatbot_messages';
     974       
     975        // Conta gli ID di conversazione unici che hanno almeno un messaggio non letto.
     976        $unread_count = $wpdb->get_var(
     977            "SELECT COUNT(DISTINCT conversation_id) FROM {$table_name} WHERE is_read = 0"
     978        );
     979       
     980        set_transient($cache_key, $unread_count, 5 * MINUTE_IN_SECONDS); // Cache per 5 minuti
     981    }
     982
     983    return (int) $unread_count;
     984}
     985
     986/**
     987 * Funzione AJAX per segnare una conversazione come letta.
     988 */
     989function newcodebyte_chatbot_mark_as_read_callback() {
     990    // Controlla il nonce usando l'azione corretta e il nome del campo corretto.
     991    if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field($_POST['nonce']), 'newcodebyte_chatbot_admin_nonce')) {
     992        wp_send_json_error(['message' => 'Security check failed.'], 403);
     993        return;
     994    }
     995
     996    if (!current_user_can('manage_options')) {
     997        wp_send_json_error(['message' => 'Permission denied.'], 403);
     998        return;
     999    }
     1000
     1001    $conversation_id = isset($_POST['conversation_id']) ? sanitize_text_field($_POST['conversation_id']) : '';
     1002    if (empty($conversation_id)) {
     1003        wp_send_json_error(['message' => 'Conversation ID is required.'], 400);
     1004    }
     1005
     1006    global $wpdb;
     1007    $table_name = $wpdb->prefix . 'newcodebyte_chatbot_messages';
     1008
     1009    $result = $wpdb->update(
     1010        $table_name,
     1011        ['is_read' => 1], // Imposta a "letto"
     1012        ['conversation_id' => $conversation_id, 'is_read' => 0], // Aggiunto 'is_read' = 0 per efficienza
     1013        ['%d'],
     1014        ['%s', '%d']
     1015    );
     1016
     1017    // Pulisci la cache solo se abbiamo effettivamente aggiornato delle righe
     1018    if ($result !== false && $result > 0) {
     1019        delete_transient('newcodebyte_chatbot_unread_count');
     1020    }
     1021
     1022    wp_send_json_success(['message' => 'Conversation marked as read. Rows affected: ' . $result]);
     1023}
     1024add_action('wp_ajax_newcodebyte_chatbot_mark_as_read', 'newcodebyte_chatbot_mark_as_read_callback');
     1025
     1026/**
     1027 * Aggiunge un tooltip alla voce di menu del chatbot se ci sono conversazioni non lette.
     1028 * Questo script viene caricato in TUTTE le pagine di amministrazione.
     1029 */
     1030function newcodebyte_chatbot_add_admin_menu_tooltip() {
     1031    $unread_count = newcodebyte_chatbot_get_unread_count();
     1032
     1033    // Esegui solo se ci sono messaggi non letti
     1034    if ($unread_count > 0) {
     1035        // Prepara il testo del tooltip (con gestione singolare/plurale)
     1036        $tooltip_text = sprintf(
     1037            esc_attr(_n(
     1038                'You have %d unread conversation.',
     1039                'You have %d unread conversations.',
     1040                $unread_count,
     1041                'chatbot-ai-free-models'
     1042            )),
     1043            $unread_count
     1044        );
     1045
     1046        // Prepara un piccolo snippet di JavaScript
     1047        $script = "
     1048            jQuery(document).ready(function($) {
     1049                $('#toplevel_page_newcodebyte-chatbot-settings > a').attr('title', '" . $tooltip_text . "');
     1050            });
     1051        ";
     1052
     1053        // Allega lo snippet a jQuery, che è sempre presente nel backend.
     1054        wp_add_inline_script('jquery', $script);
     1055    }
     1056}
     1057add_action('admin_enqueue_scripts', 'newcodebyte_chatbot_add_admin_menu_tooltip');
Note: See TracChangeset for help on using the changeset viewer.