Changeset 3043850
- Timestamp:
- 03/02/2024 12:30:47 AM (2 years ago)
- Location:
- staffing-engine-chatbot
- Files:
-
- 10 edited
- 1 copied
-
tags/0.9.5 (copied) (copied from staffing-engine-chatbot/trunk)
-
tags/0.9.5/includes/admin.php (modified) (11 diffs)
-
tags/0.9.5/includes/embed.php (modified) (10 diffs)
-
tags/0.9.5/public/js/se-chatbot.js (modified) (1 diff)
-
tags/0.9.5/readme.txt (modified) (2 diffs)
-
tags/0.9.5/staffing-engine-chatbot.php (modified) (3 diffs)
-
trunk/includes/admin.php (modified) (11 diffs)
-
trunk/includes/embed.php (modified) (10 diffs)
-
trunk/public/js/se-chatbot.js (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/staffing-engine-chatbot.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
staffing-engine-chatbot/tags/0.9.5/includes/admin.php
r2911282 r3043850 231 231 ), 232 232 ), 233 // 'rwcVersion' => array( 234 // 'id' => 'rwc_version', 235 // 'title' => __( 'RWC Version', Plugin::SLUG ), 236 // 'text' => __( 'Set the RWC version', Plugin::SLUG ), 237 // 'type' => 'radio', 238 // 'value' => 'old', 239 // 'choices' => array( 240 // 'old' => __( 'v4', Plugin::SLUG), 241 // 'new' => __( 'v5 (Experimental)', Plugin::SLUG ), 242 // ), 243 // ), 233 244 'key' => array( 234 245 'id' => 'key', 235 246 'type' => 'text', 236 'title' => __( 'Bot key', Plugin::SLUG ),247 'title' => __( 'Bot Key', Plugin::SLUG ), 237 248 'text' => __( 'Your unique chat instance key. Contact Staffing Engine support if you haven\'t received one.', Plugin::SLUG ), 238 249 'default' => '', 239 250 ), 251 // 'chatUrl' => array( 252 // 'id' => 'chat_url', 253 // 'type' => 'text', 254 // 'title' => __( 'Chat URL', Plugin::SLUG ), 255 // 'text' => __( 'Your unique chat URL. Contact Staffing Engine support if you haven\'t received one.', Plugin::SLUG ), 256 // 'default' => '', 257 // ), 240 258 ), 241 259 ), 242 260 'appearance' => array( 243 'title' => __( ' Appearance', Plugin::SLUG),261 'title' => __( 'Widget', Plugin::SLUG), 244 262 'text' => __( 'Customize the chat widget\'s appearance', Plugin::SLUG ), 245 263 'fields' => array( 246 264 'position' => array( 247 265 'id' => 'position', 248 'title' => __( ' Bot position', Plugin::SLUG ),266 'title' => __( 'Position', Plugin::SLUG ), 249 267 'text' => __( 'Set the location of the bot on your site.', Plugin::SLUG ), 250 268 'type' => 'select', … … 259 277 'widgetColor' => array( 260 278 'id' => 'widget_color', 261 'title' => __( ' WidgetColor', Plugin::SLUG ),279 'title' => __( 'Color', Plugin::SLUG ), 262 280 'text' => __( 'Set the background color of the chatbot embed.', Plugin::SLUG ), 263 281 'type' => 'color', … … 266 284 'thumbLogo' => array( 267 285 'id' => 'thumb_logo', 268 'title' => __( ' ThumbLogo', Plugin::SLUG ),286 'title' => __( 'Logo', Plugin::SLUG ), 269 287 'text' => __( 'Upload a custom logo for your chatbot.', Plugin::SLUG ), 270 288 'type' => 'media', … … 273 291 'animation' => array( 274 292 'id' => 'animation', 275 'title' => __( 'Animation type', Plugin::SLUG ),293 'title' => __( 'Animation', Plugin::SLUG ), 276 294 'text' => __( 'Choose an animation style to get the attention of site visitors.', Plugin::SLUG ), 277 295 'type' => 'select', … … 298 316 ), 299 317 'invite_popup' => array( 300 'title' => __( ' Invitation Popup', Plugin::SLUG ),318 'title' => __( ' Invitation', Plugin::SLUG ), 301 319 'text' => __( 'Show an informational popup next to the widget after a set duration', Plugin::SLUG ), 302 320 'fields' => array( … … 309 327 'inviteMessage' => array( 310 328 'id' => 'invite_message', 311 'title' => __( ' InviteMessage', Plugin::SLUG ),329 'title' => __( 'Message', Plugin::SLUG ), 312 330 'type' => 'textarea', 313 331 'class' => 'inviteMessage', … … 318 336 'inviteButtonText' => array( 319 337 'id' => 'invite_button_text', 320 'title' => __( ' InviteButton text', Plugin::SLUG ),338 'title' => __( 'Button text', Plugin::SLUG ), 321 339 'text' => __( 'Display a button with this text in the popup (optional).', Plugin::SLUG ), 322 340 'type' => 'text', … … 325 343 'inviteImage' => array( 326 344 'id' => 'invite_image', 327 'title' => __( 'I nvite Image', Plugin::SLUG ),345 'title' => __( 'Image', Plugin::SLUG ), 328 346 'text' => __( 'Display an image in the popup (optional).', Plugin::SLUG ), 329 347 'type' => 'media', … … 332 350 'inviteShowCloseIcon' => array( 333 351 'id' => 'invite_show_close_icon', 334 'title' => __( ' Show Close Icon', Plugin::SLUG ),352 'title' => __( 'Closeable', Plugin::SLUG ), 335 353 'text' => __( 'Show the close icon on the popup. If not shown, the popup cannot be dismissed.', Plugin::SLUG ), 336 354 'type' => 'radio', … … 343 361 'inviteTimeout' => array( 344 362 'id' => 'invite_timeout', 345 'title' => __( ' Invite Timeout', Plugin::SLUG ),363 'title' => __( 'Appear Delay', Plugin::SLUG ), 346 364 'text' => __( 'Set how long until the popup appears (in seconds)', Plugin::SLUG ), 347 365 'type' => 'number', … … 400 418 'allowWindowDrag' => array( 401 419 'id' => 'allow_window_drag', 402 'title' => __( ' Allow dragging the chat window', Plugin::SLUG ),420 'title' => __( 'Draggable', Plugin::SLUG ), 403 421 'text' => __( 'Set whether site visitors can move the chat window around the site.', Plugin::SLUG ), 404 422 'type' => 'radio', -
staffing-engine-chatbot/tags/0.9.5/includes/embed.php
r2947887 r3043850 75 75 76 76 /** 77 * The RWC version 78 * 79 * @since 0.10.0 80 * @var string 81 */ 82 private static $rwc_version = '4'; 83 84 /** 77 85 * Instance Builder 78 86 * … … 97 105 public function __construct() { 98 106 self::$options = get_option( Plugin::SLUG . '_settings', array() ); 107 self::$rwc_version = $this->get_rwc_version(); 99 108 self::$final_options = $this->get_options_with_defaults(); 100 109 self::$settings = $this->get_settings_with_defaults(); … … 104 113 } 105 114 115 /** 116 * Register lifecycle hooks 117 * 118 * @since 0.6.0 119 */ 106 120 private function register_lifecycle_hooks() { 107 121 add_action( 'wp', array( $this, 'get_page_info' ) ); … … 150 164 * Staffing Engine Chatbot - <?php echo SE_CHAT_VERSION ?> 151 165 */ 152 const rwcScriptLocation = "<?php echo $this->get_rwc_script_location() ?>";153 166 154 167 const IS_MOBILE = window.innerWidth <= 768; 168 const SE_RWC_VERSION = <?php echo json_encode( self::$rwc_version ); ?>; 155 169 156 170 const handleAutoExpand = (config, autoExpandState) => { 157 171 if (autoExpandState === 'disable') { 158 config.autoExpandDelay = 0; 172 if (SE_RWC_VERSION === 'old') { 173 config.autoExpandDelay = 0; 174 } else { 175 config.widget.openDelay = 0; 176 } 159 177 } else if (autoExpandState === 'enable-not-mobile' && IS_MOBILE) { 160 config.autoExpandDelay = 0; 178 if (SE_RWC_VERSION === 'old') { 179 config.autoExpandDelay = 0; 180 } else { 181 config.widget.openDelay = 0; 182 } 161 183 } 162 184 }; 163 185 186 const rwcScriptLocation = "<?php echo $this->get_rwc_script_location() ?>"; 164 187 const config = <?php echo json_encode( self::$final_options ); ?>; 165 188 const autoExpandState = <?php echo json_encode( self::$options['auto_expand_enable'] ); ?>; … … 169 192 const staffingEngineChatConfig = Object.assign(config, { 170 193 container: '#staffing-engine-chatbot', 171 appearance: {172 blurredBackground: false,173 preloadInBackground: true,174 },175 194 pageData: { 176 195 url: window.location.href, … … 211 230 } 212 231 213 if (self::$options['advanced_override_rwc_css']) { 214 wp_enqueue_style( Plugin::SLUG . '-rwc-override', esc_attr( self::$options['advanced_override_rwc_css'] ), array(), null ); 232 if (self::$rwc_version == 'new') { 233 wp_enqueue_style( 234 Plugin::SLUG . '-rwc-defer', 235 'https://chat.staffingengine.onereach.ai/lib/richWebChat.css', 236 array(), 237 null 238 ); 239 } else if (self::$options['advanced_override_rwc_css']) { 240 wp_enqueue_style( 241 Plugin::SLUG . '-rwc-override', 242 esc_attr( self::$options['advanced_override_rwc_css'] ), 243 array(), 244 null 245 ); 215 246 } else { 216 247 wp_enqueue_style( … … 235 266 236 267 /** 268 * Get which RWC version to use 269 * 270 * @since 0.10.0 271 * @return string 272 */ 273 private function get_rwc_version() { 274 return array_key_exists( 'rwc_version', self::$options ) ? esc_attr( self::$options['rwc_version'] ) : 'old'; 275 } 276 277 /** 237 278 * Parse user-defined settings and merge with sensible defaults 238 279 * … … 241 282 */ 242 283 private function get_options_with_defaults() { 284 if (self::$rwc_version == 'new') { 285 return [ 286 "chatUrl" => array_key_exists( 'chat_url', self::$options ) ? esc_attr( self::$options['chat_url'] ) : '', 287 "appearance" => array( 288 "blurredBackground" => false, 289 "resizeable" => true, 290 "draggable" => true, 291 "saveChatSize" => true, 292 "preloadInBackground" => true, // TODO: turn back on or make a setting 293 ), 294 "widget" => array( 295 "position" => array_key_exists( 'position', self::$options ) ? self::$options['position'] : 'bottom-right', 296 "animation" => array_key_exists( 'animation', self::$options ) ? esc_attr( self::$options['animation'] ) : 'pulse', 297 "color" => array_key_exists( 'widget_color', self::$options ) ? esc_attr( self::$options['widget_color'] ) : '#ffffff', 298 "logoUrl" => $this->get_thumb_logo(), 299 "revealDelay" => 0, 300 "openDelay" => array_key_exists( 'auto_expand_delay', self::$options ) ? $this->parse_ms_setting( esc_attr( self::$options['auto_expand_delay'] ) . '000' ) : '0', 301 ), 302 "invitation" => array( 303 "closeable" => array_key_exists( 'invite_show_close_icon', self::$options ) ? $this->parse_radio_setting( esc_attr( self::$options['invite_show_close_icon'] ), true ) : true, 304 "imageUrl" => array_key_exists( 'invite_image', self::$options ) ? esc_attr( self::$options['invite_image'] ) : '', 305 "message" => $this->get_invite_message(), 306 "buttonLabel" => array_key_exists( 'invite_button_text', self::$options ) ? esc_attr( self::$options['invite_button_text'] ) : '', 307 "appearDelay" => array_key_exists( 'invite_timeout', self::$options ) ? $this->parse_ms_setting( esc_attr( self::$options['invite_timeout'] ) . '000' ) : 5000, 308 ), 309 ]; 310 } 311 243 312 return [ 244 313 "chatUrl" => 'https://v1.chat.staffingengine.onereach.ai/' . ( array_key_exists( 'key', self::$options ) ? esc_attr( self::$options['key'] ) : '' ) . '?loader=auto', … … 256 325 "allowChangeChatWindowSize" => array_key_exists( 'allow_change_window_size', self::$options ) ? $this->parse_radio_setting( esc_attr( self::$options['allow_change_window_size'] ), true ) : true, 257 326 "allowDrag" => array_key_exists( 'allow_window_drag', self::$options ) ? $this->parse_radio_setting( esc_attr( self::$options['allow_window_drag'] ), true ) : true, 327 "appearance" => array( 328 "blurredBackground" => false, 329 "preloadInBackground" => true, 330 ), 258 331 ]; 259 332 } … … 295 368 */ 296 369 private function get_rwc_script_location() { 370 if ( self::$rwc_version == 'new') { 371 return 'https://chat.staffingengine.onereach.ai/lib/richWebChat.umd.min.js'; 372 } 373 297 374 if ( self::$options['advanced_override_rwc_js']) { 298 375 return esc_attr( self::$options['advanced_override_rwc_js'] ); -
staffing-engine-chatbot/tags/0.9.5/public/js/se-chatbot.js
r2966140 r3043850 1 !function(){"use strict";(async()=>{const t= (t,n)=>{console.error(`[SEChat Plugin] unable to load chatbot: ${t}`),n&&console.error(n)},n=()=>{const n=window.richWebChat.default;if(!n)return void t("richWebChat is undefined");const e=(()=>{if(staffingEngineChatConfig)return staffingEngineChatConfig})();e?new n(e):t("configuration was not provided")},e=async()=>{const n=(()=>{if(rwcScriptLocation)return rwcScriptLocation})();if(n)try{await import(n)}catch(n){return void t("richWebChat.umd.min.js could not be imported",n)}else t("richWebChat.umd.min.js not found")},i=()=>{const t=(()=>{if(staffingEngineChatSettings)return staffingEngineChatSettings})();if(t.thumbIconSize&&"default"!==t.thumbIconSize){const n=document.querySelector("#staffing-engine-chatbot .rwc-embed-thumb");if(!n)return;n.classList.add(`se-chatbot-thumb--${t.thumbIconSize}`)}},a=async()=>{await e(),await n(),i(),(()=>{const t=window.richWebChat.Sdk,n=document.querySelector('#staffing-engine-chatbot button[aria-label="Close chat"]');var e,i,a,o,c;i="click",a=()=>t.sendGlobalCommand({name:"close"}),(e=n)&&(c&&a(e[o]),e.addEventListener(i,(t=>a(t.target[o]))))})()};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(async()=>{await a()}),!1):await a()})()}();1 !function(){"use strict";(async()=>{const t="se-chatbot-open",e=(t,e)=>{console.error(`[SEChat Plugin] unable to load chatbot: ${t}`),e&&console.error(e)},n=(t,e,n,o,a)=>{t&&(a&&n(t[o]),t.addEventListener(e,(t=>n(t.target[o]))))},o=()=>{const t=window.richWebChat.default;if(!t)return void e("richWebChat is undefined");const n=(()=>{if(staffingEngineChatConfig)return staffingEngineChatConfig})();if(!n)return void e("configuration was not provided");const o=new t(n);window.SEChatbot=o},a=async()=>{const t=(()=>{if(rwcScriptLocation)return rwcScriptLocation})();if(t)try{await import(t)}catch(t){return void e("richWebChat.umd.min.js could not be imported",t)}else e("richWebChat.umd.min.js not found")},i=()=>{try{const t=(()=>{if(staffingEngineChatSettings)return staffingEngineChatSettings})();if(t.thumbIconSize&&"default"!==t.thumbIconSize){const e=document.querySelector("#staffing-engine-chatbot .rwc-embed-thumb");if(!e)return;e.classList.add(`se-chatbot-thumb--${t.thumbIconSize}`)}}catch(t){e("failed to apply chatbot settings",t)}},c=()=>{try{if("new"===(()=>{if(SE_RWC_VERSION)return SE_RWC_VERSION})()){const t=window.SEChatbot,e=document.querySelector("#staffing-engine-chatbot button.rwc-embed__close-btn");n(e,"click",(()=>t.runGlobalCommand({name:"closeChat"})))}else{const t=window.richWebChat.Sdk,e=document.querySelector('#staffing-engine-chatbot button[aria-label="Close chat"]');n(e,"click",(()=>t.sendGlobalCommand({name:"close"})))}}catch(t){e("failed to register global command listeners",t)}},r=async()=>{try{const e=localStorage.getItem(t);if(await(n=document.querySelector("#staffing-engine-chatbot"),o="rwc-embed",new Promise((t=>{const e=new MutationObserver((n=>{n.forEach((n=>{n.target.className.includes(o)&&(e.disconnect(),t())}))}));e.observe(n,{subtree:!0,childList:!0})}))),!e||"closed"===e)return;const a=window.SEChatbot;if(a.isChatOpen)return;a.openChat()}catch(t){e("failed to manage open state",t)}var n,o},s=async()=>{await a(),await o(),i(),c(),(()=>{try{const e=window.richWebChat.Sdk,n=t=>t.isOpen?"open":"closed";e.on("toggle-chat-window",(e=>{localStorage.setItem(t,n(e))}))}catch(t){e("failed to register chat state listener",t)}})(),await r()};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(async()=>{await s()}),!1):await s()})()}(); -
staffing-engine-chatbot/tags/0.9.5/readme.txt
r2966140 r3043850 4 4 - Donate Link: https://staffingengine.ai/ 5 5 - Tags: chatbot, live chat, AI, staffing, recruiting 6 - Stable tag: 0.9. 46 - Stable tag: 0.9.5 7 7 - Requires at least: 5.5 8 8 - Tested up to: 6.3.1 … … 110 110 111 111 - bug fixes 112 113 = 0.9.5 : 2024-3-1 = 114 115 - sync the open state of the chat window across tabs and reloads. If the window was open, it 116 will now re-open when site users move to a new tab or reload the page 117 - bug fixes -
staffing-engine-chatbot/tags/0.9.5/staffing-engine-chatbot.php
r2966140 r3043850 5 5 * @copyright (c) 2023 staffing Engine 6 6 * @license GPL-3.0-or-later 7 * @version 0.9. 47 * @version 0.9.5 8 8 * 9 9 * @wordpress-plugin … … 15 15 * License: GPL v3 or later 16 16 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html 17 * Version: 0.9. 417 * Version: 0.9.5 18 18 * Requires at least: 5.5 19 19 * Requires PHP: 7.1 … … 44 44 } 45 45 46 define( 'SE_CHAT_VERSION', '0.9. 4' );46 define( 'SE_CHAT_VERSION', '0.9.5' ); 47 47 define( 'CURRENT_WP_VERSION', $wp_version ); 48 48 -
staffing-engine-chatbot/trunk/includes/admin.php
r2911282 r3043850 231 231 ), 232 232 ), 233 // 'rwcVersion' => array( 234 // 'id' => 'rwc_version', 235 // 'title' => __( 'RWC Version', Plugin::SLUG ), 236 // 'text' => __( 'Set the RWC version', Plugin::SLUG ), 237 // 'type' => 'radio', 238 // 'value' => 'old', 239 // 'choices' => array( 240 // 'old' => __( 'v4', Plugin::SLUG), 241 // 'new' => __( 'v5 (Experimental)', Plugin::SLUG ), 242 // ), 243 // ), 233 244 'key' => array( 234 245 'id' => 'key', 235 246 'type' => 'text', 236 'title' => __( 'Bot key', Plugin::SLUG ),247 'title' => __( 'Bot Key', Plugin::SLUG ), 237 248 'text' => __( 'Your unique chat instance key. Contact Staffing Engine support if you haven\'t received one.', Plugin::SLUG ), 238 249 'default' => '', 239 250 ), 251 // 'chatUrl' => array( 252 // 'id' => 'chat_url', 253 // 'type' => 'text', 254 // 'title' => __( 'Chat URL', Plugin::SLUG ), 255 // 'text' => __( 'Your unique chat URL. Contact Staffing Engine support if you haven\'t received one.', Plugin::SLUG ), 256 // 'default' => '', 257 // ), 240 258 ), 241 259 ), 242 260 'appearance' => array( 243 'title' => __( ' Appearance', Plugin::SLUG),261 'title' => __( 'Widget', Plugin::SLUG), 244 262 'text' => __( 'Customize the chat widget\'s appearance', Plugin::SLUG ), 245 263 'fields' => array( 246 264 'position' => array( 247 265 'id' => 'position', 248 'title' => __( ' Bot position', Plugin::SLUG ),266 'title' => __( 'Position', Plugin::SLUG ), 249 267 'text' => __( 'Set the location of the bot on your site.', Plugin::SLUG ), 250 268 'type' => 'select', … … 259 277 'widgetColor' => array( 260 278 'id' => 'widget_color', 261 'title' => __( ' WidgetColor', Plugin::SLUG ),279 'title' => __( 'Color', Plugin::SLUG ), 262 280 'text' => __( 'Set the background color of the chatbot embed.', Plugin::SLUG ), 263 281 'type' => 'color', … … 266 284 'thumbLogo' => array( 267 285 'id' => 'thumb_logo', 268 'title' => __( ' ThumbLogo', Plugin::SLUG ),286 'title' => __( 'Logo', Plugin::SLUG ), 269 287 'text' => __( 'Upload a custom logo for your chatbot.', Plugin::SLUG ), 270 288 'type' => 'media', … … 273 291 'animation' => array( 274 292 'id' => 'animation', 275 'title' => __( 'Animation type', Plugin::SLUG ),293 'title' => __( 'Animation', Plugin::SLUG ), 276 294 'text' => __( 'Choose an animation style to get the attention of site visitors.', Plugin::SLUG ), 277 295 'type' => 'select', … … 298 316 ), 299 317 'invite_popup' => array( 300 'title' => __( ' Invitation Popup', Plugin::SLUG ),318 'title' => __( ' Invitation', Plugin::SLUG ), 301 319 'text' => __( 'Show an informational popup next to the widget after a set duration', Plugin::SLUG ), 302 320 'fields' => array( … … 309 327 'inviteMessage' => array( 310 328 'id' => 'invite_message', 311 'title' => __( ' InviteMessage', Plugin::SLUG ),329 'title' => __( 'Message', Plugin::SLUG ), 312 330 'type' => 'textarea', 313 331 'class' => 'inviteMessage', … … 318 336 'inviteButtonText' => array( 319 337 'id' => 'invite_button_text', 320 'title' => __( ' InviteButton text', Plugin::SLUG ),338 'title' => __( 'Button text', Plugin::SLUG ), 321 339 'text' => __( 'Display a button with this text in the popup (optional).', Plugin::SLUG ), 322 340 'type' => 'text', … … 325 343 'inviteImage' => array( 326 344 'id' => 'invite_image', 327 'title' => __( 'I nvite Image', Plugin::SLUG ),345 'title' => __( 'Image', Plugin::SLUG ), 328 346 'text' => __( 'Display an image in the popup (optional).', Plugin::SLUG ), 329 347 'type' => 'media', … … 332 350 'inviteShowCloseIcon' => array( 333 351 'id' => 'invite_show_close_icon', 334 'title' => __( ' Show Close Icon', Plugin::SLUG ),352 'title' => __( 'Closeable', Plugin::SLUG ), 335 353 'text' => __( 'Show the close icon on the popup. If not shown, the popup cannot be dismissed.', Plugin::SLUG ), 336 354 'type' => 'radio', … … 343 361 'inviteTimeout' => array( 344 362 'id' => 'invite_timeout', 345 'title' => __( ' Invite Timeout', Plugin::SLUG ),363 'title' => __( 'Appear Delay', Plugin::SLUG ), 346 364 'text' => __( 'Set how long until the popup appears (in seconds)', Plugin::SLUG ), 347 365 'type' => 'number', … … 400 418 'allowWindowDrag' => array( 401 419 'id' => 'allow_window_drag', 402 'title' => __( ' Allow dragging the chat window', Plugin::SLUG ),420 'title' => __( 'Draggable', Plugin::SLUG ), 403 421 'text' => __( 'Set whether site visitors can move the chat window around the site.', Plugin::SLUG ), 404 422 'type' => 'radio', -
staffing-engine-chatbot/trunk/includes/embed.php
r2947887 r3043850 75 75 76 76 /** 77 * The RWC version 78 * 79 * @since 0.10.0 80 * @var string 81 */ 82 private static $rwc_version = '4'; 83 84 /** 77 85 * Instance Builder 78 86 * … … 97 105 public function __construct() { 98 106 self::$options = get_option( Plugin::SLUG . '_settings', array() ); 107 self::$rwc_version = $this->get_rwc_version(); 99 108 self::$final_options = $this->get_options_with_defaults(); 100 109 self::$settings = $this->get_settings_with_defaults(); … … 104 113 } 105 114 115 /** 116 * Register lifecycle hooks 117 * 118 * @since 0.6.0 119 */ 106 120 private function register_lifecycle_hooks() { 107 121 add_action( 'wp', array( $this, 'get_page_info' ) ); … … 150 164 * Staffing Engine Chatbot - <?php echo SE_CHAT_VERSION ?> 151 165 */ 152 const rwcScriptLocation = "<?php echo $this->get_rwc_script_location() ?>";153 166 154 167 const IS_MOBILE = window.innerWidth <= 768; 168 const SE_RWC_VERSION = <?php echo json_encode( self::$rwc_version ); ?>; 155 169 156 170 const handleAutoExpand = (config, autoExpandState) => { 157 171 if (autoExpandState === 'disable') { 158 config.autoExpandDelay = 0; 172 if (SE_RWC_VERSION === 'old') { 173 config.autoExpandDelay = 0; 174 } else { 175 config.widget.openDelay = 0; 176 } 159 177 } else if (autoExpandState === 'enable-not-mobile' && IS_MOBILE) { 160 config.autoExpandDelay = 0; 178 if (SE_RWC_VERSION === 'old') { 179 config.autoExpandDelay = 0; 180 } else { 181 config.widget.openDelay = 0; 182 } 161 183 } 162 184 }; 163 185 186 const rwcScriptLocation = "<?php echo $this->get_rwc_script_location() ?>"; 164 187 const config = <?php echo json_encode( self::$final_options ); ?>; 165 188 const autoExpandState = <?php echo json_encode( self::$options['auto_expand_enable'] ); ?>; … … 169 192 const staffingEngineChatConfig = Object.assign(config, { 170 193 container: '#staffing-engine-chatbot', 171 appearance: {172 blurredBackground: false,173 preloadInBackground: true,174 },175 194 pageData: { 176 195 url: window.location.href, … … 211 230 } 212 231 213 if (self::$options['advanced_override_rwc_css']) { 214 wp_enqueue_style( Plugin::SLUG . '-rwc-override', esc_attr( self::$options['advanced_override_rwc_css'] ), array(), null ); 232 if (self::$rwc_version == 'new') { 233 wp_enqueue_style( 234 Plugin::SLUG . '-rwc-defer', 235 'https://chat.staffingengine.onereach.ai/lib/richWebChat.css', 236 array(), 237 null 238 ); 239 } else if (self::$options['advanced_override_rwc_css']) { 240 wp_enqueue_style( 241 Plugin::SLUG . '-rwc-override', 242 esc_attr( self::$options['advanced_override_rwc_css'] ), 243 array(), 244 null 245 ); 215 246 } else { 216 247 wp_enqueue_style( … … 235 266 236 267 /** 268 * Get which RWC version to use 269 * 270 * @since 0.10.0 271 * @return string 272 */ 273 private function get_rwc_version() { 274 return array_key_exists( 'rwc_version', self::$options ) ? esc_attr( self::$options['rwc_version'] ) : 'old'; 275 } 276 277 /** 237 278 * Parse user-defined settings and merge with sensible defaults 238 279 * … … 241 282 */ 242 283 private function get_options_with_defaults() { 284 if (self::$rwc_version == 'new') { 285 return [ 286 "chatUrl" => array_key_exists( 'chat_url', self::$options ) ? esc_attr( self::$options['chat_url'] ) : '', 287 "appearance" => array( 288 "blurredBackground" => false, 289 "resizeable" => true, 290 "draggable" => true, 291 "saveChatSize" => true, 292 "preloadInBackground" => true, // TODO: turn back on or make a setting 293 ), 294 "widget" => array( 295 "position" => array_key_exists( 'position', self::$options ) ? self::$options['position'] : 'bottom-right', 296 "animation" => array_key_exists( 'animation', self::$options ) ? esc_attr( self::$options['animation'] ) : 'pulse', 297 "color" => array_key_exists( 'widget_color', self::$options ) ? esc_attr( self::$options['widget_color'] ) : '#ffffff', 298 "logoUrl" => $this->get_thumb_logo(), 299 "revealDelay" => 0, 300 "openDelay" => array_key_exists( 'auto_expand_delay', self::$options ) ? $this->parse_ms_setting( esc_attr( self::$options['auto_expand_delay'] ) . '000' ) : '0', 301 ), 302 "invitation" => array( 303 "closeable" => array_key_exists( 'invite_show_close_icon', self::$options ) ? $this->parse_radio_setting( esc_attr( self::$options['invite_show_close_icon'] ), true ) : true, 304 "imageUrl" => array_key_exists( 'invite_image', self::$options ) ? esc_attr( self::$options['invite_image'] ) : '', 305 "message" => $this->get_invite_message(), 306 "buttonLabel" => array_key_exists( 'invite_button_text', self::$options ) ? esc_attr( self::$options['invite_button_text'] ) : '', 307 "appearDelay" => array_key_exists( 'invite_timeout', self::$options ) ? $this->parse_ms_setting( esc_attr( self::$options['invite_timeout'] ) . '000' ) : 5000, 308 ), 309 ]; 310 } 311 243 312 return [ 244 313 "chatUrl" => 'https://v1.chat.staffingengine.onereach.ai/' . ( array_key_exists( 'key', self::$options ) ? esc_attr( self::$options['key'] ) : '' ) . '?loader=auto', … … 256 325 "allowChangeChatWindowSize" => array_key_exists( 'allow_change_window_size', self::$options ) ? $this->parse_radio_setting( esc_attr( self::$options['allow_change_window_size'] ), true ) : true, 257 326 "allowDrag" => array_key_exists( 'allow_window_drag', self::$options ) ? $this->parse_radio_setting( esc_attr( self::$options['allow_window_drag'] ), true ) : true, 327 "appearance" => array( 328 "blurredBackground" => false, 329 "preloadInBackground" => true, 330 ), 258 331 ]; 259 332 } … … 295 368 */ 296 369 private function get_rwc_script_location() { 370 if ( self::$rwc_version == 'new') { 371 return 'https://chat.staffingengine.onereach.ai/lib/richWebChat.umd.min.js'; 372 } 373 297 374 if ( self::$options['advanced_override_rwc_js']) { 298 375 return esc_attr( self::$options['advanced_override_rwc_js'] ); -
staffing-engine-chatbot/trunk/public/js/se-chatbot.js
r2966140 r3043850 1 !function(){"use strict";(async()=>{const t= (t,n)=>{console.error(`[SEChat Plugin] unable to load chatbot: ${t}`),n&&console.error(n)},n=()=>{const n=window.richWebChat.default;if(!n)return void t("richWebChat is undefined");const e=(()=>{if(staffingEngineChatConfig)return staffingEngineChatConfig})();e?new n(e):t("configuration was not provided")},e=async()=>{const n=(()=>{if(rwcScriptLocation)return rwcScriptLocation})();if(n)try{await import(n)}catch(n){return void t("richWebChat.umd.min.js could not be imported",n)}else t("richWebChat.umd.min.js not found")},i=()=>{const t=(()=>{if(staffingEngineChatSettings)return staffingEngineChatSettings})();if(t.thumbIconSize&&"default"!==t.thumbIconSize){const n=document.querySelector("#staffing-engine-chatbot .rwc-embed-thumb");if(!n)return;n.classList.add(`se-chatbot-thumb--${t.thumbIconSize}`)}},a=async()=>{await e(),await n(),i(),(()=>{const t=window.richWebChat.Sdk,n=document.querySelector('#staffing-engine-chatbot button[aria-label="Close chat"]');var e,i,a,o,c;i="click",a=()=>t.sendGlobalCommand({name:"close"}),(e=n)&&(c&&a(e[o]),e.addEventListener(i,(t=>a(t.target[o]))))})()};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(async()=>{await a()}),!1):await a()})()}();1 !function(){"use strict";(async()=>{const t="se-chatbot-open",e=(t,e)=>{console.error(`[SEChat Plugin] unable to load chatbot: ${t}`),e&&console.error(e)},n=(t,e,n,o,a)=>{t&&(a&&n(t[o]),t.addEventListener(e,(t=>n(t.target[o]))))},o=()=>{const t=window.richWebChat.default;if(!t)return void e("richWebChat is undefined");const n=(()=>{if(staffingEngineChatConfig)return staffingEngineChatConfig})();if(!n)return void e("configuration was not provided");const o=new t(n);window.SEChatbot=o},a=async()=>{const t=(()=>{if(rwcScriptLocation)return rwcScriptLocation})();if(t)try{await import(t)}catch(t){return void e("richWebChat.umd.min.js could not be imported",t)}else e("richWebChat.umd.min.js not found")},i=()=>{try{const t=(()=>{if(staffingEngineChatSettings)return staffingEngineChatSettings})();if(t.thumbIconSize&&"default"!==t.thumbIconSize){const e=document.querySelector("#staffing-engine-chatbot .rwc-embed-thumb");if(!e)return;e.classList.add(`se-chatbot-thumb--${t.thumbIconSize}`)}}catch(t){e("failed to apply chatbot settings",t)}},c=()=>{try{if("new"===(()=>{if(SE_RWC_VERSION)return SE_RWC_VERSION})()){const t=window.SEChatbot,e=document.querySelector("#staffing-engine-chatbot button.rwc-embed__close-btn");n(e,"click",(()=>t.runGlobalCommand({name:"closeChat"})))}else{const t=window.richWebChat.Sdk,e=document.querySelector('#staffing-engine-chatbot button[aria-label="Close chat"]');n(e,"click",(()=>t.sendGlobalCommand({name:"close"})))}}catch(t){e("failed to register global command listeners",t)}},r=async()=>{try{const e=localStorage.getItem(t);if(await(n=document.querySelector("#staffing-engine-chatbot"),o="rwc-embed",new Promise((t=>{const e=new MutationObserver((n=>{n.forEach((n=>{n.target.className.includes(o)&&(e.disconnect(),t())}))}));e.observe(n,{subtree:!0,childList:!0})}))),!e||"closed"===e)return;const a=window.SEChatbot;if(a.isChatOpen)return;a.openChat()}catch(t){e("failed to manage open state",t)}var n,o},s=async()=>{await a(),await o(),i(),c(),(()=>{try{const e=window.richWebChat.Sdk,n=t=>t.isOpen?"open":"closed";e.on("toggle-chat-window",(e=>{localStorage.setItem(t,n(e))}))}catch(t){e("failed to register chat state listener",t)}})(),await r()};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(async()=>{await s()}),!1):await s()})()}(); -
staffing-engine-chatbot/trunk/readme.txt
r2966140 r3043850 4 4 - Donate Link: https://staffingengine.ai/ 5 5 - Tags: chatbot, live chat, AI, staffing, recruiting 6 - Stable tag: 0.9. 46 - Stable tag: 0.9.5 7 7 - Requires at least: 5.5 8 8 - Tested up to: 6.3.1 … … 110 110 111 111 - bug fixes 112 113 = 0.9.5 : 2024-3-1 = 114 115 - sync the open state of the chat window across tabs and reloads. If the window was open, it 116 will now re-open when site users move to a new tab or reload the page 117 - bug fixes -
staffing-engine-chatbot/trunk/staffing-engine-chatbot.php
r2966140 r3043850 5 5 * @copyright (c) 2023 staffing Engine 6 6 * @license GPL-3.0-or-later 7 * @version 0.9. 47 * @version 0.9.5 8 8 * 9 9 * @wordpress-plugin … … 15 15 * License: GPL v3 or later 16 16 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html 17 * Version: 0.9. 417 * Version: 0.9.5 18 18 * Requires at least: 5.5 19 19 * Requires PHP: 7.1 … … 44 44 } 45 45 46 define( 'SE_CHAT_VERSION', '0.9. 4' );46 define( 'SE_CHAT_VERSION', '0.9.5' ); 47 47 define( 'CURRENT_WP_VERSION', $wp_version ); 48 48
Note: See TracChangeset
for help on using the changeset viewer.