예제 #1
0
 /**
  * Get all strings for frontend and backend
  *
  * @since   1.1.0
  * @return  array
  * @author  Alberto Ruggiero
  */
 public function get_strings()
 {
     $options = $this->options;
     return array('months' => array('jan' => __('January', 'yith-live-chat'), 'feb' => __('February', 'yith-live-chat'), 'mar' => __('March', 'yith-live-chat'), 'apr' => __('April', 'yith-live-chat'), 'may' => __('May', 'yith-live-chat'), 'jun' => __('June', 'yith-live-chat'), 'jul' => __('July', 'yith-live-chat'), 'aug' => __('August', 'yith-live-chat'), 'sep' => __('September', 'yith-live-chat'), 'oct' => __('October', 'yith-live-chat'), 'nov' => __('November', 'yith-live-chat'), 'dec' => __('December', 'yith-live-chat')), 'months_short' => array('jan' => __('Jan', 'yith-live-chat'), 'feb' => __('Feb', 'yith-live-chat'), 'mar' => __('Mar', 'yith-live-chat'), 'apr' => __('Apr', 'yith-live-chat'), 'may' => __('May', 'yith-live-chat'), 'jun' => __('Jun', 'yith-live-chat'), 'jul' => __('Jul', 'yith-live-chat'), 'aug' => __('Aug', 'yith-live-chat'), 'sep' => __('Sep', 'yith-live-chat'), 'oct' => __('Oct', 'yith-live-chat'), 'nov' => __('Nov', 'yith-live-chat'), 'dec' => __('Dec', 'yith-live-chat')), 'time' => array('suffix' => __('ago', 'yith-live-chat'), 'seconds' => __('less than a minute', 'yith-live-chat'), 'minute' => __('about a minute', 'yith-live-chat'), 'minutes' => __('%d minutes', 'yith-live-chat'), 'hour' => __('about an hour', 'yith-live-chat'), 'hours' => __('about %d hours', 'yith-live-chat'), 'day' => __('a day', 'yith-live-chat'), 'days' => __('%d days', 'yith-live-chat'), 'month' => __('about a month', 'yith-live-chat'), 'months' => __('%d months', 'yith-live-chat'), 'year' => __('about a year', 'yith-live-chat'), 'years' => __('%d years', 'yith-live-chat')), 'fields' => array('name' => __('Your Name', 'yith-live-chat'), 'name_ph' => __('Please enter your name', 'yith-live-chat'), 'email' => __('Your Email', 'yith-live-chat'), 'email_ph' => __('Please enter your email', 'yith-live-chat'), 'message' => __('Your Message', 'yith-live-chat'), 'message_ph' => __('Write your question', 'yith-live-chat')), 'msg' => array('chat_title' => ylc_sanitize_text(esc_html($options['text-chat-title'])), 'prechat_msg' => ylc_sanitize_text(esc_html($options['text-welcome']), true), 'welc_msg' => ylc_sanitize_text(esc_html($options['text-start-chat']), true), 'start_chat' => __('Start Chat', 'yith-live-chat'), 'offline_body' => ylc_sanitize_text(esc_html($options['text-offline']), true), 'busy_body' => ylc_sanitize_text(esc_html($options['text-busy']), true), 'close_msg' => ylc_sanitize_text(esc_html($options['text-close']), true), 'close_msg_user' => __('The user has closed the conversation', 'yith-live-chat'), 'reply_ph' => __('Type here and hit enter to chat', 'yith-live-chat'), 'send_btn' => __('Send', 'yith-live-chat'), 'no_op' => __('No operators online', 'yith-live-chat'), 'no_msg' => __('No messages found', 'yith-live-chat'), 'sending' => __('Sending', 'yith-live-chat'), 'connecting' => __('Connecting', 'yith-live-chat'), 'writing' => __('%s is writing', 'yith-live-chat'), 'please_wait' => __('Please wait', 'yith-live-chat'), 'chat_online' => __('Chat Online', 'yith-live-chat'), 'chat_offline' => __('Chat Offline', 'yith-live-chat'), 'your_msg' => __('Your message', 'yith-live-chat'), 'end_chat' => __('End chat', 'yith-live-chat'), 'conn_err' => __('Connection error!', 'yith-live-chat'), 'you' => __('You', 'yith-live-chat'), 'online_btn' => __('Online', 'yith-live-chat'), 'offline_btn' => __('Offline', 'yith-live-chat'), 'field_empty' => __('Please fill out all required fields', 'yith-live-chat'), 'invalid_email' => __('Email is invalid', 'yith-live-chat'), 'invalid_username' => __('Username is invalid', 'yith-live-chat'), 'user_name' => __('User Name', 'yith-live-chat'), 'user_email' => __('User Email', 'yith-live-chat'), 'user_ip' => __('IP Address', 'yith-live-chat'), 'user_page' => __('Current Page', 'yith-live-chat'), 'connect' => __('Connect', 'yith-live-chat'), 'disconnect' => __('Disconnect', 'yith-live-chat'), 'you_offline' => __('You are offline', 'yith-live-chat'), 'save_chat' => __('Save chat', 'yith-live-chat'), 'ntf_close_console' => __('If you leave the chat, you will be logged out. However you will be able to save the conversations into your server when you will come back in the console!', 'yith-live-chat'), 'new_msg' => __('New Message', 'yith-live-chat'), 'new_user_online' => __('New User Online', 'yith-live-chat'), 'saving' => __('Saving', 'yith-live-chat'), 'waiting_users' => defined('YLC_PREMIUM') ? __('User queue: %d', 'yith-live-chat') : __('There are people waiting to talk', 'yith-live-chat'), 'good' => __('Good', 'yith-live-chat'), 'bad' => __('Bad', 'yith-live-chat'), 'chat_evaluation' => __('Was this conversation useful? Vote this chat session.', 'yith-live-chat'), 'talking_label' => __('Talking with %s', 'yith-live-chat'), 'timer' => __('Elapsed time', 'yith-live-chat'), 'chat_copy' => __('Receive the copy of the chat via e-mail', 'yith-live-chat'), 'already_logged' => __('A user is already logged in with the same email address', 'yith-live-chat'), 'current_shop' => __('%s shop', 'yith-live-chat')));
 }
