Changeset 3249844
- Timestamp:
- 03/03/2025 05:04:50 PM (13 months ago)
- Location:
- chatbase
- Files:
-
- 4 edited
- 1 copied
-
tags/1.0.4 (copied) (copied from chatbase/trunk)
-
tags/1.0.4/chatbase.php (modified) (2 diffs)
-
tags/1.0.4/readme.txt (modified) (2 diffs)
-
trunk/chatbase.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
chatbase/tags/1.0.4/chatbase.php
r3006988 r3249844 5 5 * Plugin URI: https://www.chatbase.co 6 6 * Description: Embed your Chatbase chatbot on any Wordpress site. 7 * Version: 1.0. 37 * Version: 1.0.4 8 8 * Author: Chatbase 9 9 * Author URI: https://www.chatbase.co/ … … 130 130 { 131 131 $handle = 'chatbot-script'; 132 $chatbase_id = get_option('chatbase_id'); 133 134 wp_register_script($handle, '', [], '', true); 135 wp_enqueue_script($handle); 132 136 133 $script_url = 'https://www.chatbase.co/embed.min.js'; 134 135 $chatbase_id = get_option('chatbase_id'); 136 137 // Enqueue the script 138 wp_enqueue_script( 139 $handle, 140 $script_url, 141 array(), // Dependencies (if any) 142 null, // Version number (null for no version) 143 true // Add script in the footer 144 ); 145 146 // Pass data to the script 147 wp_localize_script( 148 $handle, 149 'embeddedChatbotConfig', 150 array( 151 'chatbotId' => esc_attr($chatbase_id), 152 'domain' => 'www.chatbase.co', 153 ) 154 ); 137 if (empty($chatbase_id)) { 138 wp_add_inline_script($handle, 139 'console.log("Chatbase ID is not configured. Please enter your Chatbot ID in the WordPress admin settings.");' 140 ); 141 if (defined('WP_DEBUG') && WP_DEBUG) { 142 error_log('Chatbase: Chatbot ID is not configured'); 143 } 144 return; 145 } 146 147 $custom_script = '(function() { 148 if (!window.chatbase || window.chatbase("getState") !== "initialized") { 149 window.chatbase = (...arguments) => { 150 if (!window.chatbase.q) { 151 window.chatbase.q = [] 152 } 153 window.chatbase.q.push(arguments) 154 }; 155 window.chatbase = new Proxy(window.chatbase, { 156 get(target, prop) { 157 if (prop === "q") { 158 return target.q 159 } 160 return (...args) => target(prop, ...args) 161 } 162 }) 163 } 164 const onLoad = function() { 165 const script = document.createElement("script"); 166 script.src = "https://www.chatbase.co/embed.min.js"; 167 script.id = "' . esc_js($chatbase_id) . '"; 168 script.domain = "www.chatbase.co"; 169 document.body.appendChild(script) 170 }; 171 if (document.readyState === "complete") { 172 onLoad() 173 } else { 174 window.addEventListener("load", onLoad) 175 } 176 })();'; 177 178 wp_add_inline_script($handle, $custom_script); 155 179 } 156 180 -
chatbase/tags/1.0.4/readme.txt
r3006988 r3249844 3 3 Tags: chatbase, chatbots, ai 4 4 Requires at least: 4.7 5 Tested up to: 6. 4.26 Stable tag: 1.0. 35 Tested up to: 6.7.2 6 Stable tag: 1.0.4 7 7 Requires PHP: 7.0 8 8 License: GPLv2 … … 41 41 = 1.0.3 = 42 42 * Updated to latest Chatbase embed script. 43 44 = 1.0.4 = 45 * Improved script loading using WordPress best practices 46 * Updated to latest Chatbase embed script. 47 * Enhanced script placement in footer for better performance -
chatbase/trunk/chatbase.php
r3006988 r3249844 5 5 * Plugin URI: https://www.chatbase.co 6 6 * Description: Embed your Chatbase chatbot on any Wordpress site. 7 * Version: 1.0. 37 * Version: 1.0.4 8 8 * Author: Chatbase 9 9 * Author URI: https://www.chatbase.co/ … … 130 130 { 131 131 $handle = 'chatbot-script'; 132 $chatbase_id = get_option('chatbase_id'); 133 134 wp_register_script($handle, '', [], '', true); 135 wp_enqueue_script($handle); 132 136 133 $script_url = 'https://www.chatbase.co/embed.min.js'; 134 135 $chatbase_id = get_option('chatbase_id'); 136 137 // Enqueue the script 138 wp_enqueue_script( 139 $handle, 140 $script_url, 141 array(), // Dependencies (if any) 142 null, // Version number (null for no version) 143 true // Add script in the footer 144 ); 145 146 // Pass data to the script 147 wp_localize_script( 148 $handle, 149 'embeddedChatbotConfig', 150 array( 151 'chatbotId' => esc_attr($chatbase_id), 152 'domain' => 'www.chatbase.co', 153 ) 154 ); 137 if (empty($chatbase_id)) { 138 wp_add_inline_script($handle, 139 'console.log("Chatbase ID is not configured. Please enter your Chatbot ID in the WordPress admin settings.");' 140 ); 141 if (defined('WP_DEBUG') && WP_DEBUG) { 142 error_log('Chatbase: Chatbot ID is not configured'); 143 } 144 return; 145 } 146 147 $custom_script = '(function() { 148 if (!window.chatbase || window.chatbase("getState") !== "initialized") { 149 window.chatbase = (...arguments) => { 150 if (!window.chatbase.q) { 151 window.chatbase.q = [] 152 } 153 window.chatbase.q.push(arguments) 154 }; 155 window.chatbase = new Proxy(window.chatbase, { 156 get(target, prop) { 157 if (prop === "q") { 158 return target.q 159 } 160 return (...args) => target(prop, ...args) 161 } 162 }) 163 } 164 const onLoad = function() { 165 const script = document.createElement("script"); 166 script.src = "https://www.chatbase.co/embed.min.js"; 167 script.id = "' . esc_js($chatbase_id) . '"; 168 script.domain = "www.chatbase.co"; 169 document.body.appendChild(script) 170 }; 171 if (document.readyState === "complete") { 172 onLoad() 173 } else { 174 window.addEventListener("load", onLoad) 175 } 176 })();'; 177 178 wp_add_inline_script($handle, $custom_script); 155 179 } 156 180 -
chatbase/trunk/readme.txt
r3006988 r3249844 3 3 Tags: chatbase, chatbots, ai 4 4 Requires at least: 4.7 5 Tested up to: 6. 4.26 Stable tag: 1.0. 35 Tested up to: 6.7.2 6 Stable tag: 1.0.4 7 7 Requires PHP: 7.0 8 8 License: GPLv2 … … 41 41 = 1.0.3 = 42 42 * Updated to latest Chatbase embed script. 43 44 = 1.0.4 = 45 * Improved script loading using WordPress best practices 46 * Updated to latest Chatbase embed script. 47 * Enhanced script placement in footer for better performance
Note: See TracChangeset
for help on using the changeset viewer.