WP Live Chat Support - Version 6.0.06

Version Description

  • 2016-03-07 - Medium priority =
  • More stable fix for the menu item bug that has been experienced lately
Download this release

Release Info

Developer WP-LiveChat
Plugin Icon 128x128 WP Live Chat Support
Version 6.0.06
Comparing to
See all releases

Code changes from version 6.0.05 to 6.0.06

Files changed (3) hide show
  1. ajax_new.php +8 -0
  2. js/wplc_u_admin.js +10 -0
  3. wp-live-chat-support.php +185 -83
ajax_new.php CHANGED
@@ -52,6 +52,14 @@ function wplc_init_ajax_callback() {
52
  if (defined('WPLC_TIMEOUT')) { @set_time_limit(WPLC_TIMEOUT); } else { @set_time_limit(120); }
53
  //sleep(6);
54
  $i = 1;
 
 
 
 
 
 
 
 
55
  while($i <= $iterations){
56
 
57
 
52
  if (defined('WPLC_TIMEOUT')) { @set_time_limit(WPLC_TIMEOUT); } else { @set_time_limit(120); }
53
  //sleep(6);
54
  $i = 1;
55
+ $wplc_current_user = get_current_user_id();
56
+
57
+ /* If user is either an agent or an admin, access the page. */
58
+ if( !get_user_meta( $wplc_current_user, 'wplc_ma_agent', true )) {
59
+ $array['error'] = 1;
60
+ echo json_encode($array);
61
+ exit();
62
+ }
63
  while($i <= $iterations){
64
 
65
 
js/wplc_u_admin.js CHANGED
@@ -68,6 +68,16 @@ function wplc_call_to_server(data) {
68
  //Update your dashboard gauge
69
  if (response) {
70
  response = JSON.parse(response);
 
 
 
 
 
 
 
 
 
 
71
  data["wplc_update_admin_chat_table"] = response['wplc_update_admin_chat_table'];
72
  if (response['action'] === "wplc_update_chat_list") {
73
  wplc_handle_chat_output(response['wplc_update_admin_chat_table']);
68
  //Update your dashboard gauge
69
  if (response) {
70
  response = JSON.parse(response);
71
+
72
+ if(response.hasOwnProperty("error")){
73
+ /* stopping due to error */
74
+ wplc_run = false;
75
+ if (response['error'] === 1) {
76
+ location.reload();
77
+ }
78
+
79
+ }
80
+
81
  data["wplc_update_admin_chat_table"] = response['wplc_update_admin_chat_table'];
82
  if (response['action'] === "wplc_update_chat_list") {
83
  wplc_handle_chat_output(response['wplc_update_admin_chat_table']);
wp-live-chat-support.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Live Chat Support
4
  Plugin URI: http://www.wp-livechat.com
5
  Description: The easiest to use website live chat plugin. Let your visitors chat with you and increase sales conversion rates with WP Live Chat Support. No third party connection required!
6
- Version: 6.0.05
7
  Author: WP-LiveChat
8
  Author URI: http://www.wp-livechat.com
9
  Text Domain: wplivechat
@@ -11,6 +11,9 @@
11
  */
12
 
13
  /*
 
 
 
14
  * 6.0.05 - 2016-02-23 - Medium priority
15
  * Fixed the bug that caused the menu item to not display for some users
16
  *
@@ -326,7 +329,7 @@ global $wplc_tblname_offline_msgs;
326
  $wplc_tblname_offline_msgs = $wpdb->prefix . "wplc_offline_messages";
327
  $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
328
  $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
329
- $wplc_version = "6.0.05";
330
 
331
  define('WPLC_BASIC_PLUGIN_DIR', dirname(__FILE__));
332
  define('WPLC_BASIC_PLUGIN_URL', plugins_url() . "/wp-live-chat-support/");
@@ -392,8 +395,9 @@ function wplc_version_control() {
392
  if (!isset($current_version) || $current_version != $wplc_version) {
393
 
394
 
395
- //admins = get_role('administrator');
396
- // $admins->add_cap('wplc_ma_agent');
 
397
  $uid = get_current_user_id();
398
  update_user_meta($uid, 'wplc_ma_agent', 1);
399
  update_user_meta($uid, "wplc_chat_agent_online", time());
@@ -539,9 +543,14 @@ function wplc_admin_menu() {
539
 
540
  $wplc_current_user = get_current_user_id();
541
 
542
- if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true ) ){
 
543
  $wplc_mainpage = add_menu_page('WP Live Chat', __('Live Chat', 'wplivechat'), $cap[0], 'wplivechat-menu', 'wplc_admin_menu_layout');
544
  add_submenu_page('wplivechat-menu', __('Settings', 'wplivechat'), __('Settings', 'wplivechat'), $cap[1], 'wplivechat-menu-settings', 'wplc_admin_settings_layout');
 
 
 
 
545
  add_submenu_page('wplivechat-menu', __('History', 'wplivechat'), __('History', 'wplivechat'), $cap[2], 'wplivechat-menu-history', 'wplc_admin_history_layout');
546
  add_submenu_page('wplivechat-menu', __('Missed Chats', 'wplivechat'), __('Missed Chats', 'wplivechat'), $cap[3], 'wplivechat-menu-missed-chats', 'wplc_admin_missed_chats');
547
 
@@ -1597,32 +1606,36 @@ add_action('admin_head', 'wplc_update_chat_statuses');
1597
 
1598
  add_action("wplc_hook_superadmin_head","wplc_hook_control_superadmin_head",10);
1599
  function wplc_hook_control_superadmin_head() {
1600
- $ajax_nonce = wp_create_nonce("wplc");
1601
- ?>
1602
- <script type="text/javascript">
1603
- jQuery(document).ready(function () {
1604
 
 
 
 
 
 
1605
 
1606
- var wplc_set_transient = null;
1607
 
1608
- wplc_set_transient = setInterval(function () {
1609
- wpcl_admin_set_transient();
1610
- }, 60000);
1611
- wpcl_admin_set_transient();
1612
- function wpcl_admin_set_transient() {
1613
- var data = {
1614
- action: 'wplc_admin_set_transient',
1615
- security: '<?php echo $ajax_nonce; ?>'
1616
 
1617
- };
1618
- jQuery.post(ajaxurl, data, function (response) {
1619
-
1620
- });
1621
- }
 
 
 
1622
 
1623
- });
1624
- </script>
 
 
 
 
 
 
1625
  <?php
 
1626
  }
1627
 
1628
  function wplc_superadmin_javascript() {
@@ -1687,30 +1700,35 @@ function wplc_admin_javascript() {
1687
  $ajax_nonce = wp_create_nonce("wplc");
1688
  global $wplc_version;
1689
 
1690
- wp_register_script('wplc-admin-js', plugins_url('js/wplc_u_admin.js', __FILE__), false, $wplc_version, false);
1691
- wp_enqueue_script('wplc-admin-js');
1692
- $not_icon = plugins_url('/images/wplc_notification_icon.png', __FILE__);
1693
 
1694
- $wplc_wav_file = plugins_url('/ring.wav', __FILE__);
1695
- wp_localize_script('wplc-admin-js', 'wplc_wav_file', $wplc_wav_file);
 
1696
 
1697
- wp_localize_script('wplc-admin-js', 'wplc_ajax_nonce', $ajax_nonce);
1698
- wp_localize_script('wplc-admin-js', 'wplc_notification_icon', $not_icon);
1699
 
1700
- $extra_data = apply_filters("wplc_filter_admin_javascript",array());
1701
- wp_localize_script('wplc-admin-js', 'wplc_extra_data', $extra_data);
1702
 
1703
- $ajax_url = admin_url('admin-ajax.php');
1704
- $wplc_ajax_url = apply_filters("wplc_filter_ajax_url",$ajax_url);
1705
- wp_localize_script('wplc-admin-js', 'wplc_ajaxurl', $wplc_ajax_url);
1706
 
1707
- $wpc_ma_js_strings = array(
1708
- 'remove_agent' => __('Remove', 'wplivechat'),
1709
- 'nonce' => wp_create_nonce("wplc"),
1710
- 'user_id' => get_current_user_id()
1711
- );
1712
- wp_localize_script('wplc-admin-js', 'wplc_admin_strings', $wpc_ma_js_strings);
1713
 
 
 
 
 
 
 
 
 
 
1714
 
1715
  }
1716
 
@@ -1932,6 +1950,37 @@ function wplc_admin_menu_layout_display() {
1932
  }
1933
  do_action("wplc_hook_admin_menu_layout_display",$_GET['action'],$_GET['cid'],$aid);
1934
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1935
  }
1936
  }
1937
 
@@ -2596,8 +2645,8 @@ function wplc_head_basic() {
2596
 
2597
  do_action("wplc_hook_head");
2598
 
 
2599
  if (isset($_POST['wplc_save_settings'])) {
2600
-
2601
  do_action("wplc_hook_admin_settings_save");
2602
  if (isset($_POST['wplc_settings_align'])) { $wplc_data['wplc_settings_align'] = esc_attr($_POST['wplc_settings_align']); }
2603
  if (isset($_POST['wplc_settings_fill'])) { $wplc_data['wplc_settings_fill'] = esc_attr($_POST['wplc_settings_fill']); }
@@ -2637,6 +2686,29 @@ function wplc_head_basic() {
2637
  if(isset($_POST['wplc_animation'])){ $wplc_data['wplc_animation'] = esc_attr($_POST['wplc_animation']); }
2638
  if(isset($_POST['wplc_theme'])){ $wplc_data['wplc_theme'] = esc_attr($_POST['wplc_theme']); }
2639
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2640
 
2641
  if(isset($_POST['wplc_ban_users_ip'])){
2642
  $wplc_banned_ip_addresses = explode('<br />', nl2br(sanitize_text_field($_POST['wplc_ban_users_ip'])));
@@ -3007,53 +3079,83 @@ function wplc_filter_control_wplc_admin_long_poll_chat_iteration($array,$post_da
3007
 
3008
  add_action("wplc_hook_agents_settings","wplc_hook_control_agents_settings", 10);
3009
  function wplc_hook_control_agents_settings() {
3010
- echo "<h3>".__('Current Users that are Chat Agents', 'wplivechat')."</h3>";
3011
- $wplc_agents = "<div class='wplc_agent_container'><ul>";
3012
- $user = wp_get_current_user();
3013
- $wplc_agents .= "<li id=\"wplc_agent_li_".$user->ID."\">";
3014
- $wplc_agents .= "<p><img src=\"//www.gravatar.com/avatar/" . md5($user->user_email) . "?s=80&d=mm\" /></p>";
3015
- $check = get_user_meta($user->ID,"wplc_chat_agent_online");
3016
- if ($check) {
3017
- $wplc_agents .= "<span class='wplc_status_box wplc_type_returning'>".__("Online","wplivechat")."</span>";
3018
- }
3019
- $wplc_agents .= "<h3>" . $user->display_name . "</h3>";
3020
-
3021
- $wplc_agents .= "<small>" . $user->user_email . "</small>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3022
 
3023
- $wplc_agents .= "</li>";
3024
- echo $wplc_agents;
3025
- ?>
3026
  <li style='width:150px;' id='wplc_add_new_agent_box'>
3027
  <p><i class='fa fa-plus-circle fa-4x' style='color:#ccc;' ></i></p>
3028
  <h3><?php _e("Add New Agent","wplivechat"); ?></h3>
3029
- <select id='wplc_agent_select'>
3030
- <option value=''><?php _e("Select","wplivechat"); ?></option>
3031
-
3032
- <?php
3033
- $blogusers = get_users( array( 'role' => 'administrator', 'fields' => array( 'display_name','id','user_email' ) ) );
3034
- // Array of stdClass objects.
3035
- foreach ( $blogusers as $user ) {
3036
- $is_agent = get_user_meta(esc_html( $user->ID ), 'wplc_ma_agent', true);
3037
- if(!$is_agent){ echo '<option id="wplc_selected_agent_'. esc_html( $user->ID ) .'" value="' . esc_html( $user->ID ) . '">' . esc_html( $user->display_name ) . ' ('.__('Administrator','wplivechat').')</option>'; }
3038
- }
3039
- $blogusers = get_users( array( 'role' => 'editor', 'fields' => array( 'display_name','id','user_email' ) ) );
3040
- // Array of stdClass objects.
3041
- foreach ( $blogusers as $user ) {
3042
- $is_agent = get_user_meta(esc_html( $user->ID ), 'wplc_ma_agent', true);
3043
- if(!$is_agent){ echo '<option id="wplc_selected_agent_'. esc_html( $user->ID ) .'" value="' . esc_html( $user->ID ) . '">' . esc_html( $user->display_name ) . ' ('.__('Editor','wplivechat').')</option>'; }
3044
- }
3045
- $blogusers = get_users( array( 'role' => 'author', 'fields' => array( 'display_name','id','user_email' ) ) );
3046
- // Array of stdClass objects.
3047
- foreach ( $blogusers as $user ) {
3048
- $is_agent = get_user_meta(esc_html( $user->ID ), 'wplc_ma_agent', true);
3049
- if(!$is_agent){ echo '<option id="wplc_selected_agent_'. esc_html( $user->ID ) .'" value="' . esc_html( $user->ID ) . '">' . esc_html( $user->display_name ) . ' ('.__('Author','wplivechat').')</option>'; }
3050
- }
3051
- ?>
3052
- </select>
3053
  <p><button class='button button-secondary' id='wplc_add_agent' disabled style=><?php _e("Add Agent","wplivechat"); ?></button></p>
3054
  <p style='font-size:0.8em'><?php _e("Add as many agents as you need with the ","wplivechat") ?> <a href="https://wp-livechat.com/extensions/multiple-agents-extension/?utm_source=plugin&utm_medium=link&utm_campaign=multipleAgents" target="_BLANK"><?php _e("Multiple Agents Extension.", "wplivechat") ?></a></p>
3055
  </li>
3056
  </ul>
 
 
 
 
 
 
 
 
3057
  </div>
3058
 
3059
  <hr/>
3
  Plugin Name: WP Live Chat Support
4
  Plugin URI: http://www.wp-livechat.com
5
  Description: The easiest to use website live chat plugin. Let your visitors chat with you and increase sales conversion rates with WP Live Chat Support. No third party connection required!
6
+ Version: 6.0.06
7
  Author: WP-LiveChat
8
  Author URI: http://www.wp-livechat.com
9
  Text Domain: wplivechat
11
  */
12
 
13
  /*
14
+ * 6.0.06 - 2016-03-04 - Medium priority
15
+ * More stable fix for the menu item bug that has been experienced lately
16
+ *
17
  * 6.0.05 - 2016-02-23 - Medium priority
18
  * Fixed the bug that caused the menu item to not display for some users
19
  *
329
  $wplc_tblname_offline_msgs = $wpdb->prefix . "wplc_offline_messages";
330
  $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
331
  $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
332
+ $wplc_version = "6.0.06";
333
 
334
  define('WPLC_BASIC_PLUGIN_DIR', dirname(__FILE__));
335
  define('WPLC_BASIC_PLUGIN_URL', plugins_url() . "/wp-live-chat-support/");
395
  if (!isset($current_version) || $current_version != $wplc_version) {
396
 
397
 
398
+ $admins = get_role('administrator');
399
+ $admins->add_cap('wplc_ma_agent');
400
+
401
  $uid = get_current_user_id();
402
  update_user_meta($uid, 'wplc_ma_agent', 1);
403
  update_user_meta($uid, "wplc_chat_agent_online", time());
543
 
544
  $wplc_current_user = get_current_user_id();
545
 
546
+ /* If user is either an agent or an admin, access the page. */
547
+ if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true ) || current_user_can("wplc_ma_agent")){
548
  $wplc_mainpage = add_menu_page('WP Live Chat', __('Live Chat', 'wplivechat'), $cap[0], 'wplivechat-menu', 'wplc_admin_menu_layout');
549
  add_submenu_page('wplivechat-menu', __('Settings', 'wplivechat'), __('Settings', 'wplivechat'), $cap[1], 'wplivechat-menu-settings', 'wplc_admin_settings_layout');
550
+ }
551
+ /* only if suer is both an agent and an admin that has the cap assigned, can they access these pages */
552
+ if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true ) && current_user_can("wplc_ma_agent")){
553
+
554
  add_submenu_page('wplivechat-menu', __('History', 'wplivechat'), __('History', 'wplivechat'), $cap[2], 'wplivechat-menu-history', 'wplc_admin_history_layout');
555
  add_submenu_page('wplivechat-menu', __('Missed Chats', 'wplivechat'), __('Missed Chats', 'wplivechat'), $cap[3], 'wplivechat-menu-missed-chats', 'wplc_admin_missed_chats');
556
 
1606
 
1607
  add_action("wplc_hook_superadmin_head","wplc_hook_control_superadmin_head",10);
1608
  function wplc_hook_control_superadmin_head() {
1609
+ $wplc_current_user = get_current_user_id();
 
 
 
1610
 
1611
+ if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true )) {
1612
+ $ajax_nonce = wp_create_nonce("wplc");
1613
+ ?>
1614
+ <script type="text/javascript">
1615
+ jQuery(document).ready(function () {
1616
 
 
1617
 
1618
+ var wplc_set_transient = null;
 
 
 
 
 
 
 
1619
 
1620
+ wplc_set_transient = setInterval(function () {
1621
+ wpcl_admin_set_transient();
1622
+ }, 60000);
1623
+ wpcl_admin_set_transient();
1624
+ function wpcl_admin_set_transient() {
1625
+ var data = {
1626
+ action: 'wplc_admin_set_transient',
1627
+ security: '<?php echo $ajax_nonce; ?>'
1628
 
1629
+ };
1630
+ jQuery.post(ajaxurl, data, function (response) {
1631
+
1632
+ });
1633
+ }
1634
+
1635
+ });
1636
+ </script>
1637
  <?php
1638
+ }
1639
  }
1640
 
1641
  function wplc_superadmin_javascript() {
1700
  $ajax_nonce = wp_create_nonce("wplc");
1701
  global $wplc_version;
1702
 
1703
+ $wplc_current_user = get_current_user_id();
1704
+ if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true )) {
 
1705
 
1706
+ wp_register_script('wplc-admin-js', plugins_url('js/wplc_u_admin.js', __FILE__), false, $wplc_version, false);
1707
+ wp_enqueue_script('wplc-admin-js');
1708
+ $not_icon = plugins_url('/images/wplc_notification_icon.png', __FILE__);
1709
 
1710
+ $wplc_wav_file = plugins_url('/ring.wav', __FILE__);
1711
+ wp_localize_script('wplc-admin-js', 'wplc_wav_file', $wplc_wav_file);
1712
 
1713
+ wp_localize_script('wplc-admin-js', 'wplc_ajax_nonce', $ajax_nonce);
1714
+ wp_localize_script('wplc-admin-js', 'wplc_notification_icon', $not_icon);
1715
 
1716
+ $extra_data = apply_filters("wplc_filter_admin_javascript",array());
1717
+ wp_localize_script('wplc-admin-js', 'wplc_extra_data', $extra_data);
 
1718
 
1719
+ $ajax_url = admin_url('admin-ajax.php');
1720
+ $wplc_ajax_url = apply_filters("wplc_filter_ajax_url",$ajax_url);
1721
+ wp_localize_script('wplc-admin-js', 'wplc_ajaxurl', $wplc_ajax_url);
 
 
 
1722
 
1723
+ $wpc_ma_js_strings = array(
1724
+ 'remove_agent' => __('Remove', 'wplivechat'),
1725
+ 'nonce' => wp_create_nonce("wplc"),
1726
+ 'user_id' => get_current_user_id()
1727
+ );
1728
+ wp_localize_script('wplc-admin-js', 'wplc_admin_strings', $wpc_ma_js_strings);
1729
+
1730
+ }
1731
+
1732
 
1733
  }
1734
 
1950
  }