예제 #2
0
 /**
  * Load Live Chat scripts
  *
  * @since   1.0.0
  * @return  void
  * @author  Alberto Ruggiero
  */
 public function load_livechat_js()
 {
     wp_register_script('ylc-firebase', YLC_ASSETS_URL . '/js/firebase.js');
     wp_enqueue_script('ylc-firebase');
     wp_register_script('ylc-engine', YLC_ASSETS_URL . '/js/ylc-engine.js', array('jquery', 'ylc-firebase'));
     wp_enqueue_script('ylc-engine');
     $options = $this->options;
     $js_vars = array('app_id' => esc_html($options['firebase-appurl']), 'ajax_url' => str_replace(array('https:', 'http:'), '', admin_url('admin-ajax.php')), 'plugin_url' => YLC_ASSETS_URL, 'is_front_end' => !is_admin() ? true : null, 'is_op' => defined('YLC_OPERATOR') && is_admin() ? true : false, 'is_premium' => defined('YLC_PREMIUM') ? true : false, 'current_page' => $this->current_page, 'user_ip' => $this->ip, 'show_busy_form' => apply_filters('ylc_busy_form', false), 'max_guests' => apply_filters('ylc_max_guests', 2), 'send_transcript' => apply_filters('ylc_send_transcript', false), 'chat_evaluation' => apply_filters('ylc_chat_evaluation', false), 'company_avatar' => apply_filters('ylc_company_avatar', ''), 'autoplay_opts' => apply_filters('ylc_autoplay_opts', array()), 'templates' => array('chat_popup' => file_get_contents(YLC_DIR . 'templates/chat-frontend/chat-popup.php'), 'chat_connecting' => file_get_contents(YLC_DIR . 'templates/chat-frontend/chat-connecting.php'), 'chat_btn' => file_get_contents(YLC_DIR . 'templates/chat-frontend/chat-btn.php'), 'chat_offline' => file_get_contents(YLC_DIR . 'templates/chat-frontend/chat-offline.php'), 'chat_login' => file_get_contents(YLC_DIR . 'templates/chat-frontend/chat-login.php'), 'chat_conversation' => file_get_contents(YLC_DIR . 'templates/chat-frontend/chat-conversation.php'), 'chat_line' => file_get_contents(YLC_DIR . 'templates/chat-frontend/chat-line.php'), 'console_user_item' => file_get_contents(YLC_DIR . 'templates/chat-backend/console-user-item.php'), 'console_conversation' => file_get_contents(YLC_DIR . 'templates/chat-backend/console-conversation.php'), 'console_user_info' => file_get_contents(YLC_DIR . 'templates/chat-backend/console-user-info.php'), 'console_user_tools' => file_get_contents(YLC_DIR . 'templates/chat-backend/console-user-tools.php'), 'premium' => apply_filters('ylc_templates_premium', array())), 'strings' => array('months' => array('jan' => __('January', 'ylc'), 'feb' => __('February', 'ylc'), 'mar' => __('March', 'ylc'), 'apr' => __('April', 'ylc'), 'may' => __('May', 'ylc'), 'jun' => __('June', 'ylc'), 'jul' => __('July', 'ylc'), 'aug' => __('August', 'ylc'), 'sep' => __('September', 'ylc'), 'oct' => __('October', 'ylc'), 'nov' => __('November', 'ylc'), 'dec' => __('December', 'ylc')), 'months_short' => array('jan' => __('Jan', 'ylc'), 'feb' => __('Feb', 'ylc'), 'mar' => __('Mar', 'ylc'), 'apr' => __('Apr', 'ylc'), 'may' => __('May', 'ylc'), 'jun' => __('Jun', 'ylc'), 'jul' => __('Jul', 'ylc'), 'aug' => __('Aug', 'ylc'), 'sep' => __('Sep', 'ylc'), 'oct' => __('Oct', 'ylc'), 'nov' => __('Nov', 'ylc'), 'dec' => __('Dec', 'ylc')), 'time' => array('suffix' => __('ago', 'ylc'), 'seconds' => __('less than a minute', 'ylc'), 'minute' => __('about a minute', 'ylc'), 'minutes' => __('%d minutes', 'ylc'), 'hour' => __('about an hour', 'ylc'), 'hours' => __('about %d hours', 'ylc'), 'day' => __('a day', 'ylc'), 'days' => __('%d days', 'ylc'), 'month' => __('about a month', 'ylc'), 'months' => __('%d months', 'ylc'), 'year' => __('about a year', 'ylc'), 'years' => __('%d years', 'ylc')), 'fields' => array('name' => __('Your Name', 'ylc'), 'name_ph' => __('Please enter your name', 'ylc'), 'email' => __('Your Email', 'ylc'), 'email_ph' => __('Please enter your email', 'ylc'), 'message' => __('Your Message', 'ylc'), 'message_ph' => __('Write your question', 'ylc')), 'msg' => array('chat_title' => ylc_sanitize_text(esc_html($options['text-chat-title'])), 'prechat_msg' => ylc_sanitize_text(esc_html($options['text-welcome']), true), 'welc_msg' => ylc_sanitize_text(esc_html($options['text-start-chat']), true), 'start_chat' => __('Start Chat', 'ylc'), 'offline_body' => ylc_sanitize_text(esc_html($options['text-offline']), true), 'busy_body' => ylc_sanitize_text(esc_html($options['text-busy']), true), 'close_msg' => ylc_sanitize_text(esc_html($options['text-close']), true), 'close_msg_user' => __('The user has closed the conversation', 'ylc'), 'reply_ph' => __('Type here and hit enter to chat', 'ylc'), 'send_btn' => __('Send', 'ylc'), 'no_op' => __('No operators online', 'ylc'), 'no_msg' => __('No messages found', 'ylc'), 'sending' => __('Sending', 'ylc'), 'connecting' => __('Connecting', 'ylc'), 'writing' => __('%s is writing', 'ylc'), 'please_wait' => __('Please wait', 'ylc'), 'chat_online' => __('Chat Online', 'ylc'), 'chat_offline' => __('Chat Offline', 'ylc'), 'your_msg' => __('Your message', 'ylc'), 'end_chat' => __('End chat', 'ylc'), 'conn_err' => __('Connection error!', 'ylc'), 'you' => __('You', 'ylc'), 'online_btn' => __('Online', 'ylc'), 'offline_btn' => __('Offline', 'ylc'), 'field_empty' => __('Please fill out all required fields', 'ylc'), 'invalid_email' => __('Email is invalid', 'ylc'), 'invalid_username' => __('Username is invalid', 'ylc'), 'user_email' => __('User Email', 'ylc'), 'user_ip' => __('IP Address', 'ylc'), 'user_page' => __('Current Page', 'ylc'), 'connect' => __('Connect', 'ylc'), 'disconnect' => __('Disconnect', 'ylc'), 'you_offline' => __('You are offline', 'ylc'), 'save_chat' => __('Save chat', 'ylc'), 'ntf_close_console' => __('If you leave the chat, you will be logged out. However you will be able to save the conversations into your server when you will come back in the console!', 'ylc'), 'new_msg' => __('New Message', 'ylc'), 'new_user_online' => __('New User Online', 'ylc'), 'saving' => __('Saving', 'ylc'), 'waiting_users' => defined('YLC_PREMIUM') ? __('User queue: %d', 'ylc') : __('There are people waiting to talk', 'ylc'), 'good' => __('Good', 'ylc'), 'bad' => __('Bad', 'ylc'), 'chat_evaluation' => __('Was this conversation useful? Vote this chat session.', 'ylc'), 'talking_label' => __('Talking with %s', 'ylc'), 'timer' => __('Elapsed time', 'ylc'), 'chat_copy' => __('Receive the copy of the chat via e-mail', 'ylc'), 'already_logged' => __('A user is already logged in with the same email address', 'ylc'))));
     if (is_user_logged_in()) {
         if (defined('YLC_OPERATOR') && is_admin()) {
             $user_prefix = 'ylc-op-';
             $user_type = 'operator';
         } else {
             $user_prefix = '';
             $user_type = 'visitor';
         }
         $js_vars['user_id'] = $user_prefix . $this->user->ID;
         $js_vars['user_name'] = apply_filters('ylc_nickname', $this->user->display_name);
         $js_vars['user_email'] = $this->user->user_email;
         $js_vars['user_email_hash'] = md5($this->user->user_email);
         $js_vars['user_type'] = $user_type;
         $js_vars['avatar_type'] = apply_filters('ylc_avatar_type', '');
         $js_vars['avatar_image'] = apply_filters('ylc_avatar_image', '');
         $js_vars['frontend_op_access'] = current_user_can('answer_chat') ? true : false;
     }
     wp_localize_script('ylc-engine', 'ylc', $js_vars);
 }