Plugin Directory

Changeset 3379377


Ignore:
Timestamp:
10/16/2025 10:41:02 AM (4 months ago)
Author:
newcodebyte
Message:

Update to 1.6.7

Location:
chatbot-ai-free-models
Files:
109 added
5 edited

Legend:

Unmodified
Added
Removed
  • chatbot-ai-free-models/trunk/assets/css/chatbot.css

    r3378450 r3379377  
    5757}
    5858
     59/* =================================== */
     60/* == RESTORED FUNCTIONAL HACK      == */
     61/* =================================== */
     62
    5963.chat-message {
    6064    margin-bottom: 10px;
    6165    display: flex;
    62     align-items: flex-start;
     66    align-items: flex-start; /* Allinea in alto */
     67    max-width: 100%;
    6368}
    6469
    6570.chat-message.user {
    6671    flex-direction: row-reverse;
    67     margin-right: -10px;
    68 }
    69 
    70 .chat-message.user span {
    71     background-color: var(--chatbot-user-message-bg-color, #add8e6);
    72     color: var(--chatbot-user-message-text-color, #000);
    73     font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    74     font-size: 15px !important;
    75     padding: 10px !important;
    76     border-radius: 10px !important;
    77     max-width: 90% !important;
    78     word-wrap: break-word;
    79     margin-right: 10px !important;
    80     box-sizing: border-box !important;
    81     line-height: 1.4 !important;
     72    margin-right: -10px; /* L'hack per tirare a destra */
    8273}
    8374
    8475.chat-message.bot {
    8576    justify-content: flex-start;
    86 }
    87 
    88 .chat-message.bot span {
    89     background-color: var(--chatbot-bot-message-bg-color, #ffc0cb);
    90     color: var(--chatbot-bot-message-text-color, #000);
    91     font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    92     font-size: 15px !important;
    93     padding: 10px !important;
    94     border-radius: 10px !important;
    95     max-width: 90% !important;
    96     word-wrap: break-word;
    97     margin-right: 10px !important;
    98     box-sizing: border-box !important;
    99     line-height: 1.4 !important;
    10077}
    10178
     
    10481    height: 40px;
    10582    border-radius: 50%;
    106     margin-right: 10px;
     83    flex-shrink: 0;
     84}
     85
     86.chat-message .chat-bubble {
     87    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
     88    font-size: 15px;
     89    padding: 10px;
     90    border-radius: 10px;
     91    max-width: 90%;
     92    word-wrap: break-word;
     93    box-sizing: border-box;
     94    line-height: 1.4;
     95}
     96
     97.chat-message.user .chat-bubble {
     98    background-color: var(--chatbot-user-message-bg-color, #add8e6);
     99    color: var(--chatbot-user-message-text-color, #000);
     100    margin-right: 10px; /* L'hack per creare lo spazio */
     101}
     102
     103.chat-message.bot .chat-bubble {
     104    background-color: var(--chatbot-bot-message-bg-color, #ffc0cb);
     105    color: var(--chatbot-bot-message-text-color, #000);
     106    margin-left: 10px;
     107}
     108
     109#chatbox .chat-message .chat-bubble p {
     110    margin: 0;
     111    padding: 0;
     112    font-size: inherit;
     113    line-height: inherit;
    107114}
    108115
     
    405412    height: 600px !important;
    406413    width: 100% !important;
    407     max-width: 800px !important;
    408     margin: 0 auto 40px auto !important;
     414    max-width: 100% !important;
     415    margin: 40px 0 !important;
    409416    border: 1px solid #e0e0e0 !important;
    410417    overflow: hidden !important;
  • chatbot-ai-free-models/trunk/assets/js/chatbot.js

    r3378450 r3379377  
    1616        var isAnimating = false;
    1717
     18        // --- CHIAVI UNIVOCHE PER SESSIONSTORAGE ---
     19        const historyKey = chatbot_params.site_id + '_chatbotHistory';
     20        const convIdKey = chatbot_params.site_id + '_chatbotConvId';
     21
    1822        // --- Funzioni di Gestione della Cronologia (sessionStorage) ---
    1923        function saveHistoryToSessionStorage() {
    2024            try {
    21                 sessionStorage.setItem('newcodebyteChatbotHistory', JSON.stringify(conversationHistory));
     25                sessionStorage.setItem(historyKey, JSON.stringify(conversationHistory));
    2226            } catch (e) {
    2327                console.warn('Chatbot: Could not save history to sessionStorage.');
     
    2731        function loadHistoryFromSessionStorage() {
    2832            try {
    29                 const storedHistory = sessionStorage.getItem('newcodebyteChatbotHistory');
     33                const storedHistory = sessionStorage.getItem(historyKey);
    3034                if (storedHistory) {
    3135                    conversationHistory = JSON.parse(storedHistory);
     
    5256            if (currentConversationId) return currentConversationId;
    5357            try {
    54                 currentConversationId = sessionStorage.getItem('newcodebyteChatbotConversationId');
     58                currentConversationId = sessionStorage.getItem(convIdKey);
    5559            } catch (e) {
    56                 console.warn('Chatbot: sessionStorage not accessible.');
     60                console.warn('Chatbot: Could not read conversation ID from sessionStorage.');
    5761            }
    5862            return currentConversationId;
     
    114118                    currentConversationId = response.data.conversation_id;
    115119                    try {
    116                         sessionStorage.setItem('newcodebyteChatbotConversationId', currentConversationId);
     120                        sessionStorage.setItem(convIdKey, currentConversationId);
    117121                    } catch (e) {}
    118122                }
     
    132136
    133137        // --- Funzioni di Visualizzazione (Rendering) ---
    134         function appendChatMessage(type, avatar, messageContent) {
     138            function appendChatMessage(type, avatar, messageContent) {
    135139            var avatarImg = $('<img>').attr('src', avatar).attr('alt', type);
    136             var messageSpan = $('<span>');
    137            
     140            var messageBubble = $('<div>').addClass('chat-bubble');
     141
    138142            if (type === 'user') {
    139                 messageSpan.text(messageContent);
     143                messageBubble.text(messageContent);
    140144            } else {
    141145                if (typeof marked !== 'undefined' && typeof DOMPurify !== 'undefined') {
    142                     messageSpan.html(DOMPurify.sanitize(marked.parse(messageContent)));
     146                    // Inserisci l'HTML generato da marked.js direttamente nel div
     147                    messageBubble.html(DOMPurify.sanitize(marked.parse(messageContent)));
    143148                } else {
    144                     messageSpan.text(messageContent);
    145                 }
    146             }
    147            
    148             var newMessage = $('<div>').addClass('chat-message ' + type).append(avatarImg).append(messageSpan);
     149                    messageBubble.text(messageContent);
     150                }
     151            }
     152           
     153            var newMessage = $('<div>').addClass('chat-message ' + type).append(avatarImg).append(messageBubble);
    149154            chatboxContent.append(newMessage);
    150155            chatboxContent.stop().animate({ scrollTop: chatboxContent[0].scrollHeight }, 200);
     
    169174        }
    170175       
    171         // --- LOGICA DI APERTURA/CHIUSURA CORRETTA ---
    172176        function toggleChatbox() {
    173177            if (isAnimating) return;
     
    190194            chatboxButtonImg.attr('src', newIcon);
    191195       
    192             if (!isChatboxOpen) { // Azioni da fare quando si sta per APRIRE
     196            if (!isChatboxOpen) {
    193197                playNotificationSound();
    194198                if (conversationHistory.length === 0) {
     
    228232       
    229233        if ($('.chatbot-shortcode-wrapper').length === 0 && chatbot_params.enable_proactive === '1' && proactiveBubble.length > 0) {
    230             // Logica per il messaggio proattivo
     234            // (Logica per il messaggio proattivo)
    231235        }
    232236
  • chatbot-ai-free-models/trunk/includes/class-chatbot-frontend.php

    r3378450 r3379377  
    1818     */
    1919    public function add_hooks() {
    20         add_action('init', [$this, 'load_widget_conditionally']);
     20        // Carica SEMPRE gli script e gli stili su ogni pagina del frontend.
     21        // Questo è il metodo "primitivo" ma a prova di cache.
     22        add_action('wp_enqueue_scripts', [$this, 'enqueue_assets']);
     23
     24        // Aggiunge l'HTML del widget al footer solo se la modalità è "widget".
     25        add_action('wp_footer', [$this, 'render_widget_html']);
     26       
     27        // Registra lo shortcode.
    2128        add_shortcode('newcodebyte_chatbot', [$this, 'render_shortcode']);
    2229    }
    2330
    2431    /**
    25      * Conditionally load the widget based on the display mode setting.
     32     * Enqueue scripts and styles for the public-facing side of the site.
     33     * Questa funzione ora viene eseguita sempre.
    2634     *
    2735     * @since    1.6.5
    2836     */
    29     public function load_widget_conditionally() {
    30         $display_mode = get_option('newcodebyte_chatbot_display_mode', 'widget');
    31         if ($display_mode === 'widget' && !is_admin()) {
    32             add_action('wp_enqueue_scripts', [$this, 'enqueue_scripts']);
    33             add_action('wp_footer', [$this, 'render_chatbox_widget']);
     37    public function enqueue_assets() {
     38        // Non caricare nulla nel backend.
     39        if (is_admin()) {
     40            return;
    3441        }
    35     }
    3642
    37     /**
    38      * Enqueue scripts and styles for the public-facing side of the site.
    39      *
    40      * @since    1.6.5
    41      */
    42     public function enqueue_scripts() {
    4343        wp_enqueue_script('chatbot-js', NCB_CHATBOT_PLUGIN_URL . 'assets/js/chatbot.js', ['jquery'], NCB_CHATBOT_VERSION, true);
    4444        wp_enqueue_style('chatbot-style', NCB_CHATBOT_PLUGIN_URL . 'assets/css/chatbot.css', [], NCB_CHATBOT_VERSION);
     
    8888            'enable_proactive' => get_option('newcodebyte_chatbot_enable_proactive_message', '0'),
    8989            'proactive_text' => get_option('newcodebyte_chatbot_proactive_message_text', __("Have a question?\nAsk me!", NCB_CHATBOT_TEXT_DOMAIN)),
    90             'proactive_delay' => get_option('newcodebyte_chatbot_proactive_message_delay', '5')
     90            'proactive_delay' => get_option('newcodebyte_chatbot_proactive_message_delay', '5'),
     91            'site_id' => 'ncb_' . md5(get_home_url())
    9192        ]);
    9293
     
    9899
    99100    /**
    100      * Render the chatbox widget view.
     101     * Render the chatbox widget HTML in the footer, only if in widget mode.
    101102     *
    102103     * @since    1.6.5
    103104     */
    104     public function render_chatbox_widget() {
    105         $is_widget = true;
    106         require_once NCB_CHATBOT_PLUGIN_DIR . 'public/views/chatbot-display.php';
     105    public function render_widget_html() {
     106        $display_mode = get_option('newcodebyte_chatbot_display_mode', 'widget');
     107        if ($display_mode === 'widget') {
     108            $is_widget = true;
     109            require_once NCB_CHATBOT_PLUGIN_DIR . 'public/views/chatbot-display.php';
     110        }
    107111    }
    108112
     
    120124        }
    121125
    122         $this->enqueue_scripts();
     126        // Gli script sono già caricati globalmente, non serve chiamare enqueue qui.
    123127
    124128        ob_start();
     
    143147            });
    144148        </script>";
     149       
    145150        return $output;
    146151    }
  • chatbot-ai-free-models/trunk/readme.txt

    r3378450 r3379377  
    44Requires PHP: 7.4
    55Tested up to: 6.8.3
    6 Stable tag: 1.6.6
     6Stable tag: 1.6.7
    77Tags: ai chatbot, chatbot, live chat, virtual assistant, customer support
    88License: GPLv2 or later
  • chatbot-ai-free-models/trunk/wp-chatbot.php

    r3378450 r3379377  
    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.6
     5Version: 1.6.7
    66Author: NewCodeByte
    77Author URI: https://newcodebyte.altervista.org
     
    2222 * Define plugin constants
    2323 */
    24 define('NCB_CHATBOT_VERSION', '1.6.6');
     24define('NCB_CHATBOT_VERSION', '1.6.7');
    2525define('NCB_CHATBOT_PLUGIN_FILE', __FILE__);
    2626define('NCB_CHATBOT_PLUGIN_DIR', plugin_dir_path(__FILE__));
Note: See TracChangeset for help on using the changeset viewer.