1951
  do_action("wplc_hook_admin_menu_layout_display",$_GET['action'],$_GET['cid'],$aid);
1952
  }
1953
+ } else {
1954
+ ?>
1955
+
1956
+ <h1><?php _e("Chat Dashboard","wplivechat"); ?></h1>
1957
+ <div id="welcome-panel" class="welcome-panel">
1958
+ <div class="welcome-panel-content">
1959
+ <h2><?php _e("Oh no!","wplivechat"); ?></h2>
1960
+ <p class="about-description">
1961
+ <?php _e(
1962
+ "You do not have access to this page as <strong>you are not a chat agent</strong>.",
1963
+ "wplivechat"
1964
+ ); ?>
1965
+ </p>
1966
+ <p>Users with access to this page are as follows:</p>
1967
+ <p>
1968
+ <?php
1969
+ $user_array = get_users(array(
1970
+ 'meta_key' => 'wplc_ma_agent',
1971
+ ));
1972
+ echo "<ol>";
1973
+ if ($user_array) {
1974
+ foreach ($user_array as $user) {
1975
+ echo "<li> ".$user->display_name . " (ID: ".$user->ID.")</li>";
1976
+ }
1977
+ }
1978
+ echo "</ol>";
1979
+ ?>
1980
+ </p>
1981
+ </div>
1982
+ </div>
1983
+ <?php
1984
  }
1985
  }
1986
 
2645
 
2646
  do_action("wplc_hook_head");
2647
 
2648
+
2649
  if (isset($_POST['wplc_save_settings'])) {
 
2650
  do_action("wplc_hook_admin_settings_save");
2651
  if (isset($_POST['wplc_settings_align'])) { $wplc_data['wplc_settings_align'] = esc_attr($_POST['wplc_settings_align']); }
2652
  if (isset($_POST['wplc_settings_fill'])) { $wplc_data['wplc_settings_fill'] = esc_attr($_POST['wplc_settings_fill']); }
2686
  if(isset($_POST['wplc_animation'])){ $wplc_data['wplc_animation'] = esc_attr($_POST['wplc_animation']); }
2687
  if(isset($_POST['wplc_theme'])){ $wplc_data['wplc_theme'] = esc_attr($_POST['wplc_theme']); }
2688
 
2689
+ if(isset($_POST['wplc_agent_select'])) {
2690
+ $user_array = get_users(array(
2691
+ 'meta_key' => 'wplc_ma_agent',
2692
+ ));
2693
+ if ($user_array) {
2694
+ foreach ($user_array as $user) {
2695
+ $uid = $user->ID;
2696
+ $wplc_ma_user = new WP_User( $uid );
2697
+ $wplc_ma_user->remove_cap( 'wplc_ma_agent' );
2698
+ delete_user_meta($uid, "wplc_ma_agent");
2699
+ delete_user_meta($uid, "wplc_chat_agent_online");
2700
+ }
2701
+ }
2702
+
2703
+
2704
+ $uid = intval($_POST['wplc_agent_select']);
2705
+ $wplc_ma_user = new WP_User( $uid );
2706
+ $wplc_ma_user->add_cap( 'wplc_ma_agent' );
2707
+ update_user_meta($uid, "wplc_ma_agent", 1);
2708
+ update_user_meta($uid, "wplc_chat_agent_online", time());
2709
+
2710
+ }
2711
+
2712
 
2713
  if(isset($_POST['wplc_ban_users_ip'])){
2714
  $wplc_banned_ip_addresses = explode('<br />', nl2br(sanitize_text_field($_POST['wplc_ban_users_ip'])));
3079
 
3080
  add_action("wplc_hook_agents_settings","wplc_hook_control_agents_settings", 10);
3081
  function wplc_hook_control_agents_settings() {
3082
+ $user_array = get_users(array(
3083
+ 'meta_key' => 'wplc_ma_agent',
3084
+ ));
3085
+
3086
+ echo "<h3>".__('Current Users that are Chat Agents', 'wplivechat')."</h3>";
3087
+ $wplc_agents = "<div class='wplc_agent_container'><ul>";
3088
+
3089
+ if ($user_array) {
3090
+ foreach ($user_array as $user) {
3091
+
3092
+ $wplc_agents .= "<li id=\"wplc_agent_li_".$user->ID."\">";
3093
+ $wplc_agents .= "<p><img src=\"//www.gravatar.com/avatar/" . md5($user->user_email) . "?s=80&d=mm\" /></p>";
3094
+ $check = get_user_meta($user->ID,"wplc_chat_agent_online");
3095
+ if ($check) {
3096
+ $wplc_agents .= "<span class='wplc_status_box wplc_type_returning'>".__("Online","wplivechat")."</span>";
3097
+ }
3098
+ $default_agent_id = $user->ID;
3099
+ $default_agent_user = $user->display_name;
3100
+ $wplc_agents .= "<h3>" . $user->display_name . "</h3>";
3101
+
3102
+ $wplc_agents .= "<small>" . $user->user_email . "</small>";
3103
+
3104
+
3105
+
3106
+
3107
+ $wplc_agents .= "</li>";
3108
+ }
3109
+ }
3110
+ echo $wplc_agents;
3111
+ $temp_line = "<select name='wplc_agent_select' id='wplc_agent_select'><option value=''>".__("Select","wplivechat")."</option>";
3112
+
3113
+ $blogusers = get_users( array( 'role' => 'administrator', 'fields' => array( 'display_name','id','user_email' ) ) );
3114
+ if ($blogusers) {
3115
+ foreach ( $blogusers as $user ) {
3116
+ $is_agent = get_user_meta(esc_html( $user->id ), 'wplc_ma_agent', true);
3117
+ $temp_line2 = '<option id="wplc_selected_agent_'. esc_html( $user->id ) .'" value="' . esc_html( $user->id ) . '">' . esc_html( $user->display_name ) . ' ('.__('Administrator','wplivechat').')</option>';
3118
+ if(!$is_agent){ $temp_line .= $temp_line2; }
3119
+ }
3120
+ }
3121
+
3122
+ $blogusers = get_users( array( 'role' => 'editor', 'fields' => array( 'display_name','id','user_email' ) ) );
3123
+ if ($blogusers) {
3124
+ foreach ( $blogusers as $user ) {
3125
+ $is_agent = get_user_meta(esc_html( $user->id ), 'wplc_ma_agent', true);
3126
+ $temp_line2 = '<option id="wplc_selected_agent_'. esc_html( $user->id ) .'" value="' . esc_html( $user->id ) . '">' . esc_html( $user->display_name ) . ' ('.__('Editor','wplivechat').')</option>';
3127
+ if(!$is_agent){ $temp_line .= $temp_line2; }
3128
+ }
3129
+ }
3130
+
3131
+ $blogusers = get_users( array( 'role' => 'author', 'fields' => array( 'display_name','id','user_email' ) ) );
3132
+ if ($blogusers) {
3133
+ foreach ( $blogusers as $user ) {
3134
+ $is_agent = get_user_meta(esc_html( $user->id ), 'wplc_ma_agent', true);
3135
+ $temp_line2 = '<option id="wplc_selected_agent_'. esc_html( $user->id ) .'" value="' . esc_html( $user->id ) . '">' . esc_html( $user->display_name ) . ' ('.__('Author','wplivechat').')</option>';
3136
+ if(!$is_agent){ $temp_line .= $temp_line2; }
3137
+ }
3138
+ }
3139
+
3140
+ $temp_line .= "</select> ";
3141
+ ?>
3142
+
3143
 
 
 
 
3144
  <li style='width:150px;' id='wplc_add_new_agent_box'>
3145
  <p><i class='fa fa-plus-circle fa-4x' style='color:#ccc;' ></i></p>
3146
  <h3><?php _e("Add New Agent","wplivechat"); ?></h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3147
  <p><button class='button button-secondary' id='wplc_add_agent' disabled style=><?php _e("Add Agent","wplivechat"); ?></button></p>
3148
  <p style='font-size:0.8em'><?php _e("Add as many agents as you need with the ","wplivechat") ?> <a href="https://wp-livechat.com/extensions/multiple-agents-extension/?utm_source=plugin&utm_medium=link&utm_campaign=multipleAgents" target="_BLANK"><?php _e("Multiple Agents Extension.", "wplivechat") ?></a></p>
3149
  </li>
3150
  </ul>
3151
+ <?php
3152
+ $agent_text = sprintf( __( 'Change the default chat agent from <strong>%1$s</strong> to ', 'wplivechat' ),
3153
+ $default_agent_user
3154
+
3155
+ );
3156
+ echo $agent_text.$temp_line;
3157
+ ?>
3158
+
3159
  </div>
3160
 
3161
  <hr/>