Plugin Directory

Changeset 3043850


Ignore:
Timestamp:
03/02/2024 12:30:47 AM (2 years ago)
Author:
staffingengine
Message:

Update to version 0.9.5 from GitHub

Location:
staffing-engine-chatbot
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • staffing-engine-chatbot/tags/0.9.5/includes/admin.php

    r2911282 r3043850  
    231231                ),
    232232              ),
     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              // ),
    233244                            'key' => array(
    234245                                'id'          => 'key',
    235246                                'type'      => 'text',
    236                                 'title'     => __( 'Bot key', Plugin::SLUG ),
     247                                'title'     => __( 'Bot Key', Plugin::SLUG ),
    237248                'text'    => __( 'Your unique chat instance key. Contact Staffing Engine support if you haven\'t received one.', Plugin::SLUG ),
    238249                                'default'   => '',
    239250                            ),
     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                            // ),
    240258            ),
    241259          ),
    242260          'appearance' => array(
    243             'title'  => __( 'Appearance', Plugin::SLUG),
     261            'title'  => __( 'Widget', Plugin::SLUG),
    244262            'text'   => __( 'Customize the chat widget\'s appearance', Plugin::SLUG ),
    245263            'fields' => array(
    246264              'position' => array(
    247265                'id'          => 'position',
    248                 'title'   => __( 'Bot position', Plugin::SLUG ),
     266                'title'   => __( 'Position', Plugin::SLUG ),
    249267                'text'    => __( 'Set the location of the bot on your site.', Plugin::SLUG ),
    250268                'type'    => 'select',
     
    259277              'widgetColor' => array(
    260278                'id'    => 'widget_color',
    261                 'title' => __( 'Widget Color', Plugin::SLUG ),
     279                'title' => __( 'Color', Plugin::SLUG ),
    262280                'text'  => __( 'Set the background color of the chatbot embed.', Plugin::SLUG ),
    263281                'type'  => 'color',
     
    266284              'thumbLogo'   => array(
    267285                'id'    => 'thumb_logo',
    268                 'title' => __( 'Thumb Logo', Plugin::SLUG ),
     286                'title' => __( 'Logo', Plugin::SLUG ),
    269287                'text'  => __( 'Upload a custom logo for your chatbot.', Plugin::SLUG ),
    270288                'type'  => 'media',
     
    273291              'animation' => array(
    274292                'id'      => 'animation',
    275                 'title'   => __( 'Animation type', Plugin::SLUG ),
     293                'title'   => __( 'Animation', Plugin::SLUG ),
    276294                'text'    => __( 'Choose an animation style to get the attention of site visitors.', Plugin::SLUG ),
    277295                'type'    => 'select',
     
    298316          ),
    299317          'invite_popup' => array(
    300             'title'  => __( ' Invitation Popup', Plugin::SLUG ),
     318            'title'  => __( ' Invitation', Plugin::SLUG ),
    301319            'text'   => __( 'Show an informational popup next to the widget after a set duration', Plugin::SLUG ),
    302320            'fields' => array(
     
    309327              'inviteMessage'   => array(
    310328                'id'    => 'invite_message',
    311                 'title' => __( 'Invite Message', Plugin::SLUG ),
     329                'title' => __( 'Message', Plugin::SLUG ),
    312330                'type'  => 'textarea',
    313331                'class' => 'inviteMessage',
     
    318336              'inviteButtonText' => array(
    319337                'id'    => 'invite_button_text',
    320                 'title' => __( 'Invite Button text', Plugin::SLUG ),
     338                'title' => __( 'Button text', Plugin::SLUG ),
    321339                'text'  => __( 'Display a button with this text in the popup (optional).', Plugin::SLUG ),
    322340                'type'  => 'text',
     
    325343              'inviteImage' => array(
    326344                'id'    => 'invite_image',
    327                 'title' => __( 'Invite Image', Plugin::SLUG ),
     345                'title' => __( 'Image', Plugin::SLUG ),
    328346                'text'  => __( 'Display an image in the popup (optional).', Plugin::SLUG ),
    329347                'type'  => 'media',
     
    332350              'inviteShowCloseIcon' => array(
    333351                'id'      => 'invite_show_close_icon',
    334                 'title'   => __( 'Show Close Icon', Plugin::SLUG ),
     352                'title'   => __( 'Closeable', Plugin::SLUG ),
    335353                'text'    => __( 'Show the close icon on the popup. If not shown, the popup cannot be dismissed.', Plugin::SLUG  ),
    336354                'type'    => 'radio',
     
    343361              'inviteTimeout'   => array(
    344362                'id'         => 'invite_timeout',
    345                 'title'      => __( 'Invite Timeout', Plugin::SLUG ),
     363                'title'      => __( 'Appear Delay', Plugin::SLUG ),
    346364                'text'       => __( 'Set how long until the popup appears (in seconds)', Plugin::SLUG ),
    347365                'type'       => 'number',
     
    400418              'allowWindowDrag' => array(
    401419                'id'      => 'allow_window_drag',
    402                 'title'   => __( 'Allow dragging the chat window', Plugin::SLUG ),
     420                'title'   => __( 'Draggable', Plugin::SLUG ),
    403421                'text'    => __( 'Set whether site visitors can move the chat window around the site.', Plugin::SLUG ),
    404422                'type'    => 'radio',
  • staffing-engine-chatbot/tags/0.9.5/includes/embed.php

    r2947887 r3043850  
    7575
    7676  /**
     77   * The RWC version
     78   *
     79   * @since 0.10.0
     80   * @var   string
     81   */
     82  private static $rwc_version = '4';
     83
     84  /**
    7785     * Instance Builder
    7886     *
     
    97105    public function __construct() {
    98106    self::$options = get_option( Plugin::SLUG . '_settings', array() );
     107    self::$rwc_version = $this->get_rwc_version();
    99108    self::$final_options = $this->get_options_with_defaults();
    100109    self::$settings = $this->get_settings_with_defaults();
     
    104113  }
    105114
     115  /**
     116   * Register lifecycle hooks
     117   *
     118   * @since 0.6.0
     119   */
    106120  private function register_lifecycle_hooks() {
    107121    add_action( 'wp', array( $this, 'get_page_info' ) );
     
    150164   * Staffing Engine Chatbot - <?php echo SE_CHAT_VERSION ?>
    151165   */
    152   const rwcScriptLocation = "<?php echo $this->get_rwc_script_location() ?>";
    153166
    154167  const IS_MOBILE = window.innerWidth <= 768;
     168  const SE_RWC_VERSION = <?php echo json_encode( self::$rwc_version ); ?>;
    155169
    156170  const handleAutoExpand = (config, autoExpandState) => {
    157171    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      }
    159177    } 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      }
    161183    }
    162184  };
    163185
     186  const rwcScriptLocation = "<?php echo $this->get_rwc_script_location() ?>";
    164187  const config = <?php echo json_encode( self::$final_options ); ?>;
    165188  const autoExpandState = <?php echo json_encode( self::$options['auto_expand_enable'] ); ?>;
     
    169192  const staffingEngineChatConfig = Object.assign(config, {
    170193    container: '#staffing-engine-chatbot',
    171     appearance: {
    172       blurredBackground: false,
    173       preloadInBackground: true,
    174     },
    175194    pageData: {
    176195      url: window.location.href,
     
    211230    }
    212231
    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      );
    215246    } else {
    216247          wp_enqueue_style(
     
    235266
    236267  /**
     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  /**
    237278   * Parse user-defined settings and merge with sensible defaults
    238279   *
     
    241282   */
    242283  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
    243312    return [
    244313      "chatUrl" => 'https://v1.chat.staffingengine.onereach.ai/' . ( array_key_exists( 'key', self::$options ) ? esc_attr( self::$options['key'] ) : '' ) . '?loader=auto',
     
    256325      "allowChangeChatWindowSize" => array_key_exists( 'allow_change_window_size', self::$options ) ? $this->parse_radio_setting( esc_attr( self::$options['allow_change_window_size'] ), true ) : true,
    257326      "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      ),
    258331    ];
    259332  }
     
    295368   */
    296369  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
    297374    if ( self::$options['advanced_override_rwc_js']) {
    298375      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  
    44- Donate Link: https://staffingengine.ai/
    55- Tags: chatbot, live chat, AI, staffing, recruiting
    6 - Stable tag: 0.9.4
     6- Stable tag: 0.9.5
    77- Requires at least: 5.5
    88- Tested up to: 6.3.1
     
    110110
    111111- 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  
    55 * @copyright   (c) 2023 staffing Engine
    66 * @license     GPL-3.0-or-later
    7  * @version     0.9.4
     7 * @version     0.9.5
    88 *
    99 * @wordpress-plugin
     
    1515 * License: GPL v3 or later
    1616 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
    17  * Version: 0.9.4
     17 * Version: 0.9.5
    1818 * Requires at least: 5.5
    1919 * Requires PHP: 7.1
     
    4444}
    4545
    46 define( 'SE_CHAT_VERSION', '0.9.4' );
     46define( 'SE_CHAT_VERSION', '0.9.5' );
    4747define( 'CURRENT_WP_VERSION', $wp_version );
    4848
  • staffing-engine-chatbot/trunk/includes/admin.php

    r2911282 r3043850  
    231231                ),
    232232              ),
     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              // ),
    233244                            'key' => array(
    234245                                'id'          => 'key',
    235246                                'type'      => 'text',
    236                                 'title'     => __( 'Bot key', Plugin::SLUG ),
     247                                'title'     => __( 'Bot Key', Plugin::SLUG ),
    237248                'text'    => __( 'Your unique chat instance key. Contact Staffing Engine support if you haven\'t received one.', Plugin::SLUG ),
    238249                                'default'   => '',
    239250                            ),
     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                            // ),
    240258            ),
    241259          ),
    242260          'appearance' => array(
    243             'title'  => __( 'Appearance', Plugin::SLUG),
     261            'title'  => __( 'Widget', Plugin::SLUG),
    244262            'text'   => __( 'Customize the chat widget\'s appearance', Plugin::SLUG ),
    245263            'fields' => array(
    246264              'position' => array(
    247265                'id'          => 'position',
    248                 'title'   => __( 'Bot position', Plugin::SLUG ),
     266                'title'   => __( 'Position', Plugin::SLUG ),
    249267                'text'    => __( 'Set the location of the bot on your site.', Plugin::SLUG ),
    250268                'type'    => 'select',
     
    259277              'widgetColor' => array(
    260278                'id'    => 'widget_color',
    261                 'title' => __( 'Widget Color', Plugin::SLUG ),
     279                'title' => __( 'Color', Plugin::SLUG ),
    262280                'text'  => __( 'Set the background color of the chatbot embed.', Plugin::SLUG ),
    263281                'type'  => 'color',
     
    266284              'thumbLogo'   => array(
    267285                'id'    => 'thumb_logo',
    268                 'title' => __( 'Thumb Logo', Plugin::SLUG ),
     286                'title' => __( 'Logo', Plugin::SLUG ),
    269287                'text'  => __( 'Upload a custom logo for your chatbot.', Plugin::SLUG ),
    270288                'type'  => 'media',
     
    273291              'animation' => array(
    274292                'id'      => 'animation',
    275                 'title'   => __( 'Animation type', Plugin::SLUG ),
     293                'title'   => __( 'Animation', Plugin::SLUG ),
    276294                'text'    => __( 'Choose an animation style to get the attention of site visitors.', Plugin::SLUG ),
    277295                'type'    => 'select',
     
    298316          ),
    299317          'invite_popup' => array(
    300             'title'  => __( ' Invitation Popup', Plugin::SLUG ),
     318            'title'  => __( ' Invitation', Plugin::SLUG ),
    301319            'text'   => __( 'Show an informational popup next to the widget after a set duration', Plugin::SLUG ),
    302320            'fields' => array(
     
    309327              'inviteMessage'   => array(
    310328                'id'    => 'invite_message',
    311                 'title' => __( 'Invite Message', Plugin::SLUG ),
     329                'title' => __( 'Message', Plugin::SLUG ),
    312330                'type'  => 'textarea',
    313331                'class' => 'inviteMessage',
     
    318336              'inviteButtonText' => array(
    319337                'id'    => 'invite_button_text',
    320                 'title' => __( 'Invite Button text', Plugin::SLUG ),
     338                'title' => __( 'Button text', Plugin::SLUG ),
    321339                'text'  => __( 'Display a button with this text in the popup (optional).', Plugin::SLUG ),
    322340                'type'  => 'text',
     
    325343              'inviteImage' => array(
    326344                'id'    => 'invite_image',
    327                 'title' => __( 'Invite Image', Plugin::SLUG ),
     345                'title' => __( 'Image', Plugin::SLUG ),
    328346                'text'  => __( 'Display an image in the popup (optional).', Plugin::SLUG ),
    329347                'type'  => 'media',
     
    332350              'inviteShowCloseIcon' => array(
    333351                'id'      => 'invite_show_close_icon',
    334                 'title'   => __( 'Show Close Icon', Plugin::SLUG ),
     352                'title'   => __( 'Closeable', Plugin::SLUG ),
    335353                'text'    => __( 'Show the close icon on the popup. If not shown, the popup cannot be dismissed.', Plugin::SLUG  ),
    336354                'type'    => 'radio',
     
    343361              'inviteTimeout'   => array(
    344362                'id'         => 'invite_timeout',
    345                 'title'      => __( 'Invite Timeout', Plugin::SLUG ),
     363                'title'      => __( 'Appear Delay', Plugin::SLUG ),
    346364                'text'       => __( 'Set how long until the popup appears (in seconds)', Plugin::SLUG ),
    347365                'type'       => 'number',
     
    400418              'allowWindowDrag' => array(
    401419                'id'      => 'allow_window_drag',
    402                 'title'   => __( 'Allow dragging the chat window', Plugin::SLUG ),
     420                'title'   => __( 'Draggable', Plugin::SLUG ),
    403421                'text'    => __( 'Set whether site visitors can move the chat window around the site.', Plugin::SLUG ),
    404422                'type'    => 'radio',
  • staffing-engine-chatbot/trunk/includes/embed.php

    r2947887 r3043850  
    7575
    7676  /**
     77   * The RWC version
     78   *
     79   * @since 0.10.0
     80   * @var   string
     81   */
     82  private static $rwc_version = '4';
     83
     84  /**
    7785     * Instance Builder
    7886     *
     
    97105    public function __construct() {
    98106    self::$options = get_option( Plugin::SLUG . '_settings', array() );
     107    self::$rwc_version = $this->get_rwc_version();
    99108    self::$final_options = $this->get_options_with_defaults();
    100109    self::$settings = $this->get_settings_with_defaults();
     
    104113  }
    105114
     115  /**
     116   * Register lifecycle hooks
     117   *
     118   * @since 0.6.0
     119   */
    106120  private function register_lifecycle_hooks() {
    107121    add_action( 'wp', array( $this, 'get_page_info' ) );
     
    150164   * Staffing Engine Chatbot - <?php echo SE_CHAT_VERSION ?>
    151165   */
    152   const rwcScriptLocation = "<?php echo $this->get_rwc_script_location() ?>";
    153166
    154167  const IS_MOBILE = window.innerWidth <= 768;
     168  const SE_RWC_VERSION = <?php echo json_encode( self::$rwc_version ); ?>;
    155169
    156170  const handleAutoExpand = (config, autoExpandState) => {
    157171    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      }
    159177    } 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      }
    161183    }
    162184  };
    163185
     186  const rwcScriptLocation = "<?php echo $this->get_rwc_script_location() ?>";
    164187  const config = <?php echo json_encode( self::$final_options ); ?>;
    165188  const autoExpandState = <?php echo json_encode( self::$options['auto_expand_enable'] ); ?>;
     
    169192  const staffingEngineChatConfig = Object.assign(config, {
    170193    container: '#staffing-engine-chatbot',
    171     appearance: {
    172       blurredBackground: false,
    173       preloadInBackground: true,
    174     },
    175194    pageData: {
    176195      url: window.location.href,
     
    211230    }
    212231
    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      );
    215246    } else {
    216247          wp_enqueue_style(
     
    235266
    236267  /**
     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  /**
    237278   * Parse user-defined settings and merge with sensible defaults
    238279   *
     
    241282   */
    242283  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
    243312    return [
    244313      "chatUrl" => 'https://v1.chat.staffingengine.onereach.ai/' . ( array_key_exists( 'key', self::$options ) ? esc_attr( self::$options['key'] ) : '' ) . '?loader=auto',
     
    256325      "allowChangeChatWindowSize" => array_key_exists( 'allow_change_window_size', self::$options ) ? $this->parse_radio_setting( esc_attr( self::$options['allow_change_window_size'] ), true ) : true,
    257326      "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      ),
    258331    ];
    259332  }
     
    295368   */
    296369  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
    297374    if ( self::$options['advanced_override_rwc_js']) {
    298375      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  
    44- Donate Link: https://staffingengine.ai/
    55- Tags: chatbot, live chat, AI, staffing, recruiting
    6 - Stable tag: 0.9.4
     6- Stable tag: 0.9.5
    77- Requires at least: 5.5
    88- Tested up to: 6.3.1
     
    110110
    111111- 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  
    55 * @copyright   (c) 2023 staffing Engine
    66 * @license     GPL-3.0-or-later
    7  * @version     0.9.4
     7 * @version     0.9.5
    88 *
    99 * @wordpress-plugin
     
    1515 * License: GPL v3 or later
    1616 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
    17  * Version: 0.9.4
     17 * Version: 0.9.5
    1818 * Requires at least: 5.5
    1919 * Requires PHP: 7.1
     
    4444}
    4545
    46 define( 'SE_CHAT_VERSION', '0.9.4' );
     46define( 'SE_CHAT_VERSION', '0.9.5' );
    4747define( 'CURRENT_WP_VERSION', $wp_version );
    4848
Note: See TracChangeset for help on using the changeset viewer.