Version Description
= 8.1.x = Huge update with over 300 changes that include: Bugfixes, Vulnerability Fixes & Plugin Security, Plugin Optimization & Rebranding Updates. We suggest you remove any existing installations of this plugin and install 8.1.x fresh.
Download this release
Release Info
Developer | wpdev3cx |
Plugin | WP Live Chat Support |
Version | 8.1.8 |
Comparing to | |
See all releases |
Code changes from version 8.1.7 to 8.1.8
- changelog.txt +5 -0
- config.php +2 -2
- functions.php +34 -34
- includes/blocks/wplc-chat-box/index.php +16 -16
- includes/blocks/wplc-inline-chat-box/index.php +13 -12
- includes/modal_control.php +1 -1
- includes/wplc_data_triggers.php +2 -2
- includes/wplc_roi.php +1 -1
- js/offline_messages.js +25 -0
- js/wplc_u_admin.js +0 -24
- modules/cta_animations.php +1 -1
- modules/node_server.php +2 -2
- readme.txt +8 -3
- wp-live-chat-support.php +3769 -3362
changelog.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 8.1.7 - 2020-02-05 =
|
2 |
* Bugfix: added some missing translation strings
|
3 |
* Bugfix: HTML email body in auto responder not parsed correctly
|
1 |
+
= 8.1.8 - 2020-05-28 =
|
2 |
+
* Bugfix: Offline messages delete not worked
|
3 |
+
* Bugfix: Load bootstrap js sourcemap failed
|
4 |
+
* Bugfix: Urls Fixed for linux compatibility
|
5 |
+
|
6 |
= 8.1.7 - 2020-02-05 =
|
7 |
* Bugfix: added some missing translation strings
|
8 |
* Bugfix: HTML email body in auto responder not parsed correctly
|
config.php
CHANGED
@@ -7,9 +7,9 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
7 |
exit;
|
8 |
}
|
9 |
|
10 |
-
define('WPLC_PLUGIN_VERSION', "8.1.
|
11 |
define('WPLC_PLUGIN_DIR', dirname(__FILE__));
|
12 |
-
define('WPLC_PLUGIN_URL',
|
13 |
define('WPLC_PLUGIN', plugin_basename( __FILE__ ) );
|
14 |
define('WPLC_ACTIVATION_SERVER', 'https://activation.wp-livechat.com' ); // gets unique ID for using chat servers
|
15 |
define('WPLC_CHAT_SERVER', 'https://tcx-live-chat.appspot.com');
|
7 |
exit;
|
8 |
}
|
9 |
|
10 |
+
define('WPLC_PLUGIN_VERSION', "8.1.8");
|
11 |
define('WPLC_PLUGIN_DIR', dirname(__FILE__));
|
12 |
+
define('WPLC_PLUGIN_URL', wplc_plugins_url('/', __FILE__ ) );
|
13 |
define('WPLC_PLUGIN', plugin_basename( __FILE__ ) );
|
14 |
define('WPLC_ACTIVATION_SERVER', 'https://activation.wp-livechat.com' ); // gets unique ID for using chat servers
|
15 |
define('WPLC_CHAT_SERVER', 'https://tcx-live-chat.appspot.com');
|
functions.php
CHANGED
@@ -2156,7 +2156,7 @@ if (!function_exists("wplc_acbc_admin_scripts")) {
|
|
2156 |
if (isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu-settings') {
|
2157 |
|
2158 |
wp_enqueue_media();
|
2159 |
-
wp_register_script('my-wplc-upload',
|
2160 |
wp_enqueue_script('my-wplc-upload');
|
2161 |
}
|
2162 |
}
|
@@ -2171,31 +2171,31 @@ function wplc_acbc_hook_control_push_js_to_front() {
|
|
2171 |
'wplc_delay' => intval($wplc_settings['wplc_chat_delay'])*1000
|
2172 |
);
|
2173 |
if ($wplc_settings['wplc_typing_enabled']) {
|
2174 |
-
$wpc_misc_js_strings['typingimg'] =
|
2175 |
}
|
2176 |
wp_localize_script('wplc-user-script', 'wplc_misc_strings', $wpc_misc_js_strings);
|
2177 |
|
2178 |
if ($wplc_settings['wplc_use_node_server']) {
|
2179 |
-
wp_register_script('wplc-user-pro-events-script',
|
2180 |
-
wp_register_script('tcx-action-script',
|
2181 |
wp_enqueue_script('tcx-action-script');
|
2182 |
} else {
|
2183 |
/* not using the node server, load traditional event handler JS */
|
2184 |
-
wp_register_script('wplc-user-pro-events-script',
|
2185 |
}
|
2186 |
|
2187 |
-
wp_register_script('wplc-user-pro-features',
|
2188 |
wp_enqueue_script( 'wplc-user-pro-features' );
|
2189 |
wp_enqueue_script( 'wplc-user-pro-events-script' );
|
2190 |
|
2191 |
-
wp_register_script('wplc-user-pro-editor',
|
2192 |
wp_enqueue_script('wplc-user-pro-editor');
|
2193 |
|
2194 |
if (!empty($wplc_settings["wplc_pro_auto_first_response_chat_msg"])) {
|
2195 |
wp_localize_script('wplc-user-pro-features', 'wplc_pro_auto_resp_chat_msg', strval(apply_filters('wplc_pro_auto_first_response_chat_msg_filter', strval($wplc_settings["wplc_pro_auto_first_response_chat_msg"]))));
|
2196 |
}
|
2197 |
|
2198 |
-
wp_enqueue_style('wplc-user-pro-styles',
|
2199 |
|
2200 |
$post_id = get_the_ID();
|
2201 |
if (!$post_id || $post_id === NULL) {
|
@@ -2427,11 +2427,11 @@ function wplc_typing_mrg($user,$cid,$type) {
|
|
2427 |
*/
|
2428 |
add_action('admin_print_scripts', 'wplc_choose_admin_scripts');
|
2429 |
function wplc_choose_admin_scripts() {
|
2430 |
-
wp_register_script('wplc_switchery',
|
2431 |
wp_enqueue_script('wplc_switchery');
|
2432 |
-
wp_register_style('wplc_switchery_css',
|
2433 |
wp_enqueue_style('wplc_switchery_css');
|
2434 |
-
wp_register_script('wplc-choose-script',
|
2435 |
wp_enqueue_script('wplc-choose-script');
|
2436 |
|
2437 |
$wpc_admin_js_strings = array(
|
@@ -2459,11 +2459,11 @@ function wplc_choose_admin_scripts() {
|
|
2459 |
wp_localize_script('wplc-choose-script', 'wplc_localized_quote_string', $quote_string);
|
2460 |
}
|
2461 |
|
2462 |
-
wp_register_script('wplc-qr-script',
|
2463 |
wp_enqueue_script('wplc-qr-script');
|
2464 |
-
wp_register_script('wplc-triggers',
|
2465 |
wp_enqueue_script('wplc-triggers');
|
2466 |
-
wp_register_script('wplc-admin-editor',
|
2467 |
wp_enqueue_script('wplc-admin-editor');
|
2468 |
}
|
2469 |
|
@@ -2679,7 +2679,7 @@ function wplc_ic_admin_javascript() {
|
|
2679 |
if ($wplc_settings['wplc_typing_enabled']) {
|
2680 |
$wpc_misc_js_strings = array(
|
2681 |
'typing_enabled' => true,
|
2682 |
-
'typingimg' =>
|
2683 |
);
|
2684 |
} else {
|
2685 |
$wpc_misc_js_strings = array(
|
@@ -3277,7 +3277,7 @@ if (!function_exists("wplc_maa_hook_control_head")) {
|
|
3277 |
function wplc_maa_hook_control_head() {
|
3278 |
if (isset($_GET['page']) && $_GET['page'] == "wplivechat-menu" && (!isset($_GET['action']))) {
|
3279 |
global $wplc_multiple_agents_version;
|
3280 |
-
@wp_register_script("wplc-ma-transient-js",
|
3281 |
@wp_enqueue_script('wplc-ma-transient-js');
|
3282 |
}
|
3283 |
}
|
@@ -3303,7 +3303,7 @@ if (!function_exists("wplc_maa_agent_logout")) {
|
|
3303 |
if (!function_exists("wplc_control_admin_javascript")) {
|
3304 |
function wplc_control_admin_javascript() {
|
3305 |
global $wplc_multiple_agents_version;
|
3306 |
-
wp_register_script("wplc-ma-js",
|
3307 |
wp_enqueue_script('wplc-ma-js');
|
3308 |
|
3309 |
$ajax_url = admin_url('admin-ajax.php');
|
@@ -3692,12 +3692,12 @@ add_action('admin_enqueue_scripts', 'wplc_reporting_scripts_mrg');
|
|
3692 |
function wplc_reporting_scripts_mrg(){
|
3693 |
if( isset( $_GET['page'] ) && $_GET['page'] == 'wplivechat-menu-reporting' ){
|
3694 |
$statistics = json_encode( return_statistics_mrg() );
|
3695 |
-
wp_register_script('wplc-google-charts',
|
3696 |
wp_enqueue_script('wplc-google-charts');
|
3697 |
|
3698 |
-
wp_register_style('wplc-ui-style-stats',
|
3699 |
wp_enqueue_style('wplc-ui-style-stats');
|
3700 |
-
wp_register_script('wplc-statistics',
|
3701 |
if (empty($statistics)) { $statistics = ''; }
|
3702 |
wp_localize_script('wplc-statistics', 'wplc_reporting_statistics', $statistics);
|
3703 |
wp_enqueue_script('wplc-statistics');
|
@@ -3880,7 +3880,7 @@ function wplc_random_quote_mrg() {
|
|
3880 |
}
|
3881 |
|
3882 |
function wplc_enqueue_admin_styles_mrg(){
|
3883 |
-
wp_enqueue_style('wplc-admin-pro-styles',
|
3884 |
}
|
3885 |
|
3886 |
add_filter("wplc_filter_admin_from","wplc_filter_control_admin_from_mrg",10,3);
|
@@ -4089,7 +4089,7 @@ function wplc_active_business_hours_chat_box_notice() {
|
|
4089 |
add_filter( "wplc_get_images_to_preload", "wplc_mrg_get_images_to_preload", 10, 2);
|
4090 |
function wplc_mrg_get_images_to_preload( $images, $wplc_settings ) {
|
4091 |
if ( isset($wplc_settings) && $wplc_settings['wplc_chat_pic'] ) {
|
4092 |
-
array_push( $images, urldecode($wplc_settings['wplc_chat_pic']) );
|
4093 |
}
|
4094 |
return $images;
|
4095 |
}
|
@@ -4144,16 +4144,16 @@ if ( isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu' ) {
|
|
4144 |
function wplc_voice_notes_admin_javascript() {
|
4145 |
$wplc_settings = wplc_get_options();
|
4146 |
if (false) { // TODO: check and reactivate $wplc_settings['wplc_enable_voice_notes_on_admin']) {
|
4147 |
-
wp_register_script( 'wplc-user-voice-notes-audio-recorder-wav',
|
4148 |
-
wp_register_script( 'wplc-user-voice-notes-audio-recorder',
|
4149 |
-
wp_register_script( 'wplc-user-voice-notes-audio-wave-surfer',
|
4150 |
-
wp_register_script( 'wplc-user-voice-notes',
|
4151 |
'wplc-user-voice-notes-audio-recorder-wav',
|
4152 |
'wplc-user-voice-notes-audio-recorder',
|
4153 |
'wplc-user-voice-notes-audio-wave-surfer'
|
4154 |
), WPLC_PLUGIN_VERSION, true);
|
4155 |
wp_localize_script( 'wplc-user-voice-notes', 'wplc_visitor_voice', array(
|
4156 |
-
'plugin_url' => __(
|
4157 |
'str_delete' => __( 'Delete', 'wp-live-chat-support'),
|
4158 |
'str_save' => __( 'Send...', 'wp-live-chat-support'),
|
4159 |
'play_sound' => __( 'Play voice note', 'wp-live-chat-support'),
|
@@ -4161,7 +4161,7 @@ if ( isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu' ) {
|
|
4161 |
) );
|
4162 |
wp_enqueue_script( 'wplc-user-voice-notes' );
|
4163 |
|
4164 |
-
wp_enqueue_style('wplc-admin-voice-note-styles',
|
4165 |
}
|
4166 |
}
|
4167 |
}
|
@@ -4189,16 +4189,16 @@ if ( ! function_exists( 'wplc_voice_notes_front_scripts' ) ) {
|
|
4189 |
function wplc_voice_notes_front_scripts() {
|
4190 |
$wplc_settings = wplc_get_options();
|
4191 |
if (false) { // TODO: check and re-enable $wplc_settings['wplc_enable_voice_notes_on_visitor']) {
|
4192 |
-
wp_register_script( 'wplc-visitor-voice-notes-audio-recorder-wav',
|
4193 |
-
wp_register_script( 'wplc-visitor-voice-notes-audio-recorder',
|
4194 |
-
wp_register_script( 'wplc-user-voice-notes-audio-wave-surfer',
|
4195 |
-
wp_register_script( 'wplc-visitor-voice-notes',
|
4196 |
'wplc-visitor-voice-notes-audio-recorder-wav',
|
4197 |
'wplc-visitor-voice-notes-audio-recorder',
|
4198 |
'wplc-user-voice-notes-audio-wave-surfer'
|
4199 |
), WPLC_PLUGIN_VERSION, true);
|
4200 |
wp_localize_script( 'wplc-visitor-voice-notes', 'wplc_visitor_voice', array(
|
4201 |
-
'plugin_url' => __(
|
4202 |
'str_delete' => __( 'Delete', 'wp-live-chat-support'),
|
4203 |
'str_save' => __( 'Save...', 'wp-live-chat-support'),
|
4204 |
'play_sound' => __( 'Play voice note', 'wp-live-chat-support'),
|
@@ -4206,7 +4206,7 @@ if ( ! function_exists( 'wplc_voice_notes_front_scripts' ) ) {
|
|
4206 |
) );
|
4207 |
wp_enqueue_script( 'wplc-visitor-voice-notes' );
|
4208 |
|
4209 |
-
wp_enqueue_style('wplc-visitor-voice-note-styles',
|
4210 |
|
4211 |
}
|
4212 |
}
|
2156 |
if (isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu-settings') {
|
2157 |
|
2158 |
wp_enqueue_media();
|
2159 |
+
wp_register_script('my-wplc-upload', wplc_plugins_url('/js/media.js', __FILE__), array('jquery'), $wplc_acbc_version, true);
|
2160 |
wp_enqueue_script('my-wplc-upload');
|
2161 |
}
|
2162 |
}
|
2171 |
'wplc_delay' => intval($wplc_settings['wplc_chat_delay'])*1000
|
2172 |
);
|
2173 |
if ($wplc_settings['wplc_typing_enabled']) {
|
2174 |
+
$wpc_misc_js_strings['typingimg'] = wplc_plugins_url('/images/comment.svg', __FILE__);
|
2175 |
}
|
2176 |
wp_localize_script('wplc-user-script', 'wplc_misc_strings', $wpc_misc_js_strings);
|
2177 |
|
2178 |
if ($wplc_settings['wplc_use_node_server']) {
|
2179 |
+
wp_register_script('wplc-user-pro-events-script', wplc_plugins_url('/js/wplc_u_node_pro_events.js', __FILE__), array('jquery', 'wplc-server-script'), WPLC_PLUGIN_VERSION, true);
|
2180 |
+
wp_register_script('tcx-action-script', wplc_plugins_url('/js/tcx_action_events.js', __FILE__), false, WPLC_PLUGIN_VERSION, true);
|
2181 |
wp_enqueue_script('tcx-action-script');
|
2182 |
} else {
|
2183 |
/* not using the node server, load traditional event handler JS */
|
2184 |
+
wp_register_script('wplc-user-pro-events-script', wplc_plugins_url('/js/wplc_u_pro_events.js', __FILE__), array('jquery', 'wplc-server-script'), WPLC_PLUGIN_VERSION, true);
|
2185 |
}
|
2186 |
|
2187 |
+
wp_register_script('wplc-user-pro-features', wplc_plugins_url('/js/wplc_pro_features.js', __FILE__), array('wplc-user-script'), WPLC_PLUGIN_VERSION, true);
|
2188 |
wp_enqueue_script( 'wplc-user-pro-features' );
|
2189 |
wp_enqueue_script( 'wplc-user-pro-events-script' );
|
2190 |
|
2191 |
+
wp_register_script('wplc-user-pro-editor', wplc_plugins_url('/js/wplc_u_editor.js', __FILE__), array('wplc-user-script', 'jquery'), WPLC_PLUGIN_VERSION, true);
|
2192 |
wp_enqueue_script('wplc-user-pro-editor');
|
2193 |
|
2194 |
if (!empty($wplc_settings["wplc_pro_auto_first_response_chat_msg"])) {
|
2195 |
wp_localize_script('wplc-user-pro-features', 'wplc_pro_auto_resp_chat_msg', strval(apply_filters('wplc_pro_auto_first_response_chat_msg_filter', strval($wplc_settings["wplc_pro_auto_first_response_chat_msg"]))));
|
2196 |
}
|
2197 |
|
2198 |
+
wp_enqueue_style('wplc-user-pro-styles', wplc_plugins_url('/css/wplc_styles_pro.css', __FILE__));
|
2199 |
|
2200 |
$post_id = get_the_ID();
|
2201 |
if (!$post_id || $post_id === NULL) {
|
2427 |
*/
|
2428 |
add_action('admin_print_scripts', 'wplc_choose_admin_scripts');
|
2429 |
function wplc_choose_admin_scripts() {
|
2430 |
+
wp_register_script('wplc_switchery', wplc_plugins_url('/js/switchery.min.js', __FILE__), array('jquery'),WPLC_PLUGIN_VERSION, true);
|
2431 |
wp_enqueue_script('wplc_switchery');
|
2432 |
+
wp_register_style('wplc_switchery_css', wplc_plugins_url('/css/switchery.min.css', __FILE__), array(), WPLC_PLUGIN_VERSION);
|
2433 |
wp_enqueue_style('wplc_switchery_css');
|
2434 |
+
wp_register_script('wplc-choose-script', wplc_plugins_url('/js/wplc_choose.js', __FILE__),array('jquery'),WPLC_PLUGIN_VERSION, true);
|
2435 |
wp_enqueue_script('wplc-choose-script');
|
2436 |
|
2437 |
$wpc_admin_js_strings = array(
|
2459 |
wp_localize_script('wplc-choose-script', 'wplc_localized_quote_string', $quote_string);
|
2460 |
}
|
2461 |
|
2462 |
+
wp_register_script('wplc-qr-script', wplc_plugins_url('/js/quick_responses.js', __FILE__),array('jquery'),WPLC_PLUGIN_VERSION, true);
|
2463 |
wp_enqueue_script('wplc-qr-script');
|
2464 |
+
wp_register_script('wplc-triggers', wplc_plugins_url('/js/triggers.js', __FILE__),array('jquery'),WPLC_PLUGIN_VERSION, true);
|
2465 |
wp_enqueue_script('wplc-triggers');
|
2466 |
+
wp_register_script('wplc-admin-editor', wplc_plugins_url('/js/wplc_admin_editor.js', __FILE__),array('jquery'),WPLC_PLUGIN_VERSION, true);
|
2467 |
wp_enqueue_script('wplc-admin-editor');
|
2468 |
}
|
2469 |
|
2679 |
if ($wplc_settings['wplc_typing_enabled']) {
|
2680 |
$wpc_misc_js_strings = array(
|
2681 |
'typing_enabled' => true,
|
2682 |
+
'typingimg' => wplc_plugins_url('/images/comment.svg', __FILE__)
|
2683 |
);
|
2684 |
} else {
|
2685 |
$wpc_misc_js_strings = array(
|
3277 |
function wplc_maa_hook_control_head() {
|
3278 |
if (isset($_GET['page']) && $_GET['page'] == "wplivechat-menu" && (!isset($_GET['action']))) {
|
3279 |
global $wplc_multiple_agents_version;
|
3280 |
+
@wp_register_script("wplc-ma-transient-js", wplc_plugins_url('/js/wplc_ma_transient.js', __FILE__), array(), $wplc_multiple_agents_version, true);
|
3281 |
@wp_enqueue_script('wplc-ma-transient-js');
|
3282 |
}
|
3283 |
}
|
3303 |
if (!function_exists("wplc_control_admin_javascript")) {
|
3304 |
function wplc_control_admin_javascript() {
|
3305 |
global $wplc_multiple_agents_version;
|
3306 |
+
wp_register_script("wplc-ma-js", wplc_plugins_url('/js/wplc_ma.js', __FILE__), array(), $wplc_multiple_agents_version, true);
|
3307 |
wp_enqueue_script('wplc-ma-js');
|
3308 |
|
3309 |
$ajax_url = admin_url('admin-ajax.php');
|
3692 |
function wplc_reporting_scripts_mrg(){
|
3693 |
if( isset( $_GET['page'] ) && $_GET['page'] == 'wplivechat-menu-reporting' ){
|
3694 |
$statistics = json_encode( return_statistics_mrg() );
|
3695 |
+
wp_register_script('wplc-google-charts', wplc_plugins_url('/js/vendor/charts/loader.js', __FILE__), array('jquery'), WPLC_PLUGIN_VERSION, true);
|
3696 |
wp_enqueue_script('wplc-google-charts');
|
3697 |
|
3698 |
+
wp_register_style('wplc-ui-style-stats', wplc_plugins_url('/js/vendor/jquery-ui/jquery-ui.css', __FILE__), array(), WPLC_PLUGIN_VERSION);
|
3699 |
wp_enqueue_style('wplc-ui-style-stats');
|
3700 |
+
wp_register_script('wplc-statistics', wplc_plugins_url('/js/reporting.js', __FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-tabs'), WPLC_PLUGIN_VERSION, true);
|
3701 |
if (empty($statistics)) { $statistics = ''; }
|
3702 |
wp_localize_script('wplc-statistics', 'wplc_reporting_statistics', $statistics);
|
3703 |
wp_enqueue_script('wplc-statistics');
|
3880 |
}
|
3881 |
|
3882 |
function wplc_enqueue_admin_styles_mrg(){
|
3883 |
+
wp_enqueue_style('wplc-admin-pro-styles', wplc_plugins_url('/css/wplc_styles_admin_pro.css', __FILE__));
|
3884 |
}
|
3885 |
|
3886 |
add_filter("wplc_filter_admin_from","wplc_filter_control_admin_from_mrg",10,3);
|
4089 |
add_filter( "wplc_get_images_to_preload", "wplc_mrg_get_images_to_preload", 10, 2);
|
4090 |
function wplc_mrg_get_images_to_preload( $images, $wplc_settings ) {
|
4091 |
if ( isset($wplc_settings) && $wplc_settings['wplc_chat_pic'] ) {
|
4092 |
+
array_push( $images, wplc_protocol_agnostic_url(urldecode($wplc_settings['wplc_chat_pic'])) );
|
4093 |
}
|
4094 |
return $images;
|
4095 |
}
|
4144 |
function wplc_voice_notes_admin_javascript() {
|
4145 |
$wplc_settings = wplc_get_options();
|
4146 |
if (false) { // TODO: check and reactivate $wplc_settings['wplc_enable_voice_notes_on_admin']) {
|
4147 |
+
wp_register_script( 'wplc-user-voice-notes-audio-recorder-wav', wplc_plugins_url('/js/WebAudioRecorderWav.min.js', __FILE__ ), array(), WPLC_PLUGIN_VERSION, true);
|
4148 |
+
wp_register_script( 'wplc-user-voice-notes-audio-recorder', wplc_plugins_url('/js/WebAudioRecorder.min.js', __FILE__ ), array(), WPLC_PLUGIN_VERSION, true);
|
4149 |
+
wp_register_script( 'wplc-user-voice-notes-audio-wave-surfer', wplc_plugins_url('/js/wavesurfer.min.js', __FILE__ ), array(), WPLC_PLUGIN_VERSION, true);
|
4150 |
+
wp_register_script( 'wplc-user-voice-notes', wplc_plugins_url('/js/wplc_voice_notes.js', __FILE__ ), array(
|
4151 |
'wplc-user-voice-notes-audio-recorder-wav',
|
4152 |
'wplc-user-voice-notes-audio-recorder',
|
4153 |
'wplc-user-voice-notes-audio-wave-surfer'
|
4154 |
), WPLC_PLUGIN_VERSION, true);
|
4155 |
wp_localize_script( 'wplc-user-voice-notes', 'wplc_visitor_voice', array(
|
4156 |
+
'plugin_url' => __( wplc_plugins_url('/js/', __FILE__ ), 'wp-live-chat-support'),
|
4157 |
'str_delete' => __( 'Delete', 'wp-live-chat-support'),
|
4158 |
'str_save' => __( 'Send...', 'wp-live-chat-support'),
|
4159 |
'play_sound' => __( 'Play voice note', 'wp-live-chat-support'),
|
4161 |
) );
|
4162 |
wp_enqueue_script( 'wplc-user-voice-notes' );
|
4163 |
|
4164 |
+
wp_enqueue_style('wplc-admin-voice-note-styles', wplc_plugins_url('/css/voice_note_admin.css', __FILE__ ));
|
4165 |
}
|
4166 |
}
|
4167 |
}
|
4189 |
function wplc_voice_notes_front_scripts() {
|
4190 |
$wplc_settings = wplc_get_options();
|
4191 |
if (false) { // TODO: check and re-enable $wplc_settings['wplc_enable_voice_notes_on_visitor']) {
|
4192 |
+
wp_register_script( 'wplc-visitor-voice-notes-audio-recorder-wav', wplc_plugins_url('/js/WebAudioRecorderWav.min.js', __FILE__ ), array(), WPLC_PLUGIN_VERSION, true);
|
4193 |
+
wp_register_script( 'wplc-visitor-voice-notes-audio-recorder', wplc_plugins_url('/js/WebAudioRecorder.min.js', __FILE__ ), array(), WPLC_PLUGIN_VERSION, true);
|
4194 |
+
wp_register_script( 'wplc-user-voice-notes-audio-wave-surfer', wplc_plugins_url('/js/wavesurfer.min.js', __FILE__ ), array(), WPLC_PLUGIN_VERSION, true);
|
4195 |
+
wp_register_script( 'wplc-visitor-voice-notes', wplc_plugins_url('/js/wplc_visitor_voice_notes.js', __FILE__ ), array(
|
4196 |
'wplc-visitor-voice-notes-audio-recorder-wav',
|
4197 |
'wplc-visitor-voice-notes-audio-recorder',
|
4198 |
'wplc-user-voice-notes-audio-wave-surfer'
|
4199 |
), WPLC_PLUGIN_VERSION, true);
|
4200 |
wp_localize_script( 'wplc-visitor-voice-notes', 'wplc_visitor_voice', array(
|
4201 |
+
'plugin_url' => __( wplc_plugins_url('/js/', __FILE__ ), 'wp-live-chat-support'),
|
4202 |
'str_delete' => __( 'Delete', 'wp-live-chat-support'),
|
4203 |
'str_save' => __( 'Save...', 'wp-live-chat-support'),
|
4204 |
'play_sound' => __( 'Play voice note', 'wp-live-chat-support'),
|
4206 |
) );
|
4207 |
wp_enqueue_script( 'wplc-visitor-voice-notes' );
|
4208 |
|
4209 |
+
wp_enqueue_style('wplc-visitor-voice-note-styles', wplc_plugins_url('/css/voice_notes_user.css', __FILE__ ));
|
4210 |
|
4211 |
}
|
4212 |
}
|
includes/blocks/wplc-chat-box/index.php
CHANGED
@@ -35,16 +35,16 @@ function wplc_gutenberg_setting_tabs($tab_array) {
|
|
35 |
function wplc_gutenberg_settings_content() {
|
36 |
$gutenberg_settings = get_option('wplc_gutenberg_settings');
|
37 |
|
38 |
-
$gutenberg_enable = ( $gutenberg_settings['wplc_gutenberg_enable'] !== null ) ? $gutenberg_settings['wplc_gutenberg_enable'] : 1;
|
39 |
$checked = ( @$gutenberg_enable == 1 ? 'checked' : '' );
|
40 |
-
$gutenberg_size = ( $gutenberg_settings['wplc_gutenberg_size'] ) ? $gutenberg_settings['wplc_gutenberg_size'] : 2;
|
41 |
$gutenberg_defail_logo = WPLC_PLUGIN_URL.'images/wplc_loading.png';
|
42 |
-
$gutenberg_logo = ( $gutenberg_settings['wplc_gutenberg_logo'] == '' ) ? esc_url($gutenberg_defail_logo) : $gutenberg_settings['wplc_gutenberg_logo'];
|
43 |
-
$gutenberg_text = ( $gutenberg_settings['wplc_gutenberg_text'] ) ? sanitize_text_field($gutenberg_settings['wplc_gutenberg_text']) : 'Live Chat';
|
44 |
-
$gutenberg_icon = ( $gutenberg_settings['wplc_gutenberg_icon'] ) ? sanitize_text_field($gutenberg_settings['wplc_gutenberg_icon']) : 'fa-comment-dots';
|
45 |
-
$gutenberg_enable_icon = ( $gutenberg_settings['wplc_gutenberg_enable_icon'] !== null ) ? intval($gutenberg_settings['wplc_gutenberg_enable_icon']) : 1;
|
46 |
$icon_checked = ( @$gutenberg_enable_icon == 1 ? 'checked' : '' );
|
47 |
-
$gutenberg_custom_html = ( $gutenberg_settings['wplc_custom_html'] ) ? $gutenberg_settings['wplc_custom_html'] : '';
|
48 |
?>
|
49 |
|
50 |
<div id="tabs-gutenberg">
|
@@ -209,9 +209,9 @@ function wplc_chat_box_block_editor_assets() {
|
|
209 |
// Scripts
|
210 |
wp_enqueue_script(
|
211 |
'wplc_chat_box',
|
212 |
-
|
213 |
array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
|
214 |
-
|
215 |
);
|
216 |
|
217 |
$gutenberg_logo = $gutenberg_settings['wplc_gutenberg_logo'];
|
@@ -230,9 +230,9 @@ function wplc_chat_box_block_editor_assets() {
|
|
230 |
// Styles
|
231 |
wp_enqueue_style(
|
232 |
'wplc_chat_box-editor',
|
233 |
-
|
234 |
array( 'wp-edit-blocks' ),
|
235 |
-
|
236 |
);
|
237 |
}
|
238 |
}
|
@@ -242,17 +242,17 @@ add_action( 'enqueue_block_assets', 'wplc_chat_box_block_block_assets' );
|
|
242 |
|
243 |
function wplc_chat_box_block_block_assets() {
|
244 |
global $get_gutenberg_options;
|
245 |
-
if($get_gutenberg_options['wplc_gutenberg_enable']) {
|
246 |
// Styles for front-end
|
247 |
wp_enqueue_style(
|
248 |
'wplc_chat_box-front-end',
|
249 |
-
|
250 |
array( 'wp-blocks' ),
|
251 |
-
|
252 |
);
|
253 |
wp_enqueue_style(
|
254 |
-
'wplc_chat_box-front-end-template',
|
255 |
-
|
256 |
);
|
257 |
}
|
258 |
}
|
35 |
function wplc_gutenberg_settings_content() {
|
36 |
$gutenberg_settings = get_option('wplc_gutenberg_settings');
|
37 |
|
38 |
+
$gutenberg_enable = ($gutenberg_settings!=null && $gutenberg_settings['wplc_gutenberg_enable'] !== null ) ? $gutenberg_settings['wplc_gutenberg_enable'] : 1;
|
39 |
$checked = ( @$gutenberg_enable == 1 ? 'checked' : '' );
|
40 |
+
$gutenberg_size = ($gutenberg_settings!=null && $gutenberg_settings['wplc_gutenberg_size'] ) ? $gutenberg_settings['wplc_gutenberg_size'] : 2;
|
41 |
$gutenberg_defail_logo = WPLC_PLUGIN_URL.'images/wplc_loading.png';
|
42 |
+
$gutenberg_logo = ($gutenberg_settings!=null && $gutenberg_settings['wplc_gutenberg_logo'] == '' ) ? esc_url($gutenberg_defail_logo) : ($gutenberg_settings!=null ? $gutenberg_settings['wplc_gutenberg_logo'] : esc_url($gutenberg_defail_logo));
|
43 |
+
$gutenberg_text = ($gutenberg_settings!=null && $gutenberg_settings['wplc_gutenberg_text'] ) ? sanitize_text_field($gutenberg_settings['wplc_gutenberg_text']) : 'Live Chat';
|
44 |
+
$gutenberg_icon = ($gutenberg_settings!=null && $gutenberg_settings['wplc_gutenberg_icon'] ) ? sanitize_text_field($gutenberg_settings['wplc_gutenberg_icon']) : 'fa-comment-dots';
|
45 |
+
$gutenberg_enable_icon = ($gutenberg_settings!=null && $gutenberg_settings['wplc_gutenberg_enable_icon'] !== null ) ? intval($gutenberg_settings['wplc_gutenberg_enable_icon']) : 1;
|
46 |
$icon_checked = ( @$gutenberg_enable_icon == 1 ? 'checked' : '' );
|
47 |
+
$gutenberg_custom_html = ($gutenberg_settings!=null && $gutenberg_settings['wplc_custom_html'] ) ? $gutenberg_settings['wplc_custom_html'] : '';
|
48 |
?>
|
49 |
|
50 |
<div id="tabs-gutenberg">
|
209 |
// Scripts
|
210 |
wp_enqueue_script(
|
211 |
'wplc_chat_box',
|
212 |
+
wplc_plugins_url('/includes/blocks/wplc-chat-box/block.js', __FILE__ ),
|
213 |
array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
|
214 |
+
WPLC_PLUGIN_VERSION
|
215 |
);
|
216 |
|
217 |
$gutenberg_logo = $gutenberg_settings['wplc_gutenberg_logo'];
|
230 |
// Styles
|
231 |
wp_enqueue_style(
|
232 |
'wplc_chat_box-editor',
|
233 |
+
wplc_plugins_url('/includes/blocks/wplc-chat-box/editor.css', __FILE__ ),
|
234 |
array( 'wp-edit-blocks' ),
|
235 |
+
WPLC_PLUGIN_VERSION
|
236 |
);
|
237 |
}
|
238 |
}
|
242 |
|
243 |
function wplc_chat_box_block_block_assets() {
|
244 |
global $get_gutenberg_options;
|
245 |
+
if($get_gutenberg_options!=null && $get_gutenberg_options['wplc_gutenberg_enable']) {
|
246 |
// Styles for front-end
|
247 |
wp_enqueue_style(
|
248 |
'wplc_chat_box-front-end',
|
249 |
+
wplc_plugins_url('/includes/blocks/wplc-chat-box/style.css', __FILE__ ),
|
250 |
array( 'wp-blocks' ),
|
251 |
+
WPLC_PLUGIN_VERSION
|
252 |
);
|
253 |
wp_enqueue_style(
|
254 |
+
'wplc_chat_box-front-end-template', wplc_plugins_url('/includes/blocks/wplc-chat-box/wplc_gutenberg_template_styles.css', __FILE__ ), array( 'wp-blocks' ),
|
255 |
+
WPLC_PLUGIN_VERSION
|
256 |
);
|
257 |
}
|
258 |
}
|
includes/blocks/wplc-inline-chat-box/index.php
CHANGED
@@ -21,15 +21,15 @@ function wplc_inline_chat_box_block_editor_assets() {
|
|
21 |
$style_settings['settings'] = wplc_get_options();
|
22 |
$style_settings['color_1'] = $wplc_settings['wplc_settings_color1'];
|
23 |
|
24 |
-
$wplc_images['background_image'] =
|
25 |
-
$wplc_images['open_icon'] =
|
26 |
-
$wplc_images['close_icon'] =
|
27 |
|
28 |
// Scripts
|
29 |
wp_enqueue_script( 'wplc_inline_chat_box',
|
30 |
-
|
31 |
array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
|
32 |
-
|
33 |
);
|
34 |
|
35 |
wp_localize_script( 'wplc_inline_chat_box', 'wplc_agent_info', $agent_data );
|
@@ -37,16 +37,17 @@ function wplc_inline_chat_box_block_editor_assets() {
|
|
37 |
wp_localize_script( 'wplc_inline_chat_box', 'wplc_images', $wplc_images );
|
38 |
|
39 |
wp_enqueue_script( 'wplc_chat_box_functions',
|
40 |
-
|
41 |
-
|
|
|
42 |
);
|
43 |
|
44 |
|
45 |
// Styles
|
46 |
wp_enqueue_style( 'wplc_inline_chat_box-editor',
|
47 |
-
|
48 |
array( 'wp-edit-blocks' ),
|
49 |
-
|
50 |
);
|
51 |
}
|
52 |
}
|
@@ -55,12 +56,12 @@ add_action( 'enqueue_block_assets', 'wplc_inline_chat_box_block_block_assets' );
|
|
55 |
|
56 |
function wplc_inline_chat_box_block_block_assets() {
|
57 |
global $get_gutenberg_options;
|
58 |
-
if($get_gutenberg_options['wplc_gutenberg_enable']) {
|
59 |
// Styles for front-end
|
60 |
wp_enqueue_style( 'wplc_inline_chat_box_front_end',
|
61 |
-
|
62 |
array( 'wp-blocks' ),
|
63 |
-
|
64 |
);
|
65 |
}
|
66 |
}
|
21 |
$style_settings['settings'] = wplc_get_options();
|
22 |
$style_settings['color_1'] = $wplc_settings['wplc_settings_color1'];
|
23 |
|
24 |
+
$wplc_images['background_image'] = wplc_plugins_url('/images/bg/' . $wplc_settings['wplc_settings_bg'], __FILE__ );
|
25 |
+
$wplc_images['open_icon'] = wplc_plugins_url('/images/iconRetina.png', __FILE__ );
|
26 |
+
$wplc_images['close_icon'] = wplc_plugins_url('/images/iconCloseRetina.png', __FILE__ );
|
27 |
|
28 |
// Scripts
|
29 |
wp_enqueue_script( 'wplc_inline_chat_box',
|
30 |
+
wplc_plugins_url('/includes/blocks/wplc-inline-chat-box/block.js', __FILE__ ),
|
31 |
array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
|
32 |
+
WPLC_PLUGIN_VERSION
|
33 |
);
|
34 |
|
35 |
wp_localize_script( 'wplc_inline_chat_box', 'wplc_agent_info', $agent_data );
|
37 |
wp_localize_script( 'wplc_inline_chat_box', 'wplc_images', $wplc_images );
|
38 |
|
39 |
wp_enqueue_script( 'wplc_chat_box_functions',
|
40 |
+
wplc_plugins_url('/includes/blocks/wplc-inline-chat-box/wplc_functions.js', __FILE__ ),
|
41 |
+
array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
|
42 |
+
WPLC_PLUGIN_VERSION
|
43 |
);
|
44 |
|
45 |
|
46 |
// Styles
|
47 |
wp_enqueue_style( 'wplc_inline_chat_box-editor',
|
48 |
+
wplc_plugins_url('/includes/blocks/wplc-inline-chat-box/editor.css', __FILE__ ),
|
49 |
array( 'wp-edit-blocks' ),
|
50 |
+
WPLC_PLUGIN_VERSION
|
51 |
);
|
52 |
}
|
53 |
}
|
56 |
|
57 |
function wplc_inline_chat_box_block_block_assets() {
|
58 |
global $get_gutenberg_options;
|
59 |
+
if($get_gutenberg_options!=null && $get_gutenberg_options['wplc_gutenberg_enable']) {
|
60 |
// Styles for front-end
|
61 |
wp_enqueue_style( 'wplc_inline_chat_box_front_end',
|
62 |
+
wplc_plugins_url('/includes/blocks/wplc-inline-chat-box/style.css', __FILE__ ),
|
63 |
array( 'wp-blocks' ),
|
64 |
+
WPLC_PLUGIN_VERSION
|
65 |
);
|
66 |
}
|
67 |
}
|
includes/modal_control.php
CHANGED
@@ -53,7 +53,7 @@ add_action('admin_print_scripts', 'wplc_admin_modal_javascript');
|
|
53 |
*/
|
54 |
function wplc_admin_modal_javascript(){
|
55 |
if(isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu'){
|
56 |
-
wp_register_script('wplc-admin-modal-js',
|
57 |
wp_enqueue_script('wplc-admin-modal-js');
|
58 |
}
|
59 |
}
|
53 |
*/
|
54 |
function wplc_admin_modal_javascript(){
|
55 |
if(isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu'){
|
56 |
+
wp_register_script('wplc-admin-modal-js', WPLC_PLUGIN_URL. '/js/wplc-admin-modal.js', array(), WPLC_PLUGIN_VERSION, true);
|
57 |
wp_enqueue_script('wplc-admin-modal-js');
|
58 |
}
|
59 |
}
|
includes/wplc_data_triggers.php
CHANGED
@@ -672,7 +672,7 @@ function wplc_check_trigger_filters_mrg($page){
|
|
672 |
}
|
673 |
|
674 |
function wplc_tirggers_enqueue_user_styles_scripts($trigger_id){
|
675 |
-
wp_register_script("wplc_trigger_js",
|
676 |
/*Localize vars here*/
|
677 |
$trigger_id = intval($trigger_id);
|
678 |
|
@@ -681,7 +681,7 @@ function wplc_tirggers_enqueue_user_styles_scripts($trigger_id){
|
|
681 |
$trigger_data = $trigger_data[0];
|
682 |
//Only Load styles if content is being overriden
|
683 |
if(intval($trigger_data->show_content) == 1){
|
684 |
-
wp_enqueue_style("wplc_trigger_styles",
|
685 |
}
|
686 |
|
687 |
if($trigger_data){
|
672 |
}
|
673 |
|
674 |
function wplc_tirggers_enqueue_user_styles_scripts($trigger_id){
|
675 |
+
wp_register_script("wplc_trigger_js", wplc_plugins_url('/js/wplc_user_triggers.js', __FILE__), array('jquery'), WPLC_PLUGIN_VERSION, true);
|
676 |
/*Localize vars here*/
|
677 |
$trigger_id = intval($trigger_id);
|
678 |
|
681 |
$trigger_data = $trigger_data[0];
|
682 |
//Only Load styles if content is being overriden
|
683 |
if(intval($trigger_data->show_content) == 1){
|
684 |
+
wp_enqueue_style("wplc_trigger_styles", wplc_plugins_url('/css/wplc_trigger_styles.css', __FILE__), array(), WPLC_PLUGIN_VERSION);
|
685 |
}
|
686 |
|
687 |
if($trigger_data){
|
includes/wplc_roi.php
CHANGED
@@ -664,7 +664,7 @@ function wplc_reporting_tabs_roi_reporting_content_mrg($tabs_array){
|
|
664 |
}
|
665 |
wplc_enqueue_admin_styles_mrg();
|
666 |
|
667 |
-
wp_register_script('wplc_roi_reporting_js',
|
668 |
wp_enqueue_script('wplc_roi_reporting_js');
|
669 |
|
670 |
$content = "<h3>".__("Goal Statistics", "wp-livechat")."</h3>";
|
664 |
}
|
665 |
wplc_enqueue_admin_styles_mrg();
|
666 |
|
667 |
+
wp_register_script('wplc_roi_reporting_js', wplc_plugins_url('/js/wplc_admin_roi_reporting.js', __FILE__), array('jquery'), WPLC_PLUGIN_VERSION, true);
|
668 |
wp_enqueue_script('wplc_roi_reporting_js');
|
669 |
|
670 |
$content = "<h3>".__("Goal Statistics", "wp-livechat")."</h3>";
|
js/offline_messages.js
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(function() {
|
2 |
+
jQuery("body").on("click", ".wplc_delete_message", function(e){
|
3 |
+
|
4 |
+
var message_id = jQuery(this).attr('mid');
|
5 |
+
|
6 |
+
var data = {
|
7 |
+
action: 'delete_offline_message',
|
8 |
+
security: wplc_ajax_nonce,
|
9 |
+
mid: message_id
|
10 |
+
}
|
11 |
+
|
12 |
+
jQuery.post( wplc_ajaxurl, data, function( response ){
|
13 |
+
|
14 |
+
if( response ){
|
15 |
+
|
16 |
+
jQuery('#record_'+message_id).fadeOut(700);
|
17 |
+
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
});
|
22 |
+
|
23 |
+
});
|
24 |
+
|
25 |
+
});
|
js/wplc_u_admin.js
CHANGED
@@ -484,30 +484,6 @@ jQuery(function () {
|
|
484 |
jQuery("#wplc_admin_chat_holder").append(wplc_localized_offline_string)
|
485 |
}
|
486 |
|
487 |
-
jQuery("body").on("click", ".wplc_delete_message", function(e){
|
488 |
-
|
489 |
-
var message_id = jQuery(this).attr('mid');
|
490 |
-
|
491 |
-
var data = {
|
492 |
-
action: 'delete_offline_message',
|
493 |
-
security: wplc_ajax_nonce,
|
494 |
-
mid: message_id
|
495 |
-
}
|
496 |
-
|
497 |
-
jQuery.post( wplc_ajaxurl, data, function( response ){
|
498 |
-
|
499 |
-
if( response ){
|
500 |
-
|
501 |
-
jQuery('#record_'+message_id).fadeOut(700);
|
502 |
-
|
503 |
-
}
|
504 |
-
|
505 |
-
|
506 |
-
});
|
507 |
-
|
508 |
-
});
|
509 |
-
|
510 |
-
|
511 |
});
|
512 |
|
513 |
jQuery("body").on("change","#wplc_field_type", function() {
|
484 |
jQuery("#wplc_admin_chat_holder").append(wplc_localized_offline_string)
|
485 |
}
|
486 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
487 |
});
|
488 |
|
489 |
jQuery("body").on("change","#wplc_field_type", function() {
|
modules/cta_animations.php
CHANGED
@@ -64,6 +64,6 @@ add_action('wplc_hook_push_js_to_front', 'wplc_mrg_call_to_action_anim_styles');
|
|
64 |
function wplc_mrg_call_to_action_anim_styles() {
|
65 |
$wplc_settings = wplc_get_options();
|
66 |
if (!empty($wplc_settings['wplc_pro_cta_anim']) && $wplc_settings['wplc_pro_cta_anim'] !== 'false' && $wplc_settings['wplc_pro_cta_anim'] !== false ) {
|
67 |
-
wp_enqueue_style('wplc-pro-cta-animation',
|
68 |
}
|
69 |
}
|
64 |
function wplc_mrg_call_to_action_anim_styles() {
|
65 |
$wplc_settings = wplc_get_options();
|
66 |
if (!empty($wplc_settings['wplc_pro_cta_anim']) && $wplc_settings['wplc_pro_cta_anim'] !== 'false' && $wplc_settings['wplc_pro_cta_anim'] !== false ) {
|
67 |
+
wp_enqueue_style('wplc-pro-cta-animation', wplc_plugins_url('/css/cta_animations/' . trim($wplc_settings['wplc_pro_cta_anim']) , __FILE__ ));
|
68 |
}
|
69 |
}
|
modules/node_server.php
CHANGED
@@ -377,7 +377,7 @@ function wplc_admin_dashboard() {
|
|
377 |
wplc_admin_dashboard_layout_node('other');
|
378 |
echo '<div class="floating-right-toolbar">';
|
379 |
echo '<label for="user_list_tcx_control" style="margin-bottom: 0; display:none;"></label>';
|
380 |
-
echo '<i id="toolbar-item-open-tcx" class="fa fa-fw" style="background:url(\'' .
|
381 |
echo '</div>';
|
382 |
}
|
383 |
}
|
@@ -494,7 +494,7 @@ function wplc_admin_dashboard() {
|
|
494 |
wp_localize_script('wplc-admin-js-agent', 'wplc_agent_data', $a_array);
|
495 |
wp_localize_script('wplc-admin-js-agent', 'all_agents', $a_array);
|
496 |
|
497 |
-
wp_localize_script('wplc-admin-js-agent', 'wplc_url',
|
498 |
|
499 |
if (isset($wplc_settings['wplc_settings_enabled']) && intval($wplc_settings["wplc_settings_enabled"]) == 2) {
|
500 |
$wplc_disabled_html = __("Chat is disabled in settings area, re-enable", 'wp-live-chat-support');
|
377 |
wplc_admin_dashboard_layout_node('other');
|
378 |
echo '<div class="floating-right-toolbar">';
|
379 |
echo '<label for="user_list_tcx_control" style="margin-bottom: 0; display:none;"></label>';
|
380 |
+
echo '<i id="toolbar-item-open-tcx" class="fa fa-fw" style="background:url(\'' . wplc_plugins_url('/images/tcx48px.png', __FILE__) . '\') no-repeat; background-size: cover;"></i>';
|
381 |
echo '</div>';
|
382 |
}
|
383 |
}
|
494 |
wp_localize_script('wplc-admin-js-agent', 'wplc_agent_data', $a_array);
|
495 |
wp_localize_script('wplc-admin-js-agent', 'all_agents', $a_array);
|
496 |
|
497 |
+
wp_localize_script('wplc-admin-js-agent', 'wplc_url', wplc_plugins_url('/', dirname(__FILE__)));
|
498 |
|
499 |
if (isset($wplc_settings['wplc_settings_enabled']) && intval($wplc_settings["wplc_settings_enabled"]) == 2) {
|
500 |
$wplc_disabled_html = __("Chat is disabled in settings area, re-enable", 'wp-live-chat-support');
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: WP-LiveChat, wordpress3cx, wp3cx
|
3 |
Tags: live chat, live support, chat plugin, live help, wordpress live chat, chat, live chat plugin, live support plugin, live chat support plugin, chat plugin, support plugin, live help
|
4 |
Requires at least: 4.6
|
5 |
-
Tested up to: 5.
|
6 |
Requires PHP: 5.3
|
7 |
-
Stable tag: 8.1.
|
8 |
License: GPLv2
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
Text Domain: wp-live-chat-support
|
@@ -189,4 +189,9 @@ Huge update with over 300 changes that include: Bugfixes, Vulnerability Fixes &
|
|
189 |
* Bugfix: HTML email body in auto responder not parsed correctly
|
190 |
* Improvement: added "Debug mode", extra logs added to PHP error log
|
191 |
* Improvement: reduced ajax requests footprint, removing unneeded fields
|
192 |
-
* Improvement: added confirmation for history delete
|
|
|
|
|
|
|
|
|
|
2 |
Contributors: WP-LiveChat, wordpress3cx, wp3cx
|
3 |
Tags: live chat, live support, chat plugin, live help, wordpress live chat, chat, live chat plugin, live support plugin, live chat support plugin, chat plugin, support plugin, live help
|
4 |
Requires at least: 4.6
|
5 |
+
Tested up to: 5.4.1
|
6 |
Requires PHP: 5.3
|
7 |
+
Stable tag: 8.1.8
|
8 |
License: GPLv2
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
Text Domain: wp-live-chat-support
|
189 |
* Bugfix: HTML email body in auto responder not parsed correctly
|
190 |
* Improvement: added "Debug mode", extra logs added to PHP error log
|
191 |
* Improvement: reduced ajax requests footprint, removing unneeded fields
|
192 |
+
* Improvement: added confirmation for history delete
|
193 |
+
|
194 |
+
= 8.1.8 - 2020-05-28 =
|
195 |
+
* Bugfix: Offline messages delete not worked
|
196 |
+
* Bugfix: Load bootstrap js sourcemap failed
|
197 |
+
* Bugfix: Urls Fixed for linux compatibility
|
wp-live-chat-support.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP-Live Chat by 3CX
|
4 |
Plugin URI: https://www.3cx.com/wp-live-chat/
|
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 by 3CX.
|
6 |
-
Version: 8.1.
|
7 |
Author: 3CX
|
8 |
Author URI: https://www.3cx.com/wp-live-chat/
|
9 |
Domain Path: /languages
|
@@ -21,8 +21,8 @@ global $wpdb;
|
|
21 |
global $wplc_tblname_chats;
|
22 |
global $wplc_tblname_msgs;
|
23 |
global $wplc_tblname_offline_msgs;
|
24 |
-
global $current_chat_id;
|
25 |
-
global $wplc_tblname_chat_ratings;
|
26 |
global $wplc_tblname_chat_triggers;
|
27 |
|
28 |
/**
|
@@ -31,292 +31,294 @@ global $wplc_tblname_chat_triggers;
|
|
31 |
global $admin_chat_data;
|
32 |
$admin_chat_data = false;
|
33 |
|
34 |
-
$wplc_tblname_offline_msgs
|
35 |
-
$wplc_tblname_chats
|
36 |
-
$wplc_tblname_msgs
|
37 |
-
$wplc_tblname_chat_ratings
|
38 |
$wplc_tblname_chat_triggers = $wpdb->prefix . "wplc_chat_triggers";
|
39 |
|
40 |
$wplc_default_settings_array = array();
|
41 |
|
42 |
function wplc_set_defaults() {
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
}
|
196 |
|
197 |
wplc_set_defaults();
|
198 |
|
199 |
-
function wplc_get_options($sanitize=false) {
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
|
|
294 |
}
|
295 |
|
296 |
// Load Config
|
297 |
-
require_once
|
298 |
-
require_once
|
299 |
// User
|
300 |
-
require_once
|
301 |
// Agent
|
302 |
-
require_once
|
303 |
|
304 |
// Check if PRO plugin is active
|
305 |
function wplc_is_pro_active( $plugin ) {
|
306 |
|
307 |
// Check if it's a WP network
|
308 |
if ( ! is_multisite() ) {
|
309 |
-
$active_plugins = get_option( 'active_plugins', array() );
|
|
|
310 |
return in_array( $plugin, (array) $active_plugins );
|
311 |
}
|
312 |
|
313 |
$plugins = get_site_option( 'active_sitewide_plugins' );
|
314 |
if ( isset( $plugins[ $plugin ] ) ) {
|
315 |
return true;
|
316 |
-
}else {
|
317 |
return false;
|
318 |
}
|
319 |
-
|
320 |
}
|
321 |
|
322 |
// Check if PRO plugin is present
|
@@ -329,100 +331,103 @@ function wplc_is_pro_present() {
|
|
329 |
}
|
330 |
}
|
331 |
|
332 |
-
|
333 |
/*
|
334 |
* Load Includes
|
335 |
*/
|
336 |
-
|
337 |
-
require_once (plugin_dir_path(__FILE__) . "includes/notification_control.php");
|
338 |
-
require_once (plugin_dir_path(__FILE__) . "includes/modal_control.php");
|
339 |
-
require_once (plugin_dir_path(__FILE__) . "includes/wplc_data_triggers.php");
|
340 |
-
require_once (plugin_dir_path(__FILE__) . "includes/wplc_roi.php");
|
341 |
-
require_once (plugin_dir_path(__FILE__) . "includes/wplc_departments.php");
|
342 |
-
require_once (plugin_dir_path(__FILE__) . "includes/wplc_transfer_chats.php");
|
343 |
-
require_once (plugin_dir_path(__FILE__) . "includes/wplc_custom_fields.php");
|
344 |
-
require_once (plugin_dir_path(__FILE__) . "includes/wplc_agent_data.php");
|
345 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
|
347 |
|
348 |
/*
|
349 |
* Load Modules
|
350 |
*/
|
351 |
-
require_once
|
352 |
-
require_once
|
353 |
-
require_once
|
354 |
-
require_once
|
355 |
-
require_once
|
356 |
-
require_once
|
357 |
-
require_once
|
358 |
-
require_once
|
359 |
-
|
360 |
-
|
361 |
|
362 |
|
363 |
/*
|
364 |
* Added back for backwards compat decrypt
|
365 |
*/
|
366 |
-
if (class_exists("AES")) {
|
367 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
|
369 |
// Gutenberg Blocks
|
370 |
-
require_once
|
371 |
-
require_once
|
372 |
|
373 |
// Shortcodes
|
374 |
-
require_once
|
375 |
-
|
376 |
-
add_action("wplc_set_session_chat_id", 'wplc_set_u_session' );
|
377 |
-
add_action("wplc_end_session_chat_id", 'wplc_clean_session' );
|
378 |
-
add_action('admin_init', 'wplc_detect_old_pro_plugin');
|
379 |
-
add_action("wp_login",'wplc_check_guid');
|
380 |
-
add_action('init', 'wplc_version_control');
|
381 |
-
add_action('init', 'wplc_init');
|
382 |
-
add_action('init', 'wplc_mrg_create_macro_post_type',100);
|
383 |
-
add_action('admin_init', 'wplc_head');
|
384 |
-
add_action('wp_ajax_wplc_admin_set_transient', 'wplc_action_callback');
|
385 |
-
add_action('wp_ajax_wplc_admin_remove_transient', 'wplc_action_callback');
|
386 |
-
add_action('wp_ajax_wplc_hide_ftt', 'wplc_action_callback');
|
387 |
-
add_action('wp_ajax_nopriv_wplc_user_send_offline_message', 'wplc_action_callback');
|
388 |
-
add_action('wp_ajax_wplc_user_send_offline_message', 'wplc_action_callback');
|
389 |
-
add_action('wp_ajax_delete_offline_message', 'wplc_action_callback');
|
390 |
-
add_action('wp_ajax_wplc_a2a_dismiss', 'wplc_action_callback');
|
391 |
-
add_action('activated_plugin', 'wplc_redirect_on_activate');
|
392 |
-
add_action('wp_ajax_wplc_choose_accepting','wplc_action_callback');
|
393 |
-
add_action('wp_ajax_wplc_choose_not_accepting','wplc_action_callback');
|
394 |
-
add_action('wp_ajax_wplc_agent_list','wplc_action_callback');
|
395 |
-
add_action('wplc_hook_action_callback','wplc_choose_hook_control_action_callback');
|
396 |
-
add_action('wplc_hook_admin_menu_layout_display_top','wplc_ma_hook_control_admin_meny_layout_display_top');
|
397 |
-
add_action('edit_user_profile_update', 'wplc_maa_set_user_as_agent');
|
398 |
-
add_action('personal_options_update', 'wplc_maa_set_user_as_agent');
|
399 |
-
add_action('edit_user_profile', 'wplc_maa_custom_user_profile_fields');
|
400 |
-
add_action('show_user_profile', 'wplc_maa_custom_user_profile_fields');
|
401 |
-
add_action('admin_enqueue_scripts', 'wplc_control_admin_javascript');
|
402 |
-
add_action('wp_ajax_wplc_add_agent', 'wplc_action_callback');
|
403 |
-
add_action('wp_ajax_wplc_remove_agent', 'wplc_action_callback');
|
404 |
-
add_action('wp_ajax_wplc_macro', 'wplc_action_callback');
|
405 |
-
add_action('wp_ajax_wplc_typing', 'wplc_action_callback');
|
406 |
-
add_action('wp_ajax_nopriv_wplc_typing', 'wplc_action_callback');
|
407 |
-
add_action('wp_ajax_wplc_upload_file', 'wplc_action_callback');
|
408 |
-
add_action('wp_ajax_nopriv_wplc_upload_file', 'wplc_action_callback');
|
409 |
-
add_action('wp_ajax_wplc_record_chat_rating', 'wplc_action_callback');
|
410 |
-
add_action('wp_ajax_nopriv_wplc_record_chat_rating', 'wplc_action_callback');
|
411 |
-
add_action('wp_enqueue_scripts', 'wplc_add_user_stylesheet');
|
412 |
-
add_action('admin_enqueue_scripts', 'wplc_add_admin_stylesheet');
|
413 |
-
add_action('admin_menu', 'wplc_admin_menu', 4);
|
414 |
-
add_action("wplc_hook_admin_chatbox_javascript","wplc_features_admin_js");
|
415 |
-
add_action('admin_head', 'wplc_superadmin_javascript');
|
416 |
add_action( 'admin_notices', 'wplc_deprecated_standalone_pro' );
|
417 |
add_action( 'wp_ajax_wplc_generate_new_node_token', 'wplc_ajax_generate_new_tokens' );
|
418 |
add_action( 'wp_ajax_wplc_new_secret_key', 'wplc_ajax_generate_new_tokens' );
|
419 |
add_action( 'wp_ajax_wplc_generate_new_encryption_key', 'wplc_ajax_generate_new_tokens' );
|
420 |
|
421 |
// Activation Hook
|
422 |
-
register_activation_hook(__FILE__, 'wplc_activate');
|
423 |
|
424 |
// Uninstall Hook
|
425 |
-
register_uninstall_hook(__FILE__, 'wplc_uninstall');
|
426 |
|
427 |
function wplc_uninstall() {
|
428 |
global $wpdb;
|
@@ -431,261 +436,323 @@ function wplc_uninstall() {
|
|
431 |
global $wplc_tblname_msgs;
|
432 |
global $wplc_tblname_chat_ratings;
|
433 |
global $wplc_tblname_chat_triggers;
|
434 |
-
|
435 |
-
$wplc_settings = wplc_get_options();
|
436 |
-
|
437 |
-
if ($wplc_settings['wplc_delete_db_on_uninstall']) {
|
438 |
|
439 |
-
|
440 |
|
441 |
-
|
442 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
}
|
444 |
-
|
445 |
-
unregister_post_type('wplc_quick_response');
|
446 |
-
|
447 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wplc_tblname_offline_msgs}");
|
448 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wplc_tblname_chats }");
|
449 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wplc_tblname_msgs }");
|
450 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wplc_tblname_chat_ratings }");
|
451 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wplc_tblname_chat_triggers }");
|
452 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}wplc_webhooks");
|
453 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}wplc_roi_goals");
|
454 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}wplc_roi_conversions");
|
455 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}wplc_devices");
|
456 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}wplc_departments");
|
457 |
-
$wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}wplc_custom_fields");
|
458 |
-
|
459 |
-
$admins = get_role('administrator');
|
460 |
-
if( $admins !== null ) {
|
461 |
-
$admins->remove_cap('edit_wplc_quick_response');
|
462 |
-
$admins->remove_cap('edit_wplc_quick_response');
|
463 |
-
$admins->remove_cap('edit_other_wplc_quick_response');
|
464 |
-
$admins->remove_cap('publish_wplc_quick_response');
|
465 |
-
$admins->remove_cap('read_wplc_quick_response');
|
466 |
-
$admins->remove_cap('read_private_wplc_quick_response');
|
467 |
-
$admins->remove_cap('delete_wplc_quick_response');
|
468 |
-
$admins->remove_cap('wplc_ma_agent');
|
469 |
}
|
470 |
-
|
471 |
$users = wplc_get_agent_users();
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
}
|
482 |
}
|
483 |
|
484 |
// Plugin initialisation
|
485 |
function wplc_init() {
|
486 |
// Load Languages
|
487 |
-
|
488 |
-
|
489 |
// Load Agent API
|
490 |
-
require_once
|
491 |
}
|
492 |
|
493 |
// Show notice if PRO plugin is present in versions < 8.0.27
|
494 |
function wplc_deprecated_standalone_pro() {
|
495 |
-
if (wplc_is_pro_present()) {
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
}
|
502 |
}
|
503 |
|
504 |
// If an old PRO plugin is detected disable it as it is not needed anymore.
|
505 |
function wplc_detect_old_pro_plugin() {
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
}
|
510 |
|
511 |
/**
|
512 |
* Redirect the user to the welcome page on plugin activate
|
513 |
-
*
|
|
|
|
|
514 |
* @return void
|
515 |
*/
|
516 |
function wplc_redirect_on_activate( $plugin ) {
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
}
|
|
|
529 |
add_action( 'admin_init', 'wplc_redirect_on_activate' );
|
530 |
|
531 |
|
532 |
function wplc_version_control() {
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
}
|
600 |
-
|
601 |
-
function wplc_parameter_bool($settings, $name) {
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
|
|
610 |
}
|
611 |
|
612 |
function wplc_check_guid() {
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
}
|
646 |
|
647 |
function wplc_action_callback() {
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
|
|
|
|
|
|
|
|
689 |
}
|
690 |
|
691 |
/**
|
@@ -693,87 +760,89 @@ function wplc_action_callback() {
|
|
693 |
* @return array
|
694 |
* @since 6.0.00
|
695 |
*/
|
696 |
-
add_filter("wplc_ma_filter_menu_control","wplc_filter_control_menu_control",10,1);
|
697 |
function wplc_filter_control_menu_control() {
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
return $array;
|
727 |
-
}
|
728 |
-
|
729 |
-
add_action('admin_init', 'wplc_metric_dashboard_redirect');
|
730 |
-
function wplc_metric_dashboard_redirect(){
|
731 |
-
try{
|
732 |
-
$cap = apply_filters("wplc_ma_filter_menu_control",array());
|
733 |
-
if(current_user_can($cap[1])){
|
734 |
-
if (isset($_GET['page'])) {
|
735 |
-
if ($_GET['page'] === 'wplivechat-menu') {
|
736 |
-
// check if we are overriding this redirect because the user pressed the "Chat now" button in the dashboard
|
737 |
-
if (isset($_GET['subaction']) && $_GET['subaction'] == 'override') { } else {
|
738 |
-
if(!isset($_COOKIE['wplcfirstsession'])) {
|
739 |
-
@setcookie("wplcfirstsession", true, time() + (60 * 60 * 24)); // 60s * 60m * 24h (Life span of cookie)
|
740 |
-
@Header("Location: ./admin.php?page=wplivechat-menu-dashboard");
|
741 |
-
exit();
|
742 |
-
}
|
743 |
-
}
|
744 |
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
749 |
|
750 |
-
|
751 |
}
|
752 |
|
753 |
function wplc_admin_menu() {
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
}
|
772 |
-
|
773 |
-
|
774 |
-
add_action("wplc_hook_menu","wplc_hook_control_menu");
|
775 |
function wplc_hook_control_menu() {
|
776 |
-
|
777 |
}
|
778 |
|
779 |
/**
|
@@ -781,346 +850,443 @@ function wplc_hook_control_menu() {
|
|
781 |
* @return void
|
782 |
* @since 6.0.00
|
783 |
*/
|
784 |
-
add_action("wplc_hook_menu_mid","wplc_mid_hook_control_menu",10,1);
|
785 |
-
function wplc_mid_hook_control_menu($cap) {
|
786 |
-
add_submenu_page('wplivechat-menu', __('Reports', 'wp-live-chat-support'), __('Reports', 'edit_posts'), $cap[1], 'wplivechat-menu-reporting', 'wplc_reporting_page');
|
787 |
-
add_submenu_page('wplivechat-menu', __('Triggers', 'wp-live-chat-support'), __('Triggers', 'edit_posts'), $cap[1], 'wplivechat-menu-triggers', 'wplc_triggers_page');
|
788 |
-
add_submenu_page('wplivechat-menu', __('Custom Fields', 'wp-live-chat-support'), __('Custom Fields', 'edit_posts'), $cap[1], 'wplivechat-menu-custom-fields', 'wplc_custom_fields_page');
|
789 |
}
|
790 |
|
791 |
|
792 |
-
add_action("wp_head","wplc_load_user_js",0);
|
|
|
793 |
|
|
|
|
|
|
|
|
|
|
|
794 |
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
|
801 |
-
|
802 |
-
$user_banned = wplc_is_user_banned();
|
803 |
-
} else {
|
804 |
-
$user_banned = 0;
|
805 |
-
}
|
806 |
-
|
807 |
-
$display_contents = wplc_display_chat_contents();
|
808 |
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
}
|
819 |
|
820 |
function wplc_push_js_to_front() {
|
821 |
-
|
822 |
-
|
823 |
|
824 |
-
wp_register_script('wplc-user-jquery-cookie',
|
825 |
-
wp_enqueue_script('wplc-user-jquery-cookie');
|
826 |
|
827 |
-
|
828 |
|
829 |
-
|
830 |
|
831 |
-
|
832 |
-
$wplc_ga_enabled = get_option("WPLC_GA_SETTINGS");
|
833 |
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
|
841 |
-
|
842 |
-
|
|
|
|
|
843 |
|
844 |
-
|
845 |
-
|
846 |
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
|
851 |
-
wp_register_script('wplc-server-script',
|
852 |
-
|
853 |
|
854 |
-
|
855 |
-
|
856 |
'time_format' => get_option( 'time_format' ),
|
857 |
) );
|
858 |
|
859 |
-
|
860 |
-
|
861 |
-
wp_register_script('wplc-node-server-script', WPLC_PLUGIN_URL."js/vendor/sockets.io/socket.io.slim.js", array('jquery'), WPLC_PLUGIN_VERSION, true);
|
862 |
-
|
863 |
-
|
864 |
-
|
|
|
|
|
|
|
865 |
wp_localize_script('wplc-server-script', 'tcx_override_upload_url', rest_url( 'wp_live_chat_support/v1/remote_upload' ) );
|
866 |
*/
|
867 |
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
if (
|
873 |
-
wp_register_script('wplc-user-js-emoji-concat', WPLC_PLUGIN_URL."js/vendor/wdt-emoji/wdt-emoji-concat.min.js", array(
|
874 |
-
|
875 |
-
|
|
|
|
|
|
|
876 |
wp_enqueue_style( 'wplc-admin-style-emoji' );
|
877 |
}
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
966 |
|
967 |
$wplc_error_messages = array(
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1047 |
|
1048 |
if ( ! empty( $wplc_grav_image ) ) {
|
1049 |
-
wp_localize_script('wplc-user-script', 'wplc_gravatar_image', $wplc_grav_image);
|
1050 |
-
|
1051 |
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
|
1056 |
-
|
1057 |
-
|
1058 |
|
1059 |
-
|
1060 |
}
|
1061 |
|
1062 |
-
add_action('wp_head', 'wplc_user_top_js');
|
1063 |
|
1064 |
|
1065 |
/**
|
1066 |
* Add to the array to determine which images need to be preloaded via JS on the front end.
|
1067 |
*
|
1068 |
-
* @param
|
|
|
1069 |
* @return array
|
1070 |
*/
|
1071 |
add_filter( "wplc_get_images_to_preload", "wplc_filter_control_get_images_to_preload", 10, 2 );
|
1072 |
function wplc_filter_control_get_images_to_preload( $images, $wplc_settings ) {
|
1073 |
-
$icon
|
1074 |
-
$close_icon =
|
1075 |
array_push( $images, $icon );
|
1076 |
array_push( $images, $close_icon );
|
|
|
1077 |
return $images;
|
1078 |
}
|
1079 |
|
1080 |
function wplc_user_top_js() {
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1124 |
}
|
1125 |
|
1126 |
/**
|
@@ -1129,14 +1295,14 @@ function wplc_user_top_js() {
|
|
1129 |
* @since 6.0.00
|
1130 |
*/
|
1131 |
function wplc_hook_control_banned_users() {
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
}
|
1141 |
|
1142 |
/**
|
@@ -1145,26 +1311,26 @@ function wplc_hook_control_banned_users() {
|
|
1145 |
* @since 6.0.00
|
1146 |
*/
|
1147 |
function wplc_hook_control_check_mobile() {
|
1148 |
-
|
1149 |
-
|
1150 |
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
}
|
1169 |
|
1170 |
/**
|
@@ -1173,10 +1339,10 @@ function wplc_hook_control_check_mobile() {
|
|
1173 |
* @since 6.0.00
|
1174 |
*/
|
1175 |
function wplc_hook_control_is_chat_enabled() {
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
}
|
1181 |
|
1182 |
/**
|
@@ -1184,543 +1350,587 @@ function wplc_hook_control_is_chat_enabled() {
|
|
1184 |
* @return string
|
1185 |
* @since 6.0.00
|
1186 |
*/
|
1187 |
-
function wplc_hook_control_show_chat_box($cid) {
|
1188 |
-
|
1189 |
}
|
1190 |
|
1191 |
/* basic */
|
1192 |
-
add_action("wplc_hook_output_box_header","wplc_hook_control_banned_users");
|
1193 |
-
add_action("wplc_hook_output_box_header","wplc_hook_control_check_mobile");
|
1194 |
-
add_action("wplc_hook_output_box_header","wplc_hook_control_is_chat_enabled");
|
1195 |
|
1196 |
-
add_action("wplc_hook_output_box_body","wplc_hook_control_show_chat_box",10,1);
|
1197 |
|
1198 |
/**
|
1199 |
* Build the chat box
|
1200 |
* @return void
|
1201 |
* @since 6.0.00
|
1202 |
*/
|
1203 |
-
function wplc_output_box_5100($cid = null) {
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
}
|
1208 |
|
1209 |
/**
|
1210 |
* Filter to control the top MAIN DIV of the chat box
|
1211 |
-
*
|
|
|
|
|
1212 |
* @return string
|
1213 |
* @since 6.0.00
|
1214 |
*/
|
1215 |
-
function wplc_filter_control_live_chat_box_html_main_div_top($wplc_settings, $logged_in, $wplc_using_locale) {
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
}
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
}
|
1306 |
|
1307 |
/**
|
1308 |
* Filter to control the top HEADER DIV of the chat box
|
1309 |
-
*
|
|
|
|
|
1310 |
* @return string
|
1311 |
* @since 6.0.00
|
1312 |
*/
|
1313 |
-
function wplc_filter_control_live_chat_box_html_header_div_top($wplc_settings) {
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
|
|
1321 |
}
|
1322 |
|
1323 |
-
add_filter("wplc_filter_chat_header_under","wplc_filter_control_chat_header_under",1,2);
|
1324 |
-
function wplc_filter_control_chat_header_under($ret_msg
|
1325 |
-
if($wplc_settings['wplc_newtheme'] == "theme-2") {
|
1326 |
-
|
1327 |
}
|
|
|
1328 |
return $ret_msg;
|
1329 |
}
|
1330 |
|
1331 |
/**
|
1332 |
* Filter to control the user details section - custom fields coming soon
|
1333 |
-
*
|
|
|
|
|
1334 |
* @return string
|
1335 |
* @since 6.0.00
|
1336 |
*/
|
1337 |
-
function wplc_filter_control_live_chat_box_html_ask_user_detail($wplc_settings) {
|
1338 |
-
|
1339 |
|
1340 |
-
if ($wplc_settings['wplc_require_user_info'] == 'both' || $wplc_settings['wplc_require_user_info'] == 'name' ) {
|
1341 |
$wplc_ask_user_details = 1;
|
1342 |
} else {
|
1343 |
$wplc_ask_user_details = 0;
|
1344 |
}
|
1345 |
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1410 |
}
|
1411 |
|
1412 |
|
1413 |
/**
|
1414 |
* Filter to control the start chat button
|
1415 |
-
*
|
|
|
|
|
1416 |
* @return string
|
1417 |
* @since 6.0.00
|
1418 |
*/
|
1419 |
-
function wplc_filter_control_live_chat_box_html_start_chat_button($wplc_settings
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
|
|
|
|
|
1428 |
|
1429 |
|
1430 |
/**
|
1431 |
* Filter to control the hover card start chat button
|
1432 |
-
*
|
|
|
|
|
1433 |
* @return string
|
1434 |
* @since 6.1.00
|
1435 |
*/
|
1436 |
-
add_filter("wplc_filter_live_chat_box_hover_html_start_chat_button","wplc_filter_control_live_chat_box_html_hovercard_chat_button",10,4);
|
1437 |
-
function wplc_filter_control_live_chat_box_html_hovercard_chat_button($content
|
1438 |
-
|
1439 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1440 |
|
1441 |
-
|
1442 |
-
$text = ($wplc_using_locale ? $wplc_sst_1 : stripslashes($wplc_settings['wplc_pro_sst1']));
|
1443 |
-
return "<button id=\"speeching_button\" type=\"button\" class='wplc-color-bg-1 wplc-color-2'>$text</button>";
|
1444 |
-
} else {
|
1445 |
-
$wplc_sst_1 = stripslashes($wplc_settings['wplc_pro_offline_btn']);
|
1446 |
-
return "<button id=\"speeching_button\" type=\"button\" class='wplc-color-bg-1 wplc-color-2'>$wplc_sst_1</button>";
|
1447 |
|
1448 |
-
|
1449 |
}
|
1450 |
|
1451 |
/**
|
1452 |
* Filter to control the offline message button
|
1453 |
-
*
|
|
|
|
|
1454 |
* @return string
|
1455 |
* @since 6.0.00
|
1456 |
*/
|
1457 |
-
function wplc_filter_control_live_chat_box_html_send_offline_message_button($wplc_settings) {
|
1458 |
-
$wplc_settings = wplc_get_options();
|
1459 |
-
$wplc_theme
|
1460 |
-
if (!empty($wplc_settings['theme'])) {
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
return $ret_msg;
|
1503 |
-
}
|
1504 |
|
|
|
|
|
1505 |
|
1506 |
|
1507 |
/**
|
1508 |
* Filter to control the 2nd layer of the chat window (online/offline)
|
1509 |
-
*
|
1510 |
-
* @param
|
|
|
|
|
1511 |
* @return string
|
1512 |
* @since 6.0.00
|
1513 |
*/
|
1514 |
-
function wplc_filter_control_live_chat_box_html_2nd_layer($wplc_settings
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
|
|
|
|
1577 |
}
|
1578 |
|
1579 |
/**
|
1580 |
* Filter to control the 3rd layer of the chat window
|
1581 |
-
*
|
|
|
|
|
1582 |
* @return string
|
1583 |
* @since 6.0.00
|
1584 |
*/
|
1585 |
-
function wplc_filter_control_live_chat_box_html_3rd_layer($wplc_settings
|
1586 |
-
|
|
|
|
|
|
|
|
|
|
|
1587 |
|
1588 |
-
|
1589 |
-
$text = ($wplc_using_locale ? $wplc_default_settings_array['wplc_pro_sst2'] : stripslashes($wplc_settings['wplc_pro_sst2']));
|
1590 |
|
1591 |
-
|
1592 |
-
return $ret_msg;
|
1593 |
}
|
1594 |
|
1595 |
-
add_filter("wplc_filter_intro_text_heading", "wplc_filter_control_intro_text_heading", 10, 2);
|
1596 |
/**
|
1597 |
* Filters intro text
|
1598 |
-
*/
|
1599 |
-
function wplc_filter_control_intro_text_heading($content, $wplc_settings) {
|
1600 |
-
if ($wplc_settings['wplc_require_user_info'] == 'none') {
|
1601 |
-
|
1602 |
-
|
|
|
1603 |
return $content;
|
1604 |
}
|
1605 |
|
1606 |
-
add_filter("wplc_filter_live_chat_box_above_main_div","wplc_filter_control_live_chat_box_above_main_div",10,3);
|
1607 |
function wplc_filter_control_live_chat_box_above_main_div( $msg, $wplc_settings, $cid ) {
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
<img class="img-thumbnail img-circle wplc_thumb32 wplc_agent_involved" style="max-width:inherit;" id="agent_grav_'
|
1635 |
-
<span class="wplc_agent_name wplc-color-2" title="' . esc_attr($agent) . '">'.esc_html($agent).'</span>
|
1636 |
-
'
|
1637 |
-
<button class="tcx_pullup down" title="'.esc_attr($title).'"><i class="fas fa-angle-down" ></i></button>';
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
|
|
1648 |
}
|
1649 |
|
1650 |
/**
|
1651 |
* Filter to control the 4th layer of the chat window
|
1652 |
-
*
|
|
|
|
|
1653 |
* @return string
|
1654 |
* @since 6.0.00
|
1655 |
*/
|
1656 |
-
function wplc_filter_control_live_chat_box_html_4th_layer($wplc_settings, $wplc_using_locale, $cid) {
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
|
|
1688 |
}
|
1689 |
|
1690 |
/**
|
1691 |
* Filter to control the 1st layer of the chat window
|
1692 |
-
*
|
1693 |
-
* @param
|
1694 |
-
* @param
|
|
|
|
|
1695 |
* @return string
|
1696 |
* @since 6.0.00
|
1697 |
*/
|
1698 |
-
function wplc_filter_control_live_chat_box_html_1st_layer($wplc_settings, $logged_in, $wplc_using_locale, $class_override = false) {
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
|
|
1724 |
} else {
|
1725 |
return $url;
|
1726 |
}
|
@@ -1728,218 +1938,234 @@ function wplc_shortenurl($url) {
|
|
1728 |
|
1729 |
/**
|
1730 |
* The function that builds the chat box
|
1731 |
-
* @since 6.0.00
|
1732 |
* @return JSON encoded HTML
|
|
|
1733 |
*/
|
1734 |
-
function wplc_output_box_ajax($cid = null) {
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
}
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1883 |
|
1884 |
|
1885 |
function wplc_superadmin_javascript() {
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
|
|
|
|
|
|
|
|
1943 |
|
1944 |
}
|
1945 |
|
@@ -1952,19 +2178,19 @@ function wplc_superadmin_javascript() {
|
|
1952 |
function wplc_admin_javascript() {
|
1953 |
$wplc_settings = wplc_get_options();
|
1954 |
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
}
|
1969 |
|
1970 |
/**
|
@@ -1974,68 +2200,77 @@ function wplc_admin_javascript() {
|
|
1974 |
* @since 7.1.00
|
1975 |
*/
|
1976 |
function wplc_admin_output_js() {
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
}
|
2005 |
|
2006 |
function wplc_admin_menu_layout() {
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
}
|
2024 |
|
2025 |
function wplc_first_time_tutorial() {
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2039 |
}
|
2040 |
|
2041 |
/**
|
@@ -2043,513 +2278,531 @@ function wplc_first_time_tutorial() {
|
|
2043 |
* @return void
|
2044 |
* @since 6.0.00
|
2045 |
*/
|
2046 |
-
add_filter("wplc_filter_chat_dahsboard_visitors_online_bottom","wplc_filter_control_chat_dashboard_visitors_online_bottom",10);
|
2047 |
-
function wplc_filter_control_chat_dashboard_visitors_online_bottom($text) {
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
|
|
2054 |
}
|
2055 |
|
2056 |
function wplc_admin_menu_layout_display() {
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2128 |
}
|
2129 |
|
2130 |
-
add_action("wplc_hook_change_status_on_answer","wplc_hook_control_change_status_on_answer",10,2);
|
2131 |
-
function wplc_hook_control_change_status_on_answer($get_data, $chat_data = false) {
|
2132 |
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
}
|
2137 |
|
2138 |
|
2139 |
-
add_action('wplc_hook_accept_chat','wplc_hook_control_accept_chat',10,2);
|
2140 |
-
function wplc_hook_control_accept_chat($get_data
|
2141 |
|
2142 |
global $admin_chat_data;
|
2143 |
|
2144 |
-
if (
|
2145 |
-
$chat_data = wplc_get_chat_data($get_data['cid'], __LINE__);
|
2146 |
} else {
|
2147 |
-
if (isset($admin_chat_data->id) && intval($admin_chat_data->id) === intval($get_data['cid'])) {
|
2148 |
$chat_data = $admin_chat_data;
|
2149 |
} else {
|
2150 |
/* chat ID's dont match, get the data for the correct chat ID */
|
2151 |
-
$chat_data = wplc_get_chat_data($get_data['cid'], __LINE__);
|
2152 |
}
|
2153 |
}
|
2154 |
|
2155 |
|
2156 |
-
do_action("wplc_hook_accept_chat_url"
|
2157 |
-
|
2158 |
-
do_action("wplc_hook_draw_chat_area"
|
2159 |
|
2160 |
|
2161 |
}
|
2162 |
|
2163 |
/**
|
2164 |
-
* Hook to accept chat
|
2165 |
-
*
|
2166 |
-
* @
|
2167 |
-
*
|
2168 |
-
* @return void
|
2169 |
-
*
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
|
|
|
2179 |
|
2180 |
}
|
2181 |
|
2182 |
/**
|
2183 |
-
* Assign the chat to the agent
|
2184 |
-
*
|
2185 |
-
* Replaces the same function of a different name in the older pro version
|
2186 |
-
*
|
2187 |
-
* @
|
2188 |
-
*
|
2189 |
-
* @return void
|
2190 |
-
*
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
|
|
2200 |
}
|
2201 |
}
|
2202 |
|
2203 |
|
2204 |
-
add_action("wplc_hook_draw_chat_area","wplc_hook_control_draw_chat_area",10,2);
|
2205 |
-
function wplc_hook_control_draw_chat_area($get_data, $chat_data = false) {
|
2206 |
|
2207 |
-
|
2208 |
}
|
2209 |
|
2210 |
-
function wplc_draw_chat_area($cid, $chat_data = false) {
|
2211 |
|
2212 |
-
|
2213 |
-
|
2214 |
|
2215 |
-
|
2216 |
SELECT *
|
2217 |
FROM $wplc_tblname_chats
|
2218 |
WHERE `id` = %s
|
2219 |
LIMIT 1
|
2220 |
-
", $cid)
|
2221 |
-
|
2222 |
-
|
2223 |
-
if($results) {
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2254 |
}
|
2255 |
-
|
2256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2257 |
}
|
2258 |
-
|
2259 |
-
|
|
|
|
|
|
|
2260 |
}
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
|
|
2264 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2265 |
}
|
2266 |
|
2267 |
-
|
2268 |
-
|
|
|
|
|
|
|
2269 |
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
if ( isset( $_GET['action'] ) && $_GET['action'] === "ac" ) {
|
2285 |
-
echo "<div class=\"end_chat_div\">";
|
2286 |
|
2287 |
-
|
2288 |
|
2289 |
-
|
2290 |
|
2291 |
-
|
2292 |
-
do_action("wplc_hook_admin_visitor_info_display_after",$cid);
|
2293 |
|
2294 |
-
|
|
|
|
|
|
|
|
|
2295 |
}
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2301 |
}
|
2302 |
-
echo "<style>#adminmenuwrap { display:none; } #adminmenuback { display:none; } #wpadminbar { display:none; } #wpfooter { display:none; } .update-nag { display:none; }</style>";
|
2303 |
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2308 |
|
2309 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2310 |
|
2311 |
-
|
|
|
|
|
|
|
|
|
|
|
2312 |
|
2313 |
-
//do_action("wplc_hook_wplc_draw_chat_area",$result);
|
2314 |
|
2315 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2316 |
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
echo "<span class='part1'><b>" . __("Chat initiated on:", 'wp-live-chat-support') . "</b></span> <span class='part2'>" . esc_url($result->url) . "</span><br>";
|
2321 |
-
echo "<span class='part1'><b>" . __("Browser:", 'wp-live-chat-support') . "</b></span><span class='part2'> $browser <img src='" . WPLC_PLUGIN_URL . "images/$browser_image' alt='$browser' title='$browser' align='absmiddle' /></span>";
|
2322 |
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
echo wplc_return_chat_messages($cid, true);
|
2330 |
-
}
|
2331 |
-
echo "</div>";
|
2332 |
-
|
2333 |
-
if ( isset( $_GET['action'] ) && $_GET['action'] === "ac" ) {
|
2334 |
-
echo"<div class='admin_chat_box_inner_bottom'>" . wplc_return_chat_response_box($cid, $result) . "</div>";
|
2335 |
-
}
|
2336 |
|
2337 |
-
|
|
|
2338 |
|
2339 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2340 |
|
2341 |
-
|
|
|
2342 |
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
if (empty($cdata)) {
|
2386 |
-
wp_die(__("Invalid Chat ID", 'wp-live-chat-support'));
|
2387 |
-
}
|
2388 |
-
|
2389 |
-
$other = maybe_unserialize($cdata->other);
|
2390 |
-
|
2391 |
-
if ($wplc_settings['wplc_use_node_server']) {
|
2392 |
-
if (isset($other['socket']) && ($other['socket'] == true || $other['socket'] == "true")) {
|
2393 |
-
wp_localize_script('wplc-admin-chat-server', 'tcx_api_key', wplc_node_server_token_get());
|
2394 |
-
}
|
2395 |
-
}
|
2396 |
-
|
2397 |
-
/**
|
2398 |
-
* Create a JS object for all Agent ID's and Gravatar MD5's
|
2399 |
-
*/
|
2400 |
-
$user_array = wplc_get_agent_users();
|
2401 |
-
$a_array = array();
|
2402 |
-
foreach ($user_array as $user) {
|
2403 |
-
$a_array[$user->ID] = array();
|
2404 |
-
$a_array[$user->ID]['name'] = sanitize_text_field($user->display_name);
|
2405 |
-
$a_array[$user->ID]['md5'] = md5( $user->user_email );
|
2406 |
-
}
|
2407 |
-
wp_localize_script('wplc-admin-chat-server', 'wplc_agent_data', $a_array);
|
2408 |
-
|
2409 |
-
/**
|
2410 |
-
* Get the CURRENT agent's data
|
2411 |
-
*/
|
2412 |
-
if (isset($_GET['aid'])) {
|
2413 |
-
$agent_data = get_user_by('ID', intval($_GET['aid']));
|
2414 |
-
wp_localize_script('wplc-admin-chat-server', 'wplc_admin_agent_name', sanitize_text_field($agent_data->display_name));
|
2415 |
-
wp_localize_script('wplc-admin-chat-server', 'wplc_admin_agent_email', md5($agent_data->user_email));
|
2416 |
-
} else {
|
2417 |
-
$agent_data = get_user_by('ID', intval(get_current_user_id()));
|
2418 |
-
wp_localize_script('wplc-admin-chat-server', 'wplc_admin_agent_name', sanitize_text_field($agent_data->display_name));
|
2419 |
-
wp_localize_script('wplc-admin-chat-server', 'wplc_admin_agent_email', md5($agent_data->user_email));
|
2420 |
-
}
|
2421 |
-
|
2422 |
-
if (!empty($_REQUEST['action']) && $_REQUEST['action']=='history') {
|
2423 |
-
// do not load if displaying chat history
|
2424 |
-
} else {
|
2425 |
-
wp_register_script('wplc-admin-chat-js', plugins_url('js/wplc_u_admin_chat.js', __FILE__), array('wplc-admin-chat-server'), WPLC_PLUGIN_VERSION, false);
|
2426 |
-
wp_enqueue_script('wplc-admin-chat-js');
|
2427 |
-
}
|
2428 |
-
|
2429 |
-
|
2430 |
-
$wplc_theme = wplc_get_theme();
|
2431 |
-
|
2432 |
-
switch($wplc_theme) {
|
2433 |
-
case 'theme-default':
|
2434 |
-
wp_register_style('wplc-theme-palette-default', plugins_url('/css/themes/theme-default.css', __FILE__), array(), WPLC_PLUGIN_VERSION);
|
2435 |
-
wp_enqueue_style('wplc-theme-palette-default');
|
2436 |
-
break;
|
2437 |
-
case 'theme-1':
|
2438 |
-
case 'theme-2':
|
2439 |
-
case 'theme-3':
|
2440 |
-
case 'theme-4':
|
2441 |
-
case 'theme-5':
|
2442 |
-
$tid = substr($wplc_theme,-1,1);
|
2443 |
-
wp_register_style('wplc-theme-palette-'.$tid, plugins_url('/css/themes/theme-'.$tid.'.css', __FILE__), array(), WPLC_PLUGIN_VERSION);
|
2444 |
-
wp_enqueue_style('wplc-theme-palette-'.$tid);
|
2445 |
-
break;
|
2446 |
-
case 'theme-6':
|
2447 |
-
/* custom */
|
2448 |
-
/* handled elsewhere */
|
2449 |
-
break;
|
2450 |
-
}
|
2451 |
-
|
2452 |
-
if (isset($cdata->agent_id)) {
|
2453 |
-
$wplc_agent_data = get_user_by( 'id', intval( $cdata->agent_id ) );
|
2454 |
-
}
|
2455 |
-
|
2456 |
-
$wplc_chat_detail = array(
|
2457 |
-
'name' => $wplc_settings['wplc_show_name'],
|
2458 |
-
'avatar' => $wplc_settings['wplc_show_avatar'],
|
2459 |
-
'date' => $wplc_settings['wplc_show_date'],
|
2460 |
-
'time' => $wplc_settings['wplc_show_time']
|
2461 |
-
);
|
2462 |
-
|
2463 |
-
wp_enqueue_script('wplc-admin-chat-js');
|
2464 |
-
wp_localize_script( 'wplc-admin-chat-js', 'wplc_show_chat_detail', $wplc_chat_detail );
|
2465 |
-
|
2466 |
-
if (!empty($wplc_agent_data)) {
|
2467 |
-
wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_name', sanitize_text_field($wplc_agent_data->display_name) );
|
2468 |
-
wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_email', md5( $wplc_agent_data->user_email ) );
|
2469 |
-
} else {
|
2470 |
-
wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_name', null );
|
2471 |
-
wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_email', null );
|
2472 |
-
}
|
2473 |
-
|
2474 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_chat_name', sanitize_text_field($cdata->name));
|
2475 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_chat_email', md5($cdata->email));
|
2476 |
-
|
2477 |
-
if (class_exists("WP_REST_Request")) {
|
2478 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_restapi_enabled', array('value'=>true));
|
2479 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_restapi_token', get_option('wplc_api_secret_token'));
|
2480 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_restapi_endpoint', rest_url('wp_live_chat_support/v1'));
|
2481 |
-
} else {
|
2482 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_restapi_enabled', array('value'=>false));
|
2483 |
-
}
|
2484 |
-
|
2485 |
-
$src = wplc_get_admin_picture();
|
2486 |
-
if ($src) {
|
2487 |
-
$image = "<img src=" . $src . " width='20px' id='wp-live-chat-2-img'/>";
|
2488 |
-
} else {
|
2489 |
-
$image = " ";
|
2490 |
-
}
|
2491 |
-
|
2492 |
-
$admin_pic = $image;
|
2493 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_localized_string_is_typing', __("is typing...",'wp-live-chat-support'));
|
2494 |
-
wp_localize_script('wplc-user-script', 'wplc_localized_string_admin_name', apply_filters( 'wplc_filter_admin_name', 'Admin' ) );
|
2495 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_ajax_nonce', $ajax_nonce);
|
2496 |
-
wp_localize_script('wplc-admin-chat-js', 'admin_pic', $admin_pic);
|
2497 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_ding_file', apply_filters('wplc_filter_message_sound', ''));
|
2498 |
-
|
2499 |
-
$extra_data = apply_filters("wplc_filter_admin_javascript",array());
|
2500 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_extra_data', $extra_data);
|
2501 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_enable_ding', array('value'=>boolval($wplc_settings['wplc_enable_msg_sound'])));
|
2502 |
-
|
2503 |
-
$ajax_url = admin_url('admin-ajax.php');
|
2504 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_ajaxurl', apply_filters("wplc_filter_ajax_url",$ajax_url));
|
2505 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_home_ajaxurl', $ajax_url);
|
2506 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_url', admin_url('admin.php?page=wplivechat-menu&action=ac&cid=' . $cid));
|
2507 |
-
|
2508 |
-
$wplc_string1 = __("User has opened the chat window", 'wp-live-chat-support');
|
2509 |
-
$wplc_string2 = __("User has minimized the chat window", 'wp-live-chat-support');
|
2510 |
-
$wplc_string3 = __("User has maximized the chat window", 'wp-live-chat-support');
|
2511 |
-
$wplc_string4 = __("The chat has been ended", 'wp-live-chat-support');
|
2512 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_string1', $wplc_string1);
|
2513 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_string2', $wplc_string2);
|
2514 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_string3', $wplc_string3);
|
2515 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_string4', $wplc_string4);
|
2516 |
-
wp_localize_script('wplc-admin-chat-js', 'wplc_cid', $cid);
|
2517 |
-
do_action("wplc_hook_admin_chatbox_javascript");
|
2518 |
}
|
2519 |
|
2520 |
function wplc_activate() {
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
|
2544 |
-
|
2545 |
-
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
|
|
|
|
|
2553 |
}
|
2554 |
|
2555 |
|
@@ -2558,11 +2811,11 @@ function wplc_activate() {
|
|
2558 |
* @return void
|
2559 |
* @since 1.0.00
|
2560 |
*/
|
2561 |
-
if (!function_exists("wplc_choose_activate")) {
|
2562 |
-
register_activation_hook(__FILE__, 'wplc_choose_activate');
|
2563 |
function wplc_choose_activate( $networkwide ) {
|
2564 |
-
|
2565 |
-
|
2566 |
}
|
2567 |
}
|
2568 |
|
@@ -2571,20 +2824,20 @@ if (!function_exists("wplc_choose_activate")) {
|
|
2571 |
* @return void
|
2572 |
* @since 1.0.00
|
2573 |
*/
|
2574 |
-
if (!function_exists("wplc_choose_deactivate")) {
|
2575 |
-
register_deactivation_hook(__FILE__, 'wplc_choose_deactivate');
|
2576 |
function wplc_choose_deactivate() {
|
2577 |
-
|
2578 |
}
|
2579 |
}
|
2580 |
|
2581 |
function wplc_handle_db() {
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
|
2587 |
-
|
2588 |
CREATE TABLE " . $wplc_tblname_chats . " (
|
2589 |
id int(11) NOT NULL AUTO_INCREMENT,
|
2590 |
timestamp datetime NOT NULL,
|
@@ -2602,12 +2855,11 @@ function wplc_handle_db() {
|
|
2602 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
2603 |
";
|
2604 |
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
|
2610 |
-
|
|
|
2611 |
CREATE TABLE ' . $wplc_tblname_msgs . ' (
|
2612 |
id int(11) NOT NULL AUTO_INCREMENT,
|
2613 |
chat_sess_id int(11) NOT NULL,
|
@@ -2624,22 +2876,24 @@ function wplc_handle_db() {
|
|
2624 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
2625 |
';
|
2626 |
|
2627 |
-
|
2628 |
-
|
2629 |
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
|
2639 |
-
|
|
|
|
|
2640 |
|
2641 |
|
2642 |
-
|
2643 |
CREATE TABLE " . $wplc_tblname_offline_msgs . " (
|
2644 |
id int(11) NOT NULL AUTO_INCREMENT,
|
2645 |
timestamp datetime NOT NULL,
|
@@ -2652,124 +2906,127 @@ function wplc_handle_db() {
|
|
2652 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
2653 |
";
|
2654 |
|
2655 |
-
|
2656 |
-
|
2657 |
|
2658 |
-
|
2659 |
-
|
2660 |
}
|
2661 |
|
2662 |
function wplc_add_user_stylesheet() {
|
2663 |
-
|
2664 |
-
|
2665 |
-
|
2666 |
-
|
2667 |
-
|
2668 |
-
|
2669 |
-
|
2670 |
-
|
2671 |
-
|
2672 |
-
|
2673 |
-
|
2674 |
-
|
2675 |
-
|
2676 |
-
|
2677 |
-
|
2678 |
-
|
2679 |
-
|
2680 |
-
|
2681 |
-
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
|
2730 |
-
|
2731 |
-
|
2732 |
-
|
2733 |
-
|
2734 |
-
|
2735 |
-
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
-
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
|
|
|
|
|
|
2773 |
|
2774 |
}
|
2775 |
|
@@ -2779,14 +3036,25 @@ add_action( 'init', 'wplc_online_check_script', 10 );
|
|
2779 |
* @return void
|
2780 |
*/
|
2781 |
function wplc_online_check_script() {
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
|
2788 |
-
|
2789 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2790 |
}
|
2791 |
|
2792 |
/**
|
@@ -2796,12 +3064,13 @@ function wplc_online_check_script() {
|
|
2796 |
add_filter( 'heartbeat_received', 'wplc_heartbeat_receive', 10, 2 );
|
2797 |
add_filter( 'heartbeat_nopriv_received', 'wplc_heartbeat_receive', 10, 2 );
|
2798 |
function wplc_heartbeat_receive( $response, $data ) {
|
2799 |
-
|
2800 |
-
|
2801 |
-
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
|
|
2805 |
}
|
2806 |
|
2807 |
/**
|
@@ -2809,87 +3078,87 @@ function wplc_heartbeat_receive( $response, $data ) {
|
|
2809 |
* @return void
|
2810 |
*/
|
2811 |
function wplc_add_admin_stylesheet() {
|
2812 |
-
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
|
2820 |
-
|
2821 |
-
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
|
2827 |
-
|
2828 |
-
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
|
2834 |
-
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
|
2840 |
-
|
2841 |
-
|
2842 |
-
|
2843 |
-
|
2844 |
-
|
2845 |
-
|
2846 |
-
|
2847 |
-
|
2848 |
-
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
|
2855 |
-
|
2856 |
-
|
2857 |
-
|
2858 |
-
|
2859 |
-
|
2860 |
-
|
2861 |
-
|
2862 |
-
|
2863 |
-
|
2864 |
-
|
2865 |
-
|
2866 |
-
|
2867 |
-
|
2868 |
-
|
2869 |
-
|
2870 |
-
|
2871 |
-
|
2872 |
-
|
2873 |
-
|
2874 |
-
|
2875 |
-
|
2876 |
-
|
2877 |
-
|
2878 |
-
|
2879 |
-
|
2880 |
-
|
2881 |
-
|
2882 |
-
|
2883 |
-
|
2884 |
-
|
2885 |
-
|
2886 |
-
|
2887 |
-
|
2888 |
-
|
2889 |
-
}
|
2890 |
-
|
2891 |
-
if (isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu-settings') {
|
2892 |
-
|
2893 |
}
|
2894 |
|
2895 |
/**
|
@@ -2898,27 +3167,27 @@ if (isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu-settings') {
|
|
2898 |
*/
|
2899 |
function wplc_admin_scripts() {
|
2900 |
|
2901 |
-
$gutenberg_default_html = '<!-- Default HTML -->
|
2902 |
<div class="wplc_block">
|
2903 |
<span class="wplc_block_logo">{wplc_logo}</span>
|
2904 |
<span class="wplc_block_text">{wplc_text}</span>
|
2905 |
<span class="wplc_block_icon">{wplc_icon}</span>
|
2906 |
</div>';
|
2907 |
-
|
2908 |
-
|
2909 |
-
|
2910 |
-
|
2911 |
-
|
2912 |
-
|
2913 |
-
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
|
2919 |
-
|
2920 |
-
|
2921 |
-
|
2922 |
}
|
2923 |
|
2924 |
/**
|
@@ -2926,7 +3195,7 @@ $gutenberg_default_html = '<!-- Default HTML -->
|
|
2926 |
* @return void
|
2927 |
*/
|
2928 |
function wplc_admin_settings_layout() {
|
2929 |
-
|
2930 |
}
|
2931 |
|
2932 |
/**
|
@@ -2934,164 +3203,170 @@ function wplc_admin_settings_layout() {
|
|
2934 |
* @return void
|
2935 |
*/
|
2936 |
function wplc_admin_dashboard_layout() {
|
2937 |
-
|
2938 |
}
|
2939 |
|
2940 |
-
add_action("wplc_hook_history_draw_area","wplc_hook_control_history_draw_area",10,1);
|
2941 |
/**
|
2942 |
* Display normal history page
|
2943 |
-
*
|
|
|
|
|
2944 |
* @return void
|
2945 |
* @since 6.1.00
|
2946 |
*/
|
2947 |
-
function wplc_hook_control_history_draw_area($cid) {
|
2948 |
-
|
2949 |
}
|
2950 |
|
2951 |
/**
|
2952 |
* What to display for the chat history
|
2953 |
-
*
|
|
|
|
|
2954 |
* @return void
|
2955 |
* @since 6.1.00
|
2956 |
*/
|
2957 |
-
function wplc_admin_view_chat_history($cid) {
|
2958 |
-
|
2959 |
}
|
2960 |
|
2961 |
|
2962 |
-
add_action( 'wplc_hook_admin_menu_layout_display'
|
2963 |
/**
|
2964 |
* Control history GET calls
|
2965 |
-
*
|
2966 |
-
* @param
|
2967 |
-
* @param
|
|
|
|
|
2968 |
* @return void
|
2969 |
* @since 6.1.00
|
2970 |
*/
|
2971 |
-
function wplc_hook_control_history_get_control($action
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2972 |
|
2973 |
-
|
2974 |
-
if (!isset($_GET['wplc_history_nonce']) || !wp_verify_nonce($_GET['wplc_history_nonce'], 'wplc_history_nonce')){
|
2975 |
-
wp_die(__("You do not have permission do perform this action", 'wp-live-chat-support'));
|
2976 |
-
}
|
2977 |
-
wplc_admin_view_chat_history(sanitize_text_field($cid));
|
2978 |
-
} else if ($action == 'download_history'){
|
2979 |
-
|
2980 |
-
}
|
2981 |
|
2982 |
|
2983 |
}
|
2984 |
|
2985 |
|
2986 |
-
add_action("wplc_hook_chat_history","wplc_hook_control_chat_history");
|
2987 |
/**
|
2988 |
* Renders the chat history content
|
2989 |
* @return string
|
2990 |
*/
|
2991 |
function wplc_hook_control_chat_history() {
|
2992 |
-
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
|
3008 |
-
|
3009 |
-
|
3010 |
-
|
3011 |
-
|
3012 |
-
|
3013 |
-
|
3014 |
-
|
3015 |
-
|
3016 |
-
|
3017 |
-
|
3018 |
-
|
3019 |
-
|
3020 |
-
|
3021 |
-
|
3022 |
-
|
3023 |
-
|
3024 |
-
|
3025 |
-
|
3026 |
-
|
3027 |
-
|
3028 |
-
|
3029 |
-
|
3030 |
-
|
3031 |
-
|
3032 |
SELECT * FROM $wplc_tblname_chats
|
3033 |
WHERE `name` NOT LIKE 'agent-to-agent chat'
|
3034 |
AND (`status` = 1 OR `status` = 2 OR `status` = 3 OR `status` = 6 OR `status` = 8)
|
3035 |
ORDER BY `timestamp` DESC
|
3036 |
LIMIT %d OFFSET %d
|
3037 |
-
", $limit, $offset)
|
3038 |
-
|
3039 |
-
|
3040 |
-
<input type=\"submit\" value=\"".__('Delete History', 'wp-live-chat-support')."\" class='button' id=\"wplc-delete-chat-history\" name=\"wplc-delete-chat-history\" /><br /><br />
|
3041 |
</form>
|
3042 |
|
3043 |
<table class=\"wp-list-table wplc_list_table widefat fixed \" cellspacing=\"0\">
|
3044 |
<thead>
|
3045 |
<tr>
|
3046 |
-
<th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><span>" . __("Date", 'wp-live-chat-support') . "</span></th>
|
3047 |
-
<th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><span>" . __("Name", 'wp-live-chat-support') . "</span></th>
|
3048 |
-
<th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\">" . __("Email", 'wp-live-chat-support') . "</th>
|
3049 |
-
<th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\">" . __("URL", 'wp-live-chat-support') . "</th>
|
3050 |
-
<th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\">" . __("Status", 'wp-live-chat-support') . "</th>
|
3051 |
-
<th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><span>" . __("Action", 'wp-live-chat-support') . "</span></th>
|
3052 |
</tr>
|
3053 |
</thead>
|
3054 |
<tbody id=\"the-list\" class='list:wp_list_text_link'>";
|
3055 |
-
|
3056 |
-
|
3057 |
-
|
3058 |
-
|
3059 |
-
|
3060 |
-
|
3061 |
-
|
3062 |
-
|
3063 |
-
|
3064 |
-
|
3065 |
-
|
3066 |
-
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
|
3071 |
-
|
3072 |
-
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
|
3077 |
-
|
3078 |
-
|
3079 |
-
|
3080 |
-
|
3081 |
-
|
3082 |
-
|
3083 |
-
|
3084 |
-
|
3085 |
-
|
3086 |
-
|
3087 |
-
|
3088 |
-
|
3089 |
-
|
3090 |
-
|
3091 |
-
|
3092 |
-
|
3093 |
-
|
3094 |
-
|
3095 |
}
|
3096 |
|
3097 |
/**
|
@@ -3099,20 +3374,22 @@ function wplc_hook_control_chat_history() {
|
|
3099 |
* @return string
|
3100 |
*/
|
3101 |
function wplc_admin_history_layout() {
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
}
|
3107 |
|
3108 |
|
3109 |
-
add_action("wplc_hook_chat_missed","wplc_hook_control_missed_chats",10);
|
3110 |
/**
|
3111 |
* Loads missed chats contents
|
3112 |
* @return string
|
3113 |
*/
|
3114 |
function wplc_hook_control_missed_chats() {
|
3115 |
-
|
|
|
|
|
3116 |
}
|
3117 |
|
3118 |
/**
|
@@ -3120,18 +3397,18 @@ function wplc_hook_control_missed_chats() {
|
|
3120 |
* @return string
|
3121 |
*/
|
3122 |
function wplc_admin_missed_chats() {
|
3123 |
-
|
3124 |
-
|
3125 |
-
|
3126 |
}
|
3127 |
|
3128 |
-
add_action("wplc_hook_offline_messages_display","wplc_hook_control_offline_messages_display",10);
|
3129 |
/**
|
3130 |
* Loads the offline messages page contents
|
3131 |
* @return string
|
3132 |
*/
|
3133 |
function wplc_hook_control_offline_messages_display() {
|
3134 |
-
|
3135 |
}
|
3136 |
|
3137 |
/**
|
@@ -3139,9 +3416,9 @@ function wplc_hook_control_offline_messages_display() {
|
|
3139 |
* @return void
|
3140 |
*/
|
3141 |
function wplc_admin_offline_messages() {
|
3142 |
-
|
3143 |
-
|
3144 |
-
|
3145 |
}
|
3146 |
|
3147 |
/**
|
@@ -3150,55 +3427,55 @@ function wplc_admin_offline_messages() {
|
|
3150 |
*/
|
3151 |
function wplc_admin_display_offline_messages() {
|
3152 |
|
3153 |
-
|
3154 |
-
|
3155 |
|
3156 |
-
|
3157 |
<table class=\"wp-list-table wplc_list_table widefat \" cellspacing=\"0\">
|
3158 |
<thead>
|
3159 |
<tr>
|
3160 |
-
<th class='manage-column column-id' style='width: 15%'><span>" . __("Date", 'wp-live-chat-support') . "</span></th>
|
3161 |
-
<th scope='col' id='wplc_name_colum' class='manage-column column-id' style='width: 10%'><span>" . __("Name", 'wp-live-chat-support') . "</span></th>
|
3162 |
-
<th scope='col' id='wplc_email_colum' class='manage-column column-id' style='width: 15%'>" . __("Email", 'wp-live-chat-support') . "</th>
|
3163 |
-
<th scope='col' id='wplc_message_colum' class='manage-column column-id' style='width: 40%'>" . __("Message", 'wp-live-chat-support') . "</th>
|
3164 |
-
<th scope='col' id='wplc_message_colum' class='manage-column column-id' style='width: 10%'>" . __("Actions", 'wp-live-chat-support') . "</th>
|
3165 |
</tr>
|
3166 |
</thead>
|
3167 |
<tbody id=\"the-list\" class='list:wp_list_text_link'>";
|
3168 |
|
3169 |
-
$pagenum
|
3170 |
-
$limit
|
3171 |
-
$offset
|
3172 |
-
$total
|
3173 |
$num_of_pages = ceil( $total / $limit );
|
3174 |
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
|
3183 |
-
|
3184 |
-
|
3185 |
-
|
3186 |
-
|
3187 |
-
|
3188 |
-
|
3189 |
-
|
3190 |
-
|
3191 |
-
|
3192 |
</tbody>
|
3193 |
</table>";
|
3194 |
|
3195 |
$page_links = paginate_links( array(
|
3196 |
-
'base'
|
3197 |
-
'format'
|
3198 |
'prev_text' => '«',
|
3199 |
'next_text' => '»',
|
3200 |
-
'total'
|
3201 |
-
'current'
|
3202 |
) );
|
3203 |
|
3204 |
if ( $page_links ) {
|
@@ -3211,90 +3488,95 @@ function wplc_admin_display_offline_messages() {
|
|
3211 |
* @return string
|
3212 |
*/
|
3213 |
function wplc_settings_page() {
|
3214 |
-
|
3215 |
}
|
3216 |
|
3217 |
/**
|
3218 |
* Updates chat statistics
|
3219 |
-
*
|
|
|
|
|
3220 |
* @return void
|
3221 |
*/
|
3222 |
-
function wplc_stats($sec) {
|
3223 |
-
|
3224 |
-
|
3225 |
-
|
3226 |
-
|
3227 |
-
|
3228 |
-
|
3229 |
-
|
3230 |
-
|
3231 |
-
|
3232 |
-
|
3233 |
|
3234 |
|
3235 |
-
|
3236 |
|
3237 |
-
|
3238 |
-
|
3239 |
-
|
3240 |
|
3241 |
|
3242 |
-
|
3243 |
-
|
3244 |
|
3245 |
}
|
3246 |
|
3247 |
|
3248 |
-
add_action("wplc_hook_head","wplc_hook_control_head");
|
3249 |
/**
|
3250 |
* Deletes the chat history on submission of POST
|
3251 |
* @return bool
|
3252 |
*/
|
3253 |
function wplc_hook_control_head() {
|
3254 |
-
|
3255 |
-
|
3256 |
-
|
3257 |
}
|
3258 |
|
3259 |
/**
|
3260 |
* Deletes all chat history
|
3261 |
* @return bool
|
3262 |
*/
|
3263 |
-
function wplc_del_history(){
|
3264 |
-
|
3265 |
-
|
3266 |
-
|
3267 |
-
|
3268 |
-
|
3269 |
}
|
3270 |
|
3271 |
-
add_filter("wplc_filter_chat_header_extra_attr","wplc_filter_control_chat_header_extra_attr",10,1);
|
3272 |
/**
|
3273 |
* Controls if the chat window should popup or not
|
3274 |
-
*
|
|
|
|
|
3275 |
* @return string
|
3276 |
*/
|
3277 |
-
function wplc_filter_control_chat_header_extra_attr($wplc_extra_attr) {
|
3278 |
-
|
3279 |
-
|
3280 |
-
|
3281 |
-
|
3282 |
-
|
3283 |
-
|
3284 |
-
|
3285 |
-
|
3286 |
-
|
3287 |
-
|
3288 |
-
|
3289 |
-
|
3290 |
-
|
3291 |
-
|
3292 |
-
|
3293 |
-
|
3294 |
-
|
3295 |
-
|
3296 |
-
|
3297 |
-
|
|
|
3298 |
}
|
3299 |
|
3300 |
/**
|
@@ -3302,332 +3584,338 @@ function wplc_filter_control_chat_header_extra_attr($wplc_extra_attr) {
|
|
3302 |
* @return string
|
3303 |
*/
|
3304 |
function wplc_head() {
|
3305 |
-
|
3306 |
-
|
3307 |
-
|
3308 |
-
|
3309 |
-
|
3310 |
-
?>
|
3311 |
-
<div class='notice notice-warning wplc_settings_save_notice'>
|
3312 |
-
<?php _e("You do not have permission to save settings.", 'wp-live-chat-support'); ?>
|
3313 |
-
</div>
|
3314 |
-
<?php
|
3315 |
-
|
3316 |
-
|
3317 |
-
|
3318 |
-
|
3319 |
-
|
3320 |
-
|
3321 |
-
|
3322 |
-
|
3323 |
-
|
3324 |
-
|
3325 |
-
|
3326 |
-
|
3327 |
-
|
3328 |
-
|
3329 |
-
|
3330 |
-
|
3331 |
-
|
3332 |
-
|
3333 |
-
|
3334 |
-
|
3335 |
-
|
3336 |
-
|
3337 |
-
|
3338 |
-
|
3339 |
-
|
3340 |
-
|
3341 |
-
|
3342 |
-
|
3343 |
-
|
3344 |
-
|
3345 |
-
|
3346 |
-
|
3347 |
-
|
3348 |
-
|
3349 |
-
|
3350 |
-
|
3351 |
-
|
3352 |
-
|
3353 |
-
|
3354 |
-
|
3355 |
-
|
3356 |
-
|
3357 |
-
|
3358 |
-
|
3359 |
-
|
3360 |
-
|
3361 |
-
|
3362 |
-
|
3363 |
-
|
3364 |
-
|
3365 |
-
|
3366 |
-
|
3367 |
-
|
3368 |
-
|
3369 |
-
|
3370 |
-
|
3371 |
-
|
3372 |
-
|
3373 |
-
|
3374 |
-
|
3375 |
-
|
3376 |
-
|
3377 |
-
|
3378 |
-
|
3379 |
-
|
3380 |
-
|
3381 |
-
|
3382 |
-
|
3383 |
-
|
3384 |
-
|
3385 |
-
|
3386 |
-
|
3387 |
-
|
3388 |
-
|
3389 |
-
|
3390 |
-
|
3391 |
-
|
3392 |
-
|
3393 |
-
|
3394 |
-
|
3395 |
-
|
3396 |
-
|
3397 |
-
|
3398 |
-
|
3399 |
-
|
3400 |
-
|
3401 |
-
|
3402 |
-
|
3403 |
-
|
3404 |
-
|
3405 |
-
|
3406 |
-
|
3407 |
-
|
3408 |
-
|
3409 |
-
|
3410 |
-
|
3411 |
-
|
3412 |
-
|
3413 |
-
|
3414 |
-
|
3415 |
-
|
3416 |
-
|
3417 |
-
|
3418 |
-
|
3419 |
-
|
3420 |
-
|
3421 |
-
|
3422 |
-
|
3423 |
-
|
3424 |
-
|
3425 |
-
|
3426 |
-
|
3427 |
-
|
3428 |
-
|
3429 |
-
|
3430 |
-
|
3431 |
-
|
3432 |
-
|
3433 |
-
|
3434 |
-
|
3435 |
-
|
3436 |
-
|
3437 |
-
|
3438 |
-
|
3439 |
-
|
3440 |
-
|
3441 |
-
|
3442 |
-
|
3443 |
-
|
3444 |
-
|
3445 |
-
|
3446 |
-
|
3447 |
-
|
3448 |
-
|
3449 |
-
|
3450 |
-
|
3451 |
-
|
3452 |
-
|
3453 |
-
|
3454 |
-
|
3455 |
-
|
3456 |
-
|
3457 |
-
|
3458 |
-
|
3459 |
-
|
3460 |
-
|
3461 |
-
|
3462 |
-
|
3463 |
-
|
3464 |
-
|
3465 |
-
|
3466 |
-
|
3467 |
-
|
3468 |
-
|
3469 |
-
|
3470 |
-
|
3471 |
-
|
3472 |
-
|
3473 |
-
|
3474 |
-
|
3475 |
-
|
3476 |
-
|
3477 |
-
|
3478 |
-
|
3479 |
-
|
3480 |
-
|
3481 |
-
|
3482 |
-
|
3483 |
-
|
3484 |
-
|
3485 |
-
|
3486 |
-
|
3487 |
-
|
3488 |
-
|
3489 |
-
|
3490 |
-
|
3491 |
-
|
3492 |
-
|
3493 |
-
|
3494 |
-
|
3495 |
-
|
3496 |
-
|
3497 |
-
|
3498 |
-
|
3499 |
-
|
3500 |
-
|
3501 |
-
|
3502 |
-
|
3503 |
-
|
3504 |
-
|
3505 |
-
|
3506 |
-
|
3507 |
-
|
3508 |
-
|
3509 |
-
|
3510 |
-
|
3511 |
-
|
3512 |
-
|
3513 |
-
|
3514 |
-
|
3515 |
-
|
3516 |
-
|
3517 |
-
|
3518 |
-
|
3519 |
-
|
3520 |
-
|
3521 |
-
|
3522 |
-
|
3523 |
-
|
3524 |
-
|
3525 |
-
|
3526 |
-
|
3527 |
-
|
3528 |
-
|
3529 |
-
|
3530 |
-
|
3531 |
-
|
3532 |
-
|
3533 |
-
|
3534 |
-
|
3535 |
-
|
3536 |
-
|
3537 |
-
|
3538 |
-
|
3539 |
-
|
3540 |
-
|
3541 |
-
|
3542 |
-
|
3543 |
-
|
3544 |
-
|
3545 |
-
|
3546 |
-
|
3547 |
-
|
3548 |
-
|
3549 |
-
|
3550 |
-
|
3551 |
-
|
3552 |
-
|
3553 |
-
|
3554 |
-
|
3555 |
-
|
3556 |
-
|
3557 |
-
|
3558 |
-
|
3559 |
-
|
3560 |
-
|
3561 |
-
|
3562 |
-
|
3563 |
-
|
3564 |
-
|
3565 |
-
|
3566 |
-
|
3567 |
-
|
3568 |
-
|
3569 |
-
|
3570 |
-
|
3571 |
-
|
3572 |
-
|
3573 |
-
|
3574 |
-
|
3575 |
-
|
3576 |
-
|
3577 |
-
|
3578 |
-
|
3579 |
-
|
3580 |
-
|
3581 |
-
|
3582 |
-
|
3583 |
-
|
3584 |
-
|
3585 |
-
|
3586 |
-
|
3587 |
-
|
3588 |
-
|
3589 |
-
|
3590 |
-
|
3591 |
-
|
3592 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
3593 |
}
|
3594 |
|
3595 |
function wplc_save_settings_action() { ?>
|
3596 |
<div class='notice notice-success updated wplc_settings_save_notice'>
|
3597 |
-
<?php _e("Your settings have been saved.", 'wp-live-chat-support'); ?>
|
3598 |
</div>
|
3599 |
<?php }
|
3600 |
|
3601 |
/**
|
3602 |
* Error checks used to ensure the user's resources meet the plugin's requirements
|
3603 |
*/
|
3604 |
-
if(isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu-settings'){
|
3605 |
-
|
3606 |
-
|
3607 |
-
|
3608 |
-
|
3609 |
-
|
3610 |
-
|
3611 |
-
|
3612 |
-
|
3613 |
-
|
3614 |
-
|
3615 |
-
<p>".__("WPLC: set_time_limit() is not enabled on this server. You may experience issues while using WP Live Chat by 3CX as a result of this. Please get in contact your host to get this function enabled.", 'wp-live-chat-support')."</p>
|
3616 |
";
|
3617 |
-
|
3618 |
-
|
3619 |
-
|
3620 |
-
|
3621 |
-
<p>".__("WPLC: Safe mode is enabled on this server. You may experience issues while using WP Live Chat by 3CX as a result of this. Please contact your host to get safe mode disabled.", 'wp-live-chat-support')."</p>
|
3622 |
";
|
3623 |
-
|
3624 |
-
|
3625 |
-
|
3626 |
-
|
3627 |
-
|
3628 |
-
|
3629 |
-
|
3630 |
-
|
3631 |
}
|
3632 |
|
3633 |
/**
|
@@ -3635,193 +3923,262 @@ if(isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu-settings'){
|
|
3635 |
* @return string
|
3636 |
*/
|
3637 |
function wplc_support_menu() {
|
3638 |
-
|
3639 |
-
?>
|
3640 |
-
<div class="wrap wplc_wrap">
|
3641 |
-
|
3642 |
-
|
3643 |
-
|
3644 |
-
|
3645 |
-
|
3646 |
-
|
3647 |
-
|
3648 |
-
|
3649 |
-
|
3650 |
-
|
3651 |
-
|
3652 |
-
|
3653 |
-
|
3654 |
-
|
3655 |
-
|
3656 |
-
|
3657 |
-
|
3658 |
-
|
3659 |
-
|
3660 |
-
|
3661 |
-
|
3662 |
-
|
3663 |
-
|
3664 |
-
|
3665 |
-
|
3666 |
-
|
3667 |
-
|
3668 |
-
|
3669 |
-
|
3670 |
-
|
3671 |
-
|
3672 |
-
|
3673 |
-
|
3674 |
-
|
3675 |
-
|
3676 |
-
|
3677 |
-
|
3678 |
-
|
3679 |
-
|
3680 |
-
|
3681 |
-
|
3682 |
-
|
3683 |
-
|
3684 |
-
|
3685 |
-
|
3686 |
-
|
3687 |
-
|
3688 |
-
|
3689 |
-
|
3690 |
-
|
3691 |
-
|
3692 |
-
|
3693 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3694 |
</div>
|
3695 |
</div>
|
3696 |
-
|
3697 |
-
<?php
|
3698 |
}
|
3699 |
|
3700 |
//if (!function_exists("wplc_ic_initiate_chat_button")) { TODO: check why
|
3701 |
-
|
3702 |
//}
|
3703 |
/**
|
3704 |
* Displays the pointers on the live chat dashboard for the initiate chat functionality
|
3705 |
-
*
|
|
|
|
|
3706 |
* @return string contents of the pointers and their scripts
|
3707 |
*/
|
3708 |
-
function wp_button_pointers_load_scripts($hook) {
|
3709 |
-
|
3710 |
-
|
3711 |
-
|
3712 |
-
|
3713 |
-
|
3714 |
-
|
3715 |
-
|
3716 |
-
|
3717 |
-
|
3718 |
-
|
3719 |
-
|
3720 |
-
|
3721 |
-
|
3722 |
-
|
3723 |
-
|
3724 |
-
|
3725 |
-
|
3726 |
-
|
3727 |
-
|
3728 |
-
|
3729 |
-
|
3730 |
-
|
|
|
|
|
3731 |
}
|
3732 |
|
3733 |
add_filter( 'admin_footer_text', 'wplc_footer_mod' );
|
3734 |
/**
|
3735 |
* Adds the WP Live Chat by 3CX footer contents to the relevant pages
|
3736 |
-
*
|
|
|
|
|
3737 |
* @return string footer contents with our branding in it
|
3738 |
*/
|
3739 |
function wplc_footer_mod( $footer_text ) {
|
3740 |
-
|
3741 |
-
|
3742 |
-
|
3743 |
-
|
3744 |
-
|
3745 |
-
|
|
|
3746 |
|
3747 |
}
|
3748 |
|
3749 |
-
add_filter("wplc_filter_admin_long_poll_chat_loop_iteration","wplc_filter_control_wplc_admin_long_poll_chat_iteration", 1, 3);
|
3750 |
/**
|
3751 |
* Alters the admin's long poll chat iteration
|
3752 |
-
*
|
3753 |
-
* @param
|
3754 |
-
* @param
|
|
|
|
|
3755 |
* @return array additional contents added to the chat data
|
3756 |
*/
|
3757 |
-
function wplc_filter_control_wplc_admin_long_poll_chat_iteration($array
|
3758 |
-
|
3759 |
-
|
3760 |
-
|
3761 |
-
|
3762 |
-
|
3763 |
-
|
3764 |
|
3765 |
-
|
3766 |
-
|
3767 |
-
|
3768 |
-
|
3769 |
|
3770 |
-
|
3771 |
|
3772 |
-
|
3773 |
-
|
3774 |
-
|
3775 |
-
|
3776 |
-
|
3777 |
-
|
3778 |
|
3779 |
-
|
3780 |
|
3781 |
-
|
3782 |
-
|
3783 |
-
|
3784 |
-
|
3785 |
-
|
3786 |
|
3787 |
-
|
3788 |
}
|
3789 |
|
3790 |
|
3791 |
-
|
3792 |
/**
|
3793 |
* Returns chat data specific to a chat ID
|
3794 |
-
*
|
3795 |
-
* @
|
|
|
|
|
3796 |
*/
|
3797 |
-
function wplc_get_chat_data($cid) {
|
3798 |
-
|
3799 |
-
|
3800 |
-
|
3801 |
-
|
3802 |
-
|
3803 |
-
|
|
|
|
|
|
|
|
|
|
|
3804 |
}
|
3805 |
|
3806 |
/**
|
3807 |
* Returns chat messages specific to a chat ID
|
3808 |
-
*
|
3809 |
-
* @
|
|
|
|
|
3810 |
*/
|
3811 |
-
function wplc_get_chat_messages($cid, $only_read_messages = false, $wplc_settings = false) {
|
3812 |
-
|
3813 |
-
|
3814 |
|
3815 |
-
|
3816 |
-
|
3817 |
-
|
3818 |
|
3819 |
-
|
3820 |
-
|
3821 |
-
|
3822 |
-
|
3823 |
|
3824 |
-
|
3825 |
SELECT * FROM (
|
3826 |
SELECT *
|
3827 |
FROM $wplc_tblname_msgs
|
@@ -3830,11 +4187,11 @@ function wplc_get_chat_messages($cid, $only_read_messages = false, $wplc_setting
|
|
3830 |
) sub
|
3831 |
ORDER BY `timestamp` ASC
|
3832 |
";
|
3833 |
-
|
3834 |
-
|
3835 |
-
|
3836 |
-
|
3837 |
-
|
3838 |
SELECT * FROM (
|
3839 |
SELECT *
|
3840 |
FROM $wplc_tblname_msgs
|
@@ -3843,9 +4200,9 @@ function wplc_get_chat_messages($cid, $only_read_messages = false, $wplc_setting
|
|
3843 |
) sub
|
3844 |
ORDER BY `timestamp` ASC
|
3845 |
";
|
3846 |
-
|
3847 |
-
|
3848 |
-
|
3849 |
SELECT * FROM (
|
3850 |
SELECT *
|
3851 |
FROM $wplc_tblname_msgs
|
@@ -3854,281 +4211,317 @@ function wplc_get_chat_messages($cid, $only_read_messages = false, $wplc_setting
|
|
3854 |
) sub
|
3855 |
ORDER BY `timestamp` ASC
|
3856 |
";
|
3857 |
-
|
3858 |
|
3859 |
-
|
3860 |
-
|
3861 |
|
3862 |
-
|
3863 |
-
|
|
|
|
|
|
|
3864 |
|
3865 |
-
|
3866 |
-
|
3867 |
-
|
3868 |
-
|
3869 |
-
|
3870 |
}
|
3871 |
|
3872 |
-
add_action('admin_init', 'wplc_admin_download_chat_history');
|
3873 |
/**
|
3874 |
* Downloads the chat history and adds it to a CSV file
|
3875 |
* @return file
|
3876 |
*/
|
3877 |
-
function wplc_admin_download_chat_history(){
|
3878 |
-
if (!is_user_logged_in() || !wplc_user_is_agent()) {
|
3879 |
-
|
3880 |
}
|
3881 |
|
3882 |
-
if (isset($_GET['action']) && $_GET['action'] == "download_history") {
|
3883 |
|
3884 |
-
|
3885 |
|
3886 |
-
|
3887 |
-
|
3888 |
-
|
3889 |
|
3890 |
-
|
3891 |
-
|
3892 |
|
3893 |
-
|
3894 |
-
|
3895 |
-
|
3896 |
-
|
3897 |
-
|
3898 |
-
|
3899 |
|
3900 |
-
|
3901 |
|
3902 |
-
|
3903 |
-
|
3904 |
|
3905 |
-
|
3906 |
SELECT *
|
3907 |
FROM $wplc_tblname_msgs
|
3908 |
WHERE `chat_sess_id` = %s
|
3909 |
ORDER BY `timestamp` ASC
|
3910 |
LIMIT 0,1000
|
3911 |
-
", $chat_id)
|
3912 |
-
|
3913 |
-
|
3914 |
-
|
3915 |
-
|
3916 |
-
|
3917 |
-
|
3918 |
-
|
3919 |
-
|
3920 |
-
|
3921 |
-
|
3922 |
-
|
3923 |
-
|
3924 |
-
|
3925 |
-
|
3926 |
-
|
3927 |
-
|
3928 |
-
|
3929 |
-
|
3930 |
-
|
3931 |
-
|
3932 |
-
|
3933 |
-
|
3934 |
-
|
3935 |
-
|
3936 |
-
|
3937 |
-
|
3938 |
-
|
3939 |
-
|
3940 |
-
|
3941 |
-
|
3942 |
-
|
3943 |
-
|
3944 |
-
|
3945 |
-
|
3946 |
-
|
3947 |
}
|
3948 |
|
3949 |
/**
|
3950 |
* Retrieves the data to start downloadling the chat history
|
3951 |
-
*
|
3952 |
-
* @param
|
|
|
|
|
3953 |
* @return void
|
3954 |
*/
|
3955 |
-
function wplc_admin_download_history($type, $cid){
|
3956 |
-
|
3957 |
-
|
3958 |
}
|
3959 |
|
3960 |
-
|
3961 |
-
|
3962 |
|
3963 |
-
|
3964 |
-
|
3965 |
SELECT *
|
3966 |
FROM $wplc_tblname_msgs
|
3967 |
WHERE `chat_sess_id` = %d
|
3968 |
ORDER BY `timestamp` ASC
|
3969 |
LIMIT 0, 100
|
3970 |
"
|
3971 |
-
|
3972 |
-
|
3973 |
|
3974 |
-
|
3975 |
-
|
3976 |
-
|
3977 |
-
|
3978 |
-
|
3979 |
-
|
3980 |
-
|
3981 |
|
3982 |
-
|
3983 |
-
|
3984 |
-
|
3985 |
-
|
3986 |
-
|
3987 |
-
|
3988 |
|
3989 |
-
|
3990 |
-
|
3991 |
-
|
3992 |
-
|
3993 |
-
|
3994 |
-
|
3995 |
-
|
3996 |
-
|
3997 |
|
3998 |
-
|
3999 |
|
4000 |
-
|
4001 |
|
4002 |
-
|
4003 |
}
|
4004 |
|
4005 |
/**
|
4006 |
* Converts contents into a CSV file
|
4007 |
-
*
|
4008 |
-
* @param
|
4009 |
-
* @param
|
|
|
|
|
4010 |
* @return void
|
4011 |
*/
|
4012 |
-
function wplc_convert_to_csv($in, $out, $del) {
|
4013 |
-
|
4014 |
|
4015 |
-
|
4016 |
-
|
4017 |
-
|
4018 |
-
|
4019 |
-
|
4020 |
-
|
4021 |
-
|
4022 |
}
|
4023 |
|
4024 |
/**
|
4025 |
* Parses content to add to a CSV file
|
4026 |
-
*
|
4027 |
-
* @param
|
4028 |
-
* @param
|
4029 |
-
* @param
|
|
|
|
|
4030 |
* @return void
|
4031 |
*/
|
4032 |
-
function wplc_fputcsv_eol($fp, $array, $del, $eol) {
|
4033 |
-
|
4034 |
-
|
4035 |
-
|
4036 |
-
|
4037 |
}
|
4038 |
|
4039 |
-
add_filter("wplc_filter_typing_control_div","wplc_filter_control_return_chat_response_box_before",2,1);
|
4040 |
-
function wplc_filter_control_return_chat_response_box_before($string) {
|
4041 |
-
|
4042 |
|
4043 |
-
|
4044 |
}
|
4045 |
-
add_filter("wplc_filter_typing_control_div_theme_2","wplc_filter_control_return_chat_response_box_before_theme2",2,1);
|
4046 |
-
function wplc_filter_control_return_chat_response_box_before_theme2($string) {
|
4047 |
-
$string = $string. "<div class='typing_indicator wplc-color-1'></div>";
|
4048 |
|
4049 |
-
|
|
|
|
|
|
|
|
|
4050 |
}
|
4051 |
|
4052 |
|
4053 |
-
add_action("wplc_hook_admin_settings_main_settings_after","wplc_hook_control_admin_settings_chat_box_settings_after",2);
|
4054 |
/**
|
4055 |
* Adds the settings to allow the user to change their server environment variables
|
4056 |
-
* @return sring
|
|
|
4057 |
function wplc_hook_control_admin_settings_chat_box_settings_after() {
|
4058 |
-
|
4059 |
-
|
4060 |
?>
|
4061 |
-
|
4062 |
-
|
4063 |
-
|
4064 |
-
|
4065 |
-
|
4066 |
-
|
4067 |
-
|
4068 |
-
|
4069 |
-
|
4070 |
-
|
4071 |
-
|
4072 |
-
|
4073 |
-
|
4074 |
-
|
4075 |
-
|
4076 |
-
|
4077 |
-
|
4078 |
-
|
4079 |
-
|
4080 |
-
|
4081 |
-
<option value='
|
4082 |
-
|
4083 |
-
|
4084 |
-
|
4085 |
-
|
4086 |
-
|
4087 |
-
|
4088 |
-
|
4089 |
-
|
4090 |
-
|
4091 |
-
|
4092 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4093 |
<tr>
|
4094 |
-
|
4095 |
-
|
|
|
|
|
|
|
4096 |
</tr>
|
4097 |
<tr>
|
4098 |
-
|
4099 |
-
|
4100 |
-
|
4101 |
-
|
4102 |
-
|
4103 |
-
|
4104 |
-
|
|
|
|
|
|
|
4105 |
|
4106 |
-
|
4107 |
-
|
4108 |
|
4109 |
-
|
4110 |
-
|
4111 |
}
|
4112 |
|
4113 |
-
add_action('wplc_hook_admin_settings_main_settings_after','wplc_powered_by_link_settings_page',2);
|
4114 |
/**
|
4115 |
* Adds the necessary checkbox to enable/disable the 'Powered by' link
|
4116 |
* @return string
|
4117 |
*/
|
4118 |
function wplc_powered_by_link_settings_page() {
|
4119 |
-
|
4120 |
-
|
4121 |
<table class='form-table wp-list-table wplc_list_table widefat fixed striped pages' width='700'>
|
4122 |
<tr>
|
4123 |
<td width='350' valign='top'>
|
4124 |
-
|
|
|
|
|
4125 |
</td>
|
4126 |
<td>
|
4127 |
-
<input type="checkbox" value="1"
|
|
|
|
|
|
|
4128 |
</td>
|
4129 |
</tr>
|
4130 |
</table>
|
4131 |
-
|
4132 |
}
|
4133 |
|
4134 |
add_action( "wplc_hook_head", "wplc_powered_by_link_save_settings" );
|
@@ -4136,15 +4529,15 @@ add_action( "wplc_hook_head", "wplc_powered_by_link_save_settings" );
|
|
4136 |
* Saves the 'Powered by' link settings
|
4137 |
* @return void
|
4138 |
*/
|
4139 |
-
function wplc_powered_by_link_save_settings(){
|
4140 |
|
4141 |
-
if( isset( $_POST['wplc_save_settings'] ) ){
|
4142 |
|
4143 |
-
|
4144 |
-
|
4145 |
-
|
4146 |
-
|
4147 |
-
|
4148 |
|
4149 |
}
|
4150 |
|
@@ -4153,17 +4546,19 @@ function wplc_powered_by_link_save_settings(){
|
|
4153 |
add_filter( "wplc_start_chat_user_form_after_filter", "wplc_powered_by_link_in_chat", 12, 1 );
|
4154 |
/**
|
4155 |
* Appends the 'Powered by' link to the chat window
|
4156 |
-
*
|
4157 |
-
* @param
|
4158 |
-
* @
|
|
|
|
|
4159 |
*/
|
4160 |
-
function wplc_powered_by_link_in_chat( $string ){
|
4161 |
|
4162 |
$show_powered_by = get_option( "WPLC_POWERED_BY" );
|
4163 |
|
4164 |
-
if( $show_powered_by == 1){
|
4165 |
|
4166 |
-
$ret = "<i style='text-align: center; display: block; padding: 5px 0; font-size: 10px;'><a href='https://www.3cx.com/wp-live-chat/?utm_source=poweredby&utm_medium=click&utm_campaign=".wp_filter_post_kses(site_url())."'' target='_BLANK' rel='nofollow'>".__("Powered by WP Live Chat by 3CX", 'wp-live-chat-support')."</a></i>";
|
4167 |
|
4168 |
} else {
|
4169 |
|
@@ -4181,33 +4576,35 @@ add_action( "admin_enqueue_scripts", "wplc_custom_scripts_scripts" );
|
|
4181 |
* @return void
|
4182 |
*/
|
4183 |
function wplc_custom_scripts_scripts() {
|
4184 |
-
|
4185 |
-
|
4186 |
-
|
4187 |
-
|
4188 |
-
|
4189 |
-
|
4190 |
-
|
4191 |
-
|
4192 |
-
|
4193 |
-
|
4194 |
-
|
4195 |
-
|
4196 |
-
|
4197 |
-
|
4198 |
}
|
4199 |
|
4200 |
add_filter( "wplc_offline_message_subject_filter", "wplc_change_offline_message", 10, 1 );
|
4201 |
/**
|
4202 |
* Adds a filter to change the email address to the user's preference
|
4203 |
-
*
|
|
|
|
|
4204 |
* @return string
|
4205 |
*/
|
4206 |
-
function wplc_change_offline_message( $subject ){
|
4207 |
|
4208 |
$wplc_settings = wplc_get_options();
|
4209 |
|
4210 |
-
if( isset( $wplc_settings['wplc_pro_chat_email_offline_subject'] ) ){
|
4211 |
$subject = stripslashes( $wplc_settings['wplc_pro_chat_email_offline_subject'] );
|
4212 |
}
|
4213 |
|
@@ -4218,20 +4615,20 @@ function wplc_change_offline_message( $subject ){
|
|
4218 |
add_filter( 'wplc_filter_active_chat_box_notification', 'wplc_active_chat_box_notice' );
|
4219 |
add_action( "wplc_hook_chat_dashboard_above", "wplc_active_chat_box_notices" );
|
4220 |
function wplc_active_chat_box_notices() {
|
4221 |
-
|
4222 |
}
|
4223 |
|
4224 |
/*
|
4225 |
* Returns the WDT emoji selector
|
4226 |
*/
|
4227 |
-
function wplc_emoji_selector_div(){
|
4228 |
$wplc_settings = wplc_get_options();
|
4229 |
|
4230 |
-
if ($wplc_settings['wplc_disable_emojis'] ||
|
4231 |
return;
|
4232 |
-
|
4233 |
|
4234 |
-
|
4235 |
<a href="#" class="wdt-emoji-popup-mobile-closer"> × </a>
|
4236 |
<div class="wdt-emoji-menu-content">
|
4237 |
<div id="wdt-emoji-menu-header">
|
@@ -4277,55 +4674,60 @@ add_action( 'admin_notices', 'wplc_browser_notifications_admin_warning' );
|
|
4277 |
*/
|
4278 |
function wplc_browser_notifications_admin_warning() {
|
4279 |
|
4280 |
-
|
4281 |
|
4282 |
-
|
4283 |
|
4284 |
-
|
4285 |
|
4286 |
-
|
4287 |
|
4288 |
-
|
4289 |
|
4290 |
-
|
4291 |
<div class="notice notice-warning is-dismissible">
|
4292 |
-
<p><img src="<?php echo sanitize_text_field(
|
4293 |
-
|
4294 |
-
<p
|
4295 |
-
|
|
|
|
|
|
|
|
|
|
|
4296 |
</div>
|
4297 |
-
|
4298 |
|
4299 |
-
|
4300 |
-
|
4301 |
}
|
4302 |
|
4303 |
if ( function_exists( 'wplc_et_first_run_check' ) ) {
|
4304 |
add_action( 'admin_notices', 'wplc_transcript_admin_notice' );
|
4305 |
}
|
4306 |
function wplc_transcript_admin_notice() {
|
4307 |
-
printf( '<div class="notice notice-info">%1$s</div>', __( 'Please deactivate WP Live Chat Suport - Email Transcript plugin. Since WP Live Chat Support 8.0.05 there is build in support for Email Transcript.', 'wp-live-chat-support') );
|
4308 |
}
|
4309 |
|
4310 |
add_action( 'wplc_hook_admin_visitor_info_display_after', 'wplc_transcript_add_admin_button' );
|
4311 |
function wplc_transcript_add_admin_button( $cid ) {
|
4312 |
-
|
4313 |
-
if ($wplc_settings['wplc_enable_transcripts']) {
|
4314 |
-
echo "<a href=\"javascript:void(0);\" cid='" . esc_attr( $cid ) . "' class=\"wplc_admin_email_transcript button button-secondary\" id=\"wplc_admin_email_transcript\">" . __( "Email transcript to user", 'wp-live-chat-support') . "</a>";
|
4315 |
}
|
4316 |
}
|
4317 |
|
4318 |
add_action( 'wplc_hook_admin_javascript_chat', 'wplc_transcript_admin_javascript' );
|
4319 |
function wplc_transcript_admin_javascript() {
|
4320 |
$wplc_et_ajax_nonce = wp_create_nonce( "wplc_et_nonce" );
|
4321 |
-
wp_register_script( 'wplc_transcript_admin',
|
4322 |
$wplc_transcript_localizations = array(
|
4323 |
'ajax_nonce' => $wplc_et_ajax_nonce,
|
4324 |
-
'string_loading' => __( "Sending transcript...", 'wp-live-chat-support'),
|
4325 |
-
'string_title' => __( "Sending Transcript", 'wp-live-chat-support'),
|
4326 |
-
'string_close' => __( "Close", 'wp-live-chat-support'),
|
4327 |
-
'string_chat_emailed' => __( "The chat transcript has been emailed.", 'wp-live-chat-support'),
|
4328 |
-
'string_error1' => __( "There was a problem emailing the chat.", 'wp-live-chat-support')
|
4329 |
);
|
4330 |
wp_localize_script( 'wplc_transcript_admin', 'wplc_transcript_nonce', $wplc_transcript_localizations );
|
4331 |
wp_enqueue_script( 'wplc_transcript_admin' );
|
@@ -4333,76 +4735,79 @@ function wplc_transcript_admin_javascript() {
|
|
4333 |
|
4334 |
add_action( 'wp_ajax_wplc_et_admin_email_transcript', 'wplc_transcript_callback' );
|
4335 |
function wplc_transcript_callback() {
|
4336 |
-
|
4337 |
-
|
4338 |
-
|
4339 |
-
|
4340 |
-
|
4341 |
-
|
4342 |
-
|
4343 |
-
|
4344 |
-
|
4345 |
-
|
4346 |
-
|
4347 |
-
|
4348 |
-
|
4349 |
-
|
4350 |
-
|
4351 |
-
|
4352 |
-
|
4353 |
-
|
4354 |
-
|
4355 |
-
|
4356 |
-
|
4357 |
}
|
4358 |
|
4359 |
function wplc_send_transcript( $cid ) {
|
4360 |
-
|
4361 |
-
|
4362 |
-
|
4363 |
-
|
4364 |
-
|
4365 |
-
|
4366 |
-
|
4367 |
-
|
4368 |
-
|
4369 |
-
|
4370 |
-
|
4371 |
-
|
4372 |
-
|
4373 |
-
|
4374 |
-
|
4375 |
-
|
4376 |
-
|
4377 |
-
|
4378 |
-
|
4379 |
-
|
4380 |
-
|
4381 |
-
|
4382 |
-
|
4383 |
-
|
4384 |
-
|
4385 |
-
|
4386 |
-
|
4387 |
-
|
4388 |
-
|
4389 |
-
|
4390 |
-
|
4391 |
-
|
4392 |
-
|
4393 |
-
|
|
|
|
|
4394 |
|
4395 |
function wplc_transcript_return_chat_messages( $cid ) {
|
4396 |
global $current_chat_id;
|
4397 |
-
|
4398 |
-
|
4399 |
-
$body
|
4400 |
|
4401 |
-
if (empty($body)) {
|
4402 |
$body = do_shortcode( wplc_transcript_return_default_email_body() );
|
4403 |
} else {
|
4404 |
$body = do_shortcode( $body );
|
4405 |
}
|
|
|
4406 |
return $body;
|
4407 |
}
|
4408 |
|
@@ -4476,73 +4881,73 @@ function wplc_transcript_return_default_email_body() {
|
|
4476 |
add_action( 'wplc_hook_admin_settings_main_settings_after', 'wplc_hook_admin_transcript_settings' );
|
4477 |
function wplc_hook_admin_transcript_settings() {
|
4478 |
$wplc_settings = wplc_get_options();
|
4479 |
-
echo "<h3>" . __( "Chat Transcript Settings", 'wp-live-chat-support') . "</h3>";
|
4480 |
echo "<table class='form-table wp-list-table widefat fixed striped pages' width='700'>";
|
4481 |
echo " <tr>";
|
4482 |
-
echo " <td width='400' valign='top'>" . __( "Enable chat transcripts:", 'wp-live-chat-support') . "</td>";
|
4483 |
echo " <td>";
|
4484 |
-
echo " <input type=\"checkbox\" value=\"1\" name=\"wplc_enable_transcripts\" ".($wplc_settings['wplc_enable_transcripts'] ? ' checked' : '');
|
4485 |
echo " />";
|
4486 |
echo " </td>";
|
4487 |
echo " </tr>";
|
4488 |
|
4489 |
echo " <tr>";
|
4490 |
-
echo " <td width='400' valign='top'>" . __( "Send transcripts to:", 'wp-live-chat-support') . "</td>";
|
4491 |
echo " <td>";
|
4492 |
echo " <select name=\"wplc_send_transcripts_to\">";
|
4493 |
echo " <option value=\"user\" ";
|
4494 |
if ( $wplc_settings['wplc_send_transcripts_to'] == 'user' ) {
|
4495 |
-
|
4496 |
-
|
4497 |
-
|
4498 |
echo " <option value=\"admin\" ";
|
4499 |
if ( $wplc_settings['wplc_send_transcripts_to'] == 'admin' ) {
|
4500 |
echo "selected";
|
4501 |
}
|
4502 |
-
echo ">" . __( "Admin", 'wp-live-chat-support') . "</option>";
|
4503 |
echo " </select>";
|
4504 |
echo " </td>";
|
4505 |
echo " </tr>";
|
4506 |
|
4507 |
echo " <tr>";
|
4508 |
-
echo " <td width='400' valign='top'>" . __( "Send transcripts when chat ends:", 'wp-live-chat-support') . "</td>";
|
4509 |
echo " <td>";
|
4510 |
-
echo " <input type=\"checkbox\" value=\"1\" name=\"wplc_send_transcripts_when_chat_ends\" ".($wplc_settings['wplc_send_transcripts_when_chat_ends'] ? ' checked' : '');
|
4511 |
echo " />";
|
4512 |
echo " </td>";
|
4513 |
echo " </tr>";
|
4514 |
|
4515 |
echo " <tr>";
|
4516 |
-
echo " <td width='400' valign='top'>" . __( "Email body", 'wp-live-chat-support') . "</td>";
|
4517 |
echo " <td>";
|
4518 |
echo " <textarea cols='85' rows='15' name=\"wplc_et_email_body\">";
|
4519 |
-
|
4520 |
echo " </textarea>";
|
4521 |
echo " </td>";
|
4522 |
echo " </tr>";
|
4523 |
|
4524 |
|
4525 |
echo " <tr>";
|
4526 |
-
echo " <td width='400' valign='top'>" . __( "Email header", 'wp-live-chat-support') . "</td>";
|
4527 |
echo " <td>";
|
4528 |
echo " <textarea cols='85' rows='5' name=\"wplc_et_email_header\">";
|
4529 |
-
|
4530 |
echo " </textarea>";
|
4531 |
echo " </td>";
|
4532 |
echo " </tr>";
|
4533 |
|
4534 |
echo " <tr>";
|
4535 |
-
echo " <td width='400' valign='top'>" . __( "Email footer", 'wp-live-chat-support') . "</td>";
|
4536 |
echo " <td>";
|
4537 |
echo " <textarea cols='85' rows='5' name=\"wplc_et_email_footer\">";
|
4538 |
-
|
4539 |
echo " </textarea>";
|
4540 |
echo " </td>";
|
4541 |
echo " </tr>";
|
4542 |
echo "</table>";
|
4543 |
}
|
4544 |
|
4545 |
-
add_shortcode('wplc_et_transcript', 'wplc_transcript_get_transcript');
|
4546 |
function wplc_transcript_get_transcript() {
|
4547 |
global $current_chat_id;
|
4548 |
$cid = $current_chat_id;
|
@@ -4551,7 +4956,7 @@ function wplc_transcript_get_transcript() {
|
|
4551 |
$output_html = wplc_return_chat_messages( intval( $cid ), true );
|
4552 |
|
4553 |
// Remove empty documentation suggestions, and unneeded list items
|
4554 |
-
$output_html = str_replace('<li></li>', '', $output_html);
|
4555 |
|
4556 |
return $output_html;
|
4557 |
} else {
|
@@ -4561,19 +4966,20 @@ function wplc_transcript_get_transcript() {
|
|
4561 |
|
4562 |
add_shortcode( 'wplc_et_transcript_footer_text', 'wplc_transcript_get_footer_text' );
|
4563 |
function wplc_transcript_get_footer_text() {
|
4564 |
-
|
4565 |
-
|
|
|
4566 |
}
|
4567 |
|
4568 |
add_shortcode( 'wplc_et_transcript_header_text', 'wplc_transcript_get_header_text' );
|
4569 |
function wplc_transcript_get_header_text() {
|
4570 |
-
|
4571 |
|
4572 |
global $current_chat_id;
|
4573 |
$cid = $current_chat_id;
|
4574 |
|
4575 |
$from_email = "Unknown@unknown.com";
|
4576 |
-
$from_name
|
4577 |
if ( intval( $cid ) > 0 ) {
|
4578 |
$chat_data = wplc_get_chat_data( $cid );
|
4579 |
if ( isset( $chat_data->email ) ) {
|
@@ -4583,40 +4989,41 @@ function wplc_transcript_get_header_text() {
|
|
4583 |
$from_name = $chat_data->name;
|
4584 |
}
|
4585 |
}
|
4586 |
-
|
|
|
4587 |
}
|
4588 |
|
4589 |
function wplc_features_admin_js() {
|
4590 |
-
wp_register_script('wplc-admin-features',
|
4591 |
-
wp_enqueue_script('wplc-admin-features');
|
4592 |
}
|
4593 |
|
4594 |
// add_action('admin_notices', 'wplc_encryption_deprecated_notice');
|
4595 |
/**
|
4596 |
* Notice of doom
|
4597 |
-
*/
|
4598 |
-
function wplc_encryption_deprecated_notice(){
|
4599 |
-
|
4600 |
-
|
4601 |
-
|
4602 |
-
|
4603 |
-
|
4604 |
-
|
4605 |
-
|
4606 |
-
|
4607 |
-
|
4608 |
-
|
4609 |
-
|
4610 |
-
|
4611 |
-
|
4612 |
-
|
4613 |
-
|
4614 |
-
|
4615 |
-
|
4616 |
-
|
4617 |
-
|
4618 |
-
|
4619 |
-
|
4620 |
-
|
4621 |
-
|
4622 |
}
|
3 |
Plugin Name: WP-Live Chat by 3CX
|
4 |
Plugin URI: https://www.3cx.com/wp-live-chat/
|
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 by 3CX.
|
6 |
+
Version: 8.1.8
|
7 |
Author: 3CX
|
8 |
Author URI: https://www.3cx.com/wp-live-chat/
|
9 |
Domain Path: /languages
|
21 |
global $wplc_tblname_chats;
|
22 |
global $wplc_tblname_msgs;
|
23 |
global $wplc_tblname_offline_msgs;
|
24 |
+
global $current_chat_id;
|
25 |
+
global $wplc_tblname_chat_ratings;
|
26 |
global $wplc_tblname_chat_triggers;
|
27 |
|
28 |
/**
|
31 |
global $admin_chat_data;
|
32 |
$admin_chat_data = false;
|
33 |
|
34 |
+
$wplc_tblname_offline_msgs = $wpdb->prefix . "wplc_offline_messages";
|
35 |
+
$wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
|
36 |
+
$wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
|
37 |
+
$wplc_tblname_chat_ratings = $wpdb->prefix . "wplc_chat_ratings";
|
38 |
$wplc_tblname_chat_triggers = $wpdb->prefix . "wplc_chat_triggers";
|
39 |
|
40 |
$wplc_default_settings_array = array();
|
41 |
|
42 |
function wplc_set_defaults() {
|
43 |
+
global $wplc_default_settings_array;
|
44 |
+
if ( empty( $wplc_default_settings_array ) ) {
|
45 |
+
$wplc_default_settings_array = array(
|
46 |
+
'wplc_allow_department_selection' => false,
|
47 |
+
'wplc_allow_agents_set_status' => true,
|
48 |
+
'wplc_animation' => '',
|
49 |
+
'wplc_auto_pop_up' => 0,
|
50 |
+
'wplc_auto_pop_up_online' => false,
|
51 |
+
'wplc_auto_pop_up_mobile' => true,
|
52 |
+
'wplc_avatar_source' => '',
|
53 |
+
'wplc_bh_days' => '0111110',
|
54 |
+
'wplc_bh_enable' => false,
|
55 |
+
'wplc_bh_schedule' => array(
|
56 |
+
0 => array(
|
57 |
+
0 => array( 'hs' => 9, 'ms' => 0, 'he' => 13, 'me' => 0 ),
|
58 |
+
1 => array( 'hs' => 14, 'ms' => 0, 'he' => 18, 'me' => 0 )
|
59 |
+
),
|
60 |
+
1 => array(
|
61 |
+
0 => array( 'hs' => 9, 'ms' => 0, 'he' => 13, 'me' => 0 ),
|
62 |
+
1 => array( 'hs' => 14, 'ms' => 0, 'he' => 18, 'me' => 0 )
|
63 |
+
),
|
64 |
+
2 => array(
|
65 |
+
0 => array( 'hs' => 9, 'ms' => 0, 'he' => 13, 'me' => 0 ),
|
66 |
+
1 => array( 'hs' => 14, 'ms' => 0, 'he' => 18, 'me' => 0 )
|
67 |
+
),
|
68 |
+
3 => array(
|
69 |
+
0 => array( 'hs' => 9, 'ms' => 0, 'he' => 13, 'me' => 0 ),
|
70 |
+
1 => array( 'hs' => 14, 'ms' => 0, 'he' => 18, 'me' => 0 )
|
71 |
+
),
|
72 |
+
4 => array(
|
73 |
+
0 => array( 'hs' => 9, 'ms' => 0, 'he' => 13, 'me' => 0 ),
|
74 |
+
1 => array( 'hs' => 14, 'ms' => 0, 'he' => 18, 'me' => 0 )
|
75 |
+
),
|
76 |
+
5 => array(
|
77 |
+
0 => array( 'hs' => 9, 'ms' => 0, 'he' => 13, 'me' => 0 ),
|
78 |
+
1 => array( 'hs' => 14, 'ms' => 0, 'he' => 18, 'me' => 0 )
|
79 |
+
),
|
80 |
+
6 => array(
|
81 |
+
0 => array( 'hs' => 9, 'ms' => 0, 'he' => 13, 'me' => 0 ),
|
82 |
+
1 => array( 'hs' => 14, 'ms' => 0, 'he' => 18, 'me' => 0 )
|
83 |
+
),
|
84 |
+
),
|
85 |
+
'wplc_chat_delay' => 2,
|
86 |
+
'wplc_chat_icon' => wplc_plugins_url( '/images/chaticon.png', __FILE__ ),
|
87 |
+
'wplc_chat_logo' => '',
|
88 |
+
'wplc_chat_name' => __( 'Admin', 'wp-live-chat-support' ),
|
89 |
+
'wplc_chat_pic' => wplc_plugins_url( '/images/picture-for-chat-box.jpg', __FILE__ ),
|
90 |
+
'wplc_chatbox_height' => 70,
|
91 |
+
'wplc_chatbox_absolute_height' => 400,
|
92 |
+
'wplc_close_btn_text' => __( "close", 'wp-live-chat-support' ),
|
93 |
+
'wplc_debug_mode' => false,
|
94 |
+
'wplc_default_department' => - 1,
|
95 |
+
'wplc_delay_between_loops' => 500,
|
96 |
+
'wplc_delete_db_on_uninstall' => true,
|
97 |
+
'wplc_disable_emojis' => false,
|
98 |
+
'wplc_display_to_loggedin_only' => false,
|
99 |
+
'wplc_elem_trigger_action' => 0,
|
100 |
+
'wplc_elem_trigger_id' => '',
|
101 |
+
'wplc_elem_trigger_type' => 0,
|
102 |
+
'wplc_enable_all_admin_pages' => false,
|
103 |
+
'wplc_enable_encryption' => false,
|
104 |
+
'wplc_enable_font_awesome' => true,
|
105 |
+
'wplc_enable_initiate_chat' => false,
|
106 |
+
'wplc_enable_msg_sound' => true,
|
107 |
+
'wplc_enable_transcripts' => true,
|
108 |
+
'wplc_enable_visitor_sound' => true,
|
109 |
+
'wplc_enable_voice_notes_on_admin' => false,
|
110 |
+
'wplc_enable_voice_notes_on_visitor' => false,
|
111 |
+
'wplc_enabled_on_mobile' => true,
|
112 |
+
'wplc_encryption_key' => '',
|
113 |
+
'wplc_environment' => 2,
|
114 |
+
'wplc_et_email_body' => wplc_transcript_return_default_email_body(),
|
115 |
+
'wplc_et_email_footer' => "<span style='font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: normal;'>" . __( 'Thank you for chatting with us.' ) . "</span>",
|
116 |
+
'wplc_et_email_header' => '<a title="' . get_bloginfo( 'name' ) . '" href="' . get_bloginfo( 'url' ) . '" style="font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: bold; text-decoration: underline;">' . get_bloginfo( 'name' ) . '</a>',
|
117 |
+
'wplc_exclude_from_pages' => '',
|
118 |
+
'wplc_exclude_home' => false,
|
119 |
+
'wplc_exclude_archive' => false,
|
120 |
+
'wplc_exclude_post_types' => '',
|
121 |
+
'wplc_gdpr_custom' => false,
|
122 |
+
'wplc_gdpr_enabled' => true,
|
123 |
+
'wplc_gdpr_notice_company' => get_bloginfo( 'name' ),
|
124 |
+
'wplc_gdpr_notice_retention_period' => 30,
|
125 |
+
'wplc_gdpr_notice_retention_purpose' => __( 'Chat/Support', 'wp-live-chat-support' ),
|
126 |
+
'wplc_gdpr_notice_text' => '',
|
127 |
+
'wplc_hide_when_offline' => false,
|
128 |
+
'wplc_include_on_pages' => '',
|
129 |
+
'wplc_iterations' => 55,
|
130 |
+
'wplc_loggedin_user_info' => true,
|
131 |
+
'wplc_messagetone' => '',
|
132 |
+
'wplc_new_chat_ringer_count' => 4,
|
133 |
+
'wplc_newtheme' => 'theme-2',
|
134 |
+
'wplc_node_enable_typing_preview' => false,
|
135 |
+
'wplc_powered_by_link' => '',
|
136 |
+
'wplc_pro_auto_first_response_chat_msg' => '',
|
137 |
+
'wplc_pro_chat_email_address' => get_option( 'admin_email' ),
|
138 |
+
'wplc_pro_chat_email_offline_subject' => '',
|
139 |
+
'wplc_pro_chat_notification' => false,
|
140 |
+
'wplc_pro_cta_anim' => false,
|
141 |
+
'wplc_pro_fst1' => __( "Questions?", 'wp-live-chat-support' ),
|
142 |
+
'wplc_pro_fst2' => __( "Chat with us", 'wp-live-chat-support' ),
|
143 |
+
'wplc_pro_fst3' => __( "Start live chat", 'wp-live-chat-support' ),
|
144 |
+
'wplc_pro_intro' => __( "Complete the fields below to proceed.", 'wp-live-chat-support' ),
|
145 |
+
'wplc_pro_na' => __( "Leave a message", 'wp-live-chat-support' ),
|
146 |
+
'wplc_pro_offline1' => __( "Please leave a message and we'll get back to you as soon as possible.", 'wp-live-chat-support' ),
|
147 |
+
'wplc_pro_offline2' => __( "Sending message...", 'wp-live-chat-support' ),
|
148 |
+
'wplc_pro_offline3' => __( "Thank you for your message. We will be in contact soon.", 'wp-live-chat-support' ),
|
149 |
+
'wplc_pro_offline_btn' => __( "Leave a message", 'wp-live-chat-support' ),
|
150 |
+
'wplc_pro_offline_btn_send' => __( "Send message", 'wp-live-chat-support' ),
|
151 |
+
'wplc_pro_sst1' => __( "Start Chat", 'wp-live-chat-support' ),
|
152 |
+
'wplc_pro_sst2' => __( "Connecting...", 'wp-live-chat-support' ),
|
153 |
+
'wplc_pro_tst1' => __( "Reactivating your previous chat...", 'wp-live-chat-support' ),
|
154 |
+
'wplc_quick_response_order' => 'DESC',
|
155 |
+
'wplc_quick_response_orderby' => 'title',
|
156 |
+
'wplc_record_ip_address' => false,
|
157 |
+
'wplc_redirect_thank_you_url' => '',
|
158 |
+
'wplc_redirect_to_thank_you_page' => false,
|
159 |
+
'wplc_require_user_info' => 'both',
|
160 |
+
'wplc_ringtone' => '',
|
161 |
+
'wplc_send_transcripts_to' => 'user',
|
162 |
+
'wplc_send_transcripts_when_chat_ends' => false,
|
163 |
+
'wplc_settings_align' => 2,
|
164 |
+
'wplc_settings_bg' => 'cloudy.jpg',
|
165 |
+
'wplc_settings_color1' => '0596d4',
|
166 |
+
'wplc_settings_color2' => 'FFFFFF',
|
167 |
+
'wplc_settings_color3' => 'EEEEEE',
|
168 |
+
'wplc_settings_color4' => '373737',
|
169 |
+
'wplc_settings_enabled' => 1,
|
170 |
+
'wplc_settings_fill' => '0596d4',
|
171 |
+
'wplc_settings_font' => 'FFFFFF',
|
172 |
+
'wplc_show_avatar' => true,
|
173 |
+
'wplc_show_date' => true,
|
174 |
+
'wplc_show_name' => true,
|
175 |
+
'wplc_show_time' => true,
|
176 |
+
'wplc_social_fb' => '',
|
177 |
+
'wplc_social_tw' => '',
|
178 |
+
'wplc_text_chat_ended' => __( "The chat has been ended by the agent.", 'wp-live-chat-support' ),
|
179 |
+
'wplc_theme' => 'theme-default',
|
180 |
+
'wplc_typing_enabled' => true,
|
181 |
+
'wplc_use_geolocalization' => false,
|
182 |
+
'wplc_use_node_server' => true,
|
183 |
+
'wplc_use_wp_name' => true,
|
184 |
+
'wplc_user_alternative_text' => __( "Please click 'Start Chat' to initiate a chat with an agent", 'wp-live-chat-support' ),
|
185 |
+
'wplc_user_default_visitor_name' => __( "Guest", 'wp-live-chat-support' ),
|
186 |
+
'wplc_user_enter' => __( "Press ENTER to send your message", 'wp-live-chat-support' ),
|
187 |
+
'wplc_user_no_answer' => __( "No answer. Try again later.", 'wp-live-chat-support' ),
|
188 |
+
'wplc_user_welcome_chat' => __( "Welcome. How may I help you?", 'wp-live-chat-support' ),
|
189 |
+
'wplc_using_localization_plugin' => false,
|
190 |
+
'wplc_ux_exp_rating' => true,
|
191 |
+
'wplc_ux_file_share' => true,
|
192 |
+
'wplc_welcome_msg' => __( "Please standby for an agent. Send your message while you wait.", 'wp-live-chat-support' )
|
193 |
+
);
|
194 |
+
}
|
195 |
}
|
196 |
|
197 |
wplc_set_defaults();
|
198 |
|
199 |
+
function wplc_get_options( $sanitize = false ) {
|
200 |
+
global $wplc_default_settings_array;
|
201 |
+
$current = get_option( 'WPLC_SETTINGS' );
|
202 |
+
$res = array();
|
203 |
+
if ( empty( $current ) || ! is_array( $current ) ) {
|
204 |
+
$current = array();
|
205 |
+
$sanitize = true;
|
206 |
+
}
|
207 |
+
if ( $sanitize ) {
|
208 |
+
wplc_set_defaults();
|
209 |
+
foreach ( $wplc_default_settings_array as $k => $v ) {
|
210 |
+
if ( ! isset( $current[ $k ] ) ) {
|
211 |
+
$res[ $k ] = $v;
|
212 |
+
} else {
|
213 |
+
$res[ $k ] = $current[ $k ];
|
214 |
+
if ( is_bool( $v ) ) {
|
215 |
+
$res[ $k ] = boolval( $current[ $k ] );
|
216 |
+
} elseif ( is_int( $v ) ) {
|
217 |
+
$res[ $k ] = intval( $current[ $k ] );
|
218 |
+
}
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
// format changes between versions / migrations
|
223 |
+
|
224 |
+
if ( isset( $current['wplc_require_user_info'] ) ) {
|
225 |
+
if ( $current['wplc_require_user_info'] == '1' ) {
|
226 |
+
$res['wplc_require_user_info'] = 'both';
|
227 |
+
}
|
228 |
+
if ( $current['wplc_require_user_info'] == '0' ) {
|
229 |
+
$res['wplc_require_user_info'] = 'none';
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
if ( isset( $current['wplc_bh_interval'] ) ) {
|
234 |
+
switch ( $current['wplc_bh_interval'] ) {
|
235 |
+
case 0:
|
236 |
+
$res['wplc_bh_days'] = '1111111';
|
237 |
+
break;
|
238 |
+
case 1:
|
239 |
+
$res['wplc_bh_days'] = '0111110';
|
240 |
+
break;
|
241 |
+
case 2:
|
242 |
+
$res['wplc_bh_days'] = '1000001';
|
243 |
+
break;
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
// business hours new params
|
248 |
+
if ( isset( $current['wplc_bh_hours_start'] ) ) {
|
249 |
+
if ( ! is_array( $current['wplc_bh_hours_start'] ) && ! empty( $current['wplc_bh_hours_start'] ) ) {
|
250 |
+
$res['wplc_bh_hours_start'] = explode( ' ', trim( str_repeat( $current['wplc_bh_hours_start'] . ' ', 7 ) ) );
|
251 |
+
}
|
252 |
+
}
|
253 |
+
if ( isset( $current['wplc_bh_minutes_start'] ) ) {
|
254 |
+
if ( ! is_array( $current['wplc_bh_minutes_start'] ) && ! empty( $current['wplc_bh_minutes_start'] ) ) {
|
255 |
+
$res['wplc_bh_minutes_start'] = explode( ' ', trim( str_repeat( $current['wplc_bh_minutes_start'] . ' ', 7 ) ) );
|
256 |
+
}
|
257 |
+
}
|
258 |
+
if ( isset( $current['wplc_bh_hours_end'] ) ) {
|
259 |
+
if ( ! is_array( $current['wplc_bh_hours_end'] ) && ! empty( $current['wplc_bh_hours_end'] ) ) {
|
260 |
+
$res['wplc_bh_hours_end'] = explode( ' ', trim( str_repeat( $current['wplc_bh_hours_end'] . ' ', 7 ) ) );
|
261 |
+
}
|
262 |
+
}
|
263 |
+
if ( isset( $current['wplc_bh_minutes_end'] ) ) {
|
264 |
+
if ( ! is_array( $current['wplc_bh_minutes_end'] ) && ! empty( $current['wplc_bh_minutes_end'] ) ) {
|
265 |
+
$res['wplc_bh_minutes_end'] = explode( ' ', trim( str_repeat( $current['wplc_bh_minutes_end'] . ' ', 7 ) ) );
|
266 |
+
}
|
267 |
+
}
|
268 |
+
if ( isset( $current['wplc_bh_hours_start2'] ) ) {
|
269 |
+
if ( ! is_array( $current['wplc_bh_hours_start2'] ) && ! empty( $current['wplc_bh_hours_start2'] ) ) {
|
270 |
+
$res['wplc_bh_hours_start2'] = explode( ' ', trim( str_repeat( $current['wplc_bh_hours_start2'] . ' ', 7 ) ) );
|
271 |
+
}
|
272 |
+
}
|
273 |
+
if ( isset( $current['wplc_bh_minutes_start2'] ) ) {
|
274 |
+
if ( ! is_array( $current['wplc_bh_minutes_start2'] ) && ! empty( $current['wplc_bh_minutes_start2'] ) ) {
|
275 |
+
$res['wplc_bh_minutes_start2'] = explode( ' ', trim( str_repeat( $current['wplc_bh_minutes_start2'] . ' ', 7 ) ) );
|
276 |
+
}
|
277 |
+
}
|
278 |
+
if ( isset( $current['wplc_bh_hours_end2'] ) ) {
|
279 |
+
if ( ! is_array( $current['wplc_bh_hours_end2'] ) && ! empty( $current['wplc_bh_hours_end2'] ) ) {
|
280 |
+
$res['wplc_bh_hours_end2'] = explode( ' ', trim( str_repeat( $current['wplc_bh_hours_end2'] . ' ', 7 ) ) );
|
281 |
+
}
|
282 |
+
}
|
283 |
+
if ( isset( $current['wplc_bh_minutes_end2'] ) ) {
|
284 |
+
if ( ! is_array( $current['wplc_bh_minutes_end2'] ) && ! empty( $current['wplc_bh_minutes_end2'] ) ) {
|
285 |
+
$res['wplc_bh_minutes_end2'] = explode( ' ', trim( str_repeat( $current['wplc_bh_minutes_end2'] . ' ', 7 ) ) );
|
286 |
+
}
|
287 |
+
}
|
288 |
+
} else {
|
289 |
+
$res = $current;
|
290 |
+
}
|
291 |
+
// override
|
292 |
+
$res['wplc_newtheme'] = 'theme-2';
|
293 |
+
|
294 |
+
return $res;
|
295 |
}
|
296 |
|
297 |
// Load Config
|
298 |
+
require_once( plugin_dir_path( __FILE__ ) . "config.php" );
|
299 |
+
require_once( plugin_dir_path( __FILE__ ) . "functions.php" );
|
300 |
// User
|
301 |
+
require_once( plugin_dir_path( __FILE__ ) . "ajax/user.php" );
|
302 |
// Agent
|
303 |
+
require_once( plugin_dir_path( __FILE__ ) . "ajax/agent.php" );
|
304 |
|
305 |
// Check if PRO plugin is active
|
306 |
function wplc_is_pro_active( $plugin ) {
|
307 |
|
308 |
// Check if it's a WP network
|
309 |
if ( ! is_multisite() ) {
|
310 |
+
$active_plugins = get_option( 'active_plugins', array() );
|
311 |
+
|
312 |
return in_array( $plugin, (array) $active_plugins );
|
313 |
}
|
314 |
|
315 |
$plugins = get_site_option( 'active_sitewide_plugins' );
|
316 |
if ( isset( $plugins[ $plugin ] ) ) {
|
317 |
return true;
|
318 |
+
} else {
|
319 |
return false;
|
320 |
}
|
321 |
+
|
322 |
}
|
323 |
|
324 |
// Check if PRO plugin is present
|
331 |
}
|
332 |
}
|
333 |
|
334 |
+
|
335 |
/*
|
336 |
* Load Includes
|
337 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
|
339 |
+
require_once( plugin_dir_path( __FILE__ ) . "includes/notification_control.php" );
|
340 |
+
require_once( plugin_dir_path( __FILE__ ) . "includes/modal_control.php" );
|
341 |
+
require_once( plugin_dir_path( __FILE__ ) . "includes/wplc_data_triggers.php" );
|
342 |
+
require_once( plugin_dir_path( __FILE__ ) . "includes/wplc_roi.php" );
|
343 |
+
require_once( plugin_dir_path( __FILE__ ) . "includes/wplc_departments.php" );
|
344 |
+
require_once( plugin_dir_path( __FILE__ ) . "includes/wplc_transfer_chats.php" );
|
345 |
+
require_once( plugin_dir_path( __FILE__ ) . "includes/wplc_custom_fields.php" );
|
346 |
+
require_once( plugin_dir_path( __FILE__ ) . "includes/wplc_agent_data.php" );
|
347 |
|
348 |
|
349 |
/*
|
350 |
* Load Modules
|
351 |
*/
|
352 |
+
require_once( plugin_dir_path( __FILE__ ) . "modules/google_analytics.php" );
|
353 |
+
require_once( plugin_dir_path( __FILE__ ) . "modules/api/public/wplc-api.php" );
|
354 |
+
require_once( plugin_dir_path( __FILE__ ) . "modules/advanced_features.php" );
|
355 |
+
require_once( plugin_dir_path( __FILE__ ) . "modules/node_server.php" );
|
356 |
+
require_once( plugin_dir_path( __FILE__ ) . "modules/webhooks_manager.php" );
|
357 |
+
require_once( plugin_dir_path( __FILE__ ) . "modules/privacy.php" );
|
358 |
+
require_once( plugin_dir_path( __FILE__ ) . "modules/cta_animations.php" );
|
359 |
+
require_once( plugin_dir_path( __FILE__ ) . "modules/advanced_tools.php" );
|
|
|
|
|
360 |
|
361 |
|
362 |
/*
|
363 |
* Added back for backwards compat decrypt
|
364 |
*/
|
365 |
+
if ( class_exists( "AES" ) ) {
|
366 |
+
} else {
|
367 |
+
require( 'includes/aes_fast.php' );
|
368 |
+
}
|
369 |
+
if ( class_exists( "cryptoHelpers" ) ) {
|
370 |
+
} else {
|
371 |
+
require( 'includes/cryptoHelpers.php' );
|
372 |
+
}
|
373 |
|
374 |
// Gutenberg Blocks
|
375 |
+
require_once( plugin_dir_path( __FILE__ ) . "includes/blocks/wplc-chat-box/index.php" );
|
376 |
+
require_once( plugin_dir_path( __FILE__ ) . "includes/blocks/wplc-inline-chat-box/index.php" );
|
377 |
|
378 |
// Shortcodes
|
379 |
+
require_once( plugin_dir_path( __FILE__ ) . "includes/shortcodes.php" );
|
380 |
+
|
381 |
+
add_action( "wplc_set_session_chat_id", 'wplc_set_u_session' );
|
382 |
+
add_action( "wplc_end_session_chat_id", 'wplc_clean_session' );
|
383 |
+
add_action( 'admin_init', 'wplc_detect_old_pro_plugin' );
|
384 |
+
add_action( "wp_login", 'wplc_check_guid' );
|
385 |
+
add_action( 'init', 'wplc_version_control' );
|
386 |
+
add_action( 'init', 'wplc_init' );
|
387 |
+
add_action( 'init', 'wplc_mrg_create_macro_post_type', 100 );
|
388 |
+
add_action( 'admin_init', 'wplc_head' );
|
389 |
+
add_action( 'wp_ajax_wplc_admin_set_transient', 'wplc_action_callback' );
|
390 |
+
add_action( 'wp_ajax_wplc_admin_remove_transient', 'wplc_action_callback' );
|
391 |
+
add_action( 'wp_ajax_wplc_hide_ftt', 'wplc_action_callback' );
|
392 |
+
add_action( 'wp_ajax_nopriv_wplc_user_send_offline_message', 'wplc_action_callback' );
|
393 |
+
add_action( 'wp_ajax_wplc_user_send_offline_message', 'wplc_action_callback' );
|
394 |
+
add_action( 'wp_ajax_delete_offline_message', 'wplc_action_callback' );
|
395 |
+
add_action( 'wp_ajax_wplc_a2a_dismiss', 'wplc_action_callback' );
|
396 |
+
add_action( 'activated_plugin', 'wplc_redirect_on_activate' );
|
397 |
+
add_action( 'wp_ajax_wplc_choose_accepting', 'wplc_action_callback' );
|
398 |
+
add_action( 'wp_ajax_wplc_choose_not_accepting', 'wplc_action_callback' );
|
399 |
+
add_action( 'wp_ajax_wplc_agent_list', 'wplc_action_callback' );
|
400 |
+
add_action( 'wplc_hook_action_callback', 'wplc_choose_hook_control_action_callback' );
|
401 |
+
add_action( 'wplc_hook_admin_menu_layout_display_top', 'wplc_ma_hook_control_admin_meny_layout_display_top' );
|
402 |
+
add_action( 'edit_user_profile_update', 'wplc_maa_set_user_as_agent' );
|
403 |
+
add_action( 'personal_options_update', 'wplc_maa_set_user_as_agent' );
|
404 |
+
add_action( 'edit_user_profile', 'wplc_maa_custom_user_profile_fields' );
|
405 |
+
add_action( 'show_user_profile', 'wplc_maa_custom_user_profile_fields' );
|
406 |
+
add_action( 'admin_enqueue_scripts', 'wplc_control_admin_javascript' );
|
407 |
+
add_action( 'wp_ajax_wplc_add_agent', 'wplc_action_callback' );
|
408 |
+
add_action( 'wp_ajax_wplc_remove_agent', 'wplc_action_callback' );
|
409 |
+
add_action( 'wp_ajax_wplc_macro', 'wplc_action_callback' );
|
410 |
+
add_action( 'wp_ajax_wplc_typing', 'wplc_action_callback' );
|
411 |
+
add_action( 'wp_ajax_nopriv_wplc_typing', 'wplc_action_callback' );
|
412 |
+
add_action( 'wp_ajax_wplc_upload_file', 'wplc_action_callback' );
|
413 |
+
add_action( 'wp_ajax_nopriv_wplc_upload_file', 'wplc_action_callback' );
|
414 |
+
add_action( 'wp_ajax_wplc_record_chat_rating', 'wplc_action_callback' );
|
415 |
+
add_action( 'wp_ajax_nopriv_wplc_record_chat_rating', 'wplc_action_callback' );
|
416 |
+
add_action( 'wp_enqueue_scripts', 'wplc_add_user_stylesheet' );
|
417 |
+
add_action( 'admin_enqueue_scripts', 'wplc_add_admin_stylesheet' );
|
418 |
+
add_action( 'admin_menu', 'wplc_admin_menu', 4 );
|
419 |
+
add_action( "wplc_hook_admin_chatbox_javascript", "wplc_features_admin_js" );
|
420 |
+
add_action( 'admin_head', 'wplc_superadmin_javascript' );
|
421 |
add_action( 'admin_notices', 'wplc_deprecated_standalone_pro' );
|
422 |
add_action( 'wp_ajax_wplc_generate_new_node_token', 'wplc_ajax_generate_new_tokens' );
|
423 |
add_action( 'wp_ajax_wplc_new_secret_key', 'wplc_ajax_generate_new_tokens' );
|
424 |
add_action( 'wp_ajax_wplc_generate_new_encryption_key', 'wplc_ajax_generate_new_tokens' );
|
425 |
|
426 |
// Activation Hook
|
427 |
+
register_activation_hook( __FILE__, 'wplc_activate' );
|
428 |
|
429 |
// Uninstall Hook
|
430 |
+
register_uninstall_hook( __FILE__, 'wplc_uninstall' );
|
431 |
|
432 |
function wplc_uninstall() {
|
433 |
global $wpdb;
|
436 |
global $wplc_tblname_msgs;
|
437 |
global $wplc_tblname_chat_ratings;
|
438 |
global $wplc_tblname_chat_triggers;
|
|
|
|
|
|
|
|
|
439 |
|
440 |
+
$wplc_settings = wplc_get_options();
|
441 |
|
442 |
+
if ( $wplc_settings['wplc_delete_db_on_uninstall'] ) {
|
443 |
+
|
444 |
+
$options = array(
|
445 |
+
'WPLC_ACBC_SETTINGS',
|
446 |
+
'wplc_advanced_settings',
|
447 |
+
'wplc_api_key_valid',
|
448 |
+
'wplc_api_secret_token',
|
449 |
+
'WPLC_AUTO_RESPONDER_SETTINGS',
|
450 |
+
'WPLC_BANNED_IP_ADDRESSES',
|
451 |
+
'wplc_bh_settings',
|
452 |
+
'WPLC_CHOOSE_ACCEPTING',
|
453 |
+
'WPLC_CHOOSE_FIRST_RUN',
|
454 |
+
'WPLC_CHOOSE_SETTINGS',
|
455 |
+
'wplc_current_version',
|
456 |
+
'WPLC_CUSTOM_CSS',
|
457 |
+
'WPLC_CUSTOM_JS',
|
458 |
+
'wplc_db_version',
|
459 |
+
'wplc_dismiss_notice_bn',
|
460 |
+
'WPLC_DOC_SUGG_SETTINGS',
|
461 |
+
'WPLC_ENCRYPT_DEPREC_NOTICE_DISMISSED',
|
462 |
+
'WPLC_ENCRYPT_FIRST_RUN',
|
463 |
+
'WPLC_ENCRYPT_SETTINGS',
|
464 |
+
'wplc_end_point_override',
|
465 |
+
'WPLC_ET_FIRST_RUN',
|
466 |
+
'WPLC_ET_SETTINGS',
|
467 |
+
'WPLC_FIRST_TIME_TUTORIAL',
|
468 |
+
'WPLC_GA_SETTINGS',
|
469 |
+
'WPLC_GDPR_DISABLED_WARNING_DISMISSED',
|
470 |
+
'WPLC_GDPR_ENABLED_AT_LEAST_ONCE',
|
471 |
+
'WPLC_GUID',
|
472 |
+
'WPLC_GUID_CHECK',
|
473 |
+
'WPLC_GUID_URL',
|
474 |
+
'wplc_gutenberg_settings',
|
475 |
+
'WPLC_HIDE_CHAT',
|
476 |
+
'WPLC_IC_FIRST_RUN',
|
477 |
+
'WPLC_IC_SETTINGS',
|
478 |
+
'WPLC_INEX_FIRST_RUN',
|
479 |
+
'WPLC_INEX_SETTINGS',
|
480 |
+
'WPLC_ma_FIRST_RUN',
|
481 |
+
'WPLC_ma_SETTINGS',
|
482 |
+
'wplc_mail_host',
|
483 |
+
'wplc_mail_password',
|
484 |
+
'wplc_mail_port',
|
485 |
+
'wplc_mail_type',
|
486 |
+
'wplc_mail_username',
|
487 |
+
'WPLC_MOBILE_FIRST_RUN',
|
488 |
+
'WPLC_MOBILE_SETTINGS',
|
489 |
+
'wplc_node_server_secret_token',
|
490 |
+
'wplc_node_v8_plus_notice_dismissed',
|
491 |
+
'WPLC_POWERED_BY',
|
492 |
+
'wplc_previous_is_typing',
|
493 |
+
'wplc_pro_current_version',
|
494 |
+
'WPLC_PRO_SETTINGS',
|
495 |
+
'WPLC_SETTINGS',
|
496 |
+
'wplc_stats',
|
497 |
+
'WPLC_V8_FIRST_TIME'
|
498 |
+
);
|
499 |
+
|
500 |
+
foreach ( $options as $option ) {
|
501 |
+
delete_option( $option );
|
502 |
}
|
503 |
+
|
504 |
+
unregister_post_type( 'wplc_quick_response' );
|
505 |
+
|
506 |
+
$wpdb->query( "DROP TABLE IF EXISTS {$wplc_tblname_offline_msgs}" );
|
507 |
+
$wpdb->query( "DROP TABLE IF EXISTS {$wplc_tblname_chats }" );
|
508 |
+
$wpdb->query( "DROP TABLE IF EXISTS {$wplc_tblname_msgs }" );
|
509 |
+
$wpdb->query( "DROP TABLE IF EXISTS {$wplc_tblname_chat_ratings }" );
|
510 |
+
$wpdb->query( "DROP TABLE IF EXISTS {$wplc_tblname_chat_triggers }" );
|
511 |
+
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wplc_webhooks" );
|
512 |
+
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wplc_roi_goals" );
|
513 |
+
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wplc_roi_conversions" );
|
514 |
+
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wplc_devices" );
|
515 |
+
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wplc_departments" );
|
516 |
+
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wplc_custom_fields" );
|
517 |
+
|
518 |
+
$admins = get_role( 'administrator' );
|
519 |
+
if ( $admins !== null ) {
|
520 |
+
$admins->remove_cap( 'edit_wplc_quick_response' );
|
521 |
+
$admins->remove_cap( 'edit_wplc_quick_response' );
|
522 |
+
$admins->remove_cap( 'edit_other_wplc_quick_response' );
|
523 |
+
$admins->remove_cap( 'publish_wplc_quick_response' );
|
524 |
+
$admins->remove_cap( 'read_wplc_quick_response' );
|
525 |
+
$admins->remove_cap( 'read_private_wplc_quick_response' );
|
526 |
+
$admins->remove_cap( 'delete_wplc_quick_response' );
|
527 |
+
$admins->remove_cap( 'wplc_ma_agent' );
|
528 |
}
|
529 |
+
|
530 |
$users = wplc_get_agent_users();
|
531 |
+
foreach ( $users as $user ) {
|
532 |
+
delete_user_meta( $user->ID, 'wplc_user_department' );
|
533 |
+
delete_user_meta( $user->ID, 'wplc_ma_agent' );
|
534 |
+
delete_user_meta( $user->ID, 'wplc_user_bio' );
|
535 |
+
delete_user_meta( $user->ID, 'wplc_user_facebook' );
|
536 |
+
delete_user_meta( $user->ID, 'wplc_user_linkedin' );
|
537 |
+
delete_user_meta( $user->ID, 'wplc_user_tagline' );
|
538 |
+
delete_user_meta( $user->ID, 'wplc_user_twitter' );
|
539 |
+
}
|
540 |
}
|
541 |
}
|
542 |
|
543 |
// Plugin initialisation
|
544 |
function wplc_init() {
|
545 |
// Load Languages
|
546 |
+
$plugin_dir = basename( dirname( __FILE__ ) ) . "/languages/";
|
547 |
+
load_plugin_textdomain( 'wp-live-chat-support', false, $plugin_dir );
|
548 |
// Load Agent API
|
549 |
+
require_once( plugin_dir_path( __FILE__ ) . "modules/api/agent/wplc-api.php" );
|
550 |
}
|
551 |
|
552 |
// Show notice if PRO plugin is present in versions < 8.0.27
|
553 |
function wplc_deprecated_standalone_pro() {
|
554 |
+
if ( wplc_is_pro_present() ) {
|
555 |
+
?>
|
556 |
+
<div class="notice notice-error is-dismissible">
|
557 |
+
<p><?php _e( 'The additional WP Live Chat Support PRO plugin which you have installed is no longer needed, please uninstall it.', 'wp-live-chat-support' ); ?></p>
|
558 |
+
</div>
|
559 |
+
<?php
|
560 |
}
|
561 |
}
|
562 |
|
563 |
// If an old PRO plugin is detected disable it as it is not needed anymore.
|
564 |
function wplc_detect_old_pro_plugin() {
|
565 |
+
if ( wplc_is_pro_active( "wp-live-chat-support-pro/wp-live-chat-support-pro.php" ) ) {
|
566 |
+
deactivate_plugins( "wp-live-chat-support-pro/wp-live-chat-support-pro.php" );
|
567 |
+
}
|
568 |
}
|
569 |
|
570 |
/**
|
571 |
* Redirect the user to the welcome page on plugin activate
|
572 |
+
*
|
573 |
+
* @param string $plugin
|
574 |
+
*
|
575 |
* @return void
|
576 |
*/
|
577 |
function wplc_redirect_on_activate( $plugin ) {
|
578 |
+
if ( $plugin == plugin_basename( __FILE__ ) ) {
|
579 |
+
if ( get_option( "WPLC_V8_FIRST_TIME" ) == true ) {
|
580 |
+
update_option( "WPLC_V8_FIRST_TIME", false );
|
581 |
+
// clean the output header and redirect the user
|
582 |
+
@ob_flush();
|
583 |
+
@ob_end_flush();
|
584 |
+
@ob_end_clean();
|
585 |
+
wp_redirect( admin_url( 'admin.php?page=wplivechat-menu&action=wplivechat-menu-dashboard' ) );
|
586 |
+
die;
|
587 |
+
}
|
588 |
+
}
|
589 |
}
|
590 |
+
|
591 |
add_action( 'admin_init', 'wplc_redirect_on_activate' );
|
592 |
|
593 |
|
594 |
function wplc_version_control() {
|
595 |
+
$current_version = get_option( "wplc_current_version" );
|
596 |
+
if ( ! isset( $current_version ) || $current_version != WPLC_PLUGIN_VERSION ) {
|
597 |
+
$wplc_settings = wplc_get_options( true ); // force sanitize on version change
|
598 |
+
/**
|
599 |
+
* Are we updating from a version before version 8?
|
600 |
+
* If yes, set NODE to enabled
|
601 |
+
*/
|
602 |
+
if ( isset( $current_version ) ) {
|
603 |
+
$main_ver = intval( $current_version[0] );
|
604 |
+
if ( $main_ver < 8 ) {
|
605 |
+
if ( $wplc_settings ) {
|
606 |
+
$wplc_settings['wplc_use_node_server'] = true;
|
607 |
+
update_option( "WPLC_V8_FIRST_TIME", true );
|
608 |
+
}
|
609 |
+
}
|
610 |
+
}
|
611 |
+
|
612 |
+
/**
|
613 |
+
* Added for security cleanup prior to version 8.0.31
|
614 |
+
*/
|
615 |
+
if ( isset( $current_version ) ) {
|
616 |
+
if ( intval( str_replace( '.', '', $current_version ) ) < 8031 || intval( str_replace( '.', '', $current_version ) ) < 8032 ) {
|
617 |
+
// Remove all custom JS if previous version was less than 8.0.31 or 8.0.32
|
618 |
+
update_option( "WPLC_CUSTOM_JS", '' );
|
619 |
+
update_option( "WPLC_CUSTOM_CSS", '' );
|
620 |
+
}
|
621 |
+
}
|
622 |
+
|
623 |
+
$wplc_settings = wplc_cleanup_old_options( $wplc_settings );
|
624 |
+
|
625 |
+
// adjust wp caps
|
626 |
+
$admins = get_role( 'administrator' );
|
627 |
+
if ( $admins !== null ) {
|
628 |
+
$admins->add_cap( 'wplc_ma_agent' );
|
629 |
+
}
|
630 |
+
|
631 |
+
$uid = get_current_user_id();
|
632 |
+
update_user_meta( $uid, 'wplc_ma_agent', 1 );
|
633 |
+
wplc_update_agent_time( $uid );
|
634 |
+
|
635 |
+
/* add caps to admin */
|
636 |
+
if ( current_user_can( 'manage_options' ) ) {
|
637 |
+
global $user_ID;
|
638 |
+
$user = new WP_User( $user_ID );
|
639 |
+
foreach ( $user->roles as $urole ) {
|
640 |
+
if ( $urole == "administrator" ) {
|
641 |
+
$admins = get_role( 'administrator' );
|
642 |
+
$admins->add_cap( 'edit_wplc_quick_response' );
|
643 |
+
$admins->add_cap( 'edit_wplc_quick_response' );
|
644 |
+
$admins->add_cap( 'edit_other_wplc_quick_response' );
|
645 |
+
$admins->add_cap( 'publish_wplc_quick_response' );
|
646 |
+
$admins->add_cap( 'read_wplc_quick_response' );
|
647 |
+
$admins->add_cap( 'read_private_wplc_quick_response' );
|
648 |
+
$admins->add_cap( 'delete_wplc_quick_response' );
|
649 |
+
}
|
650 |
+
}
|
651 |
+
}
|
652 |
+
|
653 |
+
wplc_handle_db();
|
654 |
+
update_option( "wplc_current_version", WPLC_PLUGIN_VERSION );
|
655 |
+
|
656 |
+
$wplc_settings = apply_filters( 'wplc_update_settings_between_versions_hook', $wplc_settings ); //Added in 8.0.09
|
657 |
+
ksort( $wplc_settings );
|
658 |
+
update_option( "WPLC_SETTINGS", $wplc_settings );
|
659 |
+
do_action( "wplc_update_hook" );
|
660 |
+
}
|
661 |
+
}
|
662 |
+
|
663 |
+
function wplc_parameter_bool( $settings, $name ) {
|
664 |
+
$param = 0;
|
665 |
+
if ( ! empty( $settings ) && isset( $settings[ $name ] ) ) {
|
666 |
+
$param = intval( $settings[ $name ] );
|
667 |
+
if ( $param != 0 ) {
|
668 |
+
$param = 1;
|
669 |
+
}
|
670 |
+
}
|
671 |
+
|
672 |
+
return $param;
|
673 |
}
|
674 |
|
675 |
function wplc_check_guid() {
|
676 |
+
$guid = get_option( 'WPLC_GUID' );
|
677 |
+
$guid_fqdn = get_option( 'WPLC_GUID_URL' );
|
678 |
+
$guid_lastcheck = intval( get_option( 'WPLC_GUID_CHECK' ) );
|
679 |
+
if ( empty( $guid_lastcheck ) || time() - $guid_lastcheck > 86400 ) { // check at least once per day to ensure guid is updated properly
|
680 |
+
$guid = '';
|
681 |
+
}
|
682 |
+
if ( empty( $guid ) || $guid_fqdn != get_option( 'siteurl' ) ) { // guid not assigned or fqdn is changed since last assignment
|
683 |
+
$wplc_settings = wplc_get_options();
|
684 |
+
$server = wplc_parameter_bool( $wplc_settings, 'wplc_use_node_server' );
|
685 |
+
$gdpr = wplc_parameter_bool( $wplc_settings, 'wplc_gdpr_enabled' );
|
686 |
+
$data_array = array(
|
687 |
+
'method' => 'POST',
|
688 |
+
'body' => array(
|
689 |
+
'method' => 'get_guid',
|
690 |
+
'url' => get_option( 'siteurl' ),
|
691 |
+
'server' => $server,
|
692 |
+
'gdpr' => $gdpr,
|
693 |
+
'version' => WPLC_PLUGIN_VERSION
|
694 |
+
)
|
695 |
+
);
|
696 |
+
$response = wp_remote_post( WPLC_ACTIVATION_SERVER . '/api/v1', $data_array );
|
697 |
+
if ( is_array( $response ) ) {
|
698 |
+
if ( $response['response']['code'] == "200" ) {
|
699 |
+
$data = json_decode( $response['body'], true );
|
700 |
+
if ( $data && isset( $data['guid'] ) ) {
|
701 |
+
update_option( 'WPLC_GUID', sanitize_text_field( $data["guid"] ) );
|
702 |
+
update_option( 'WPLC_GUID_URL', get_option( 'siteurl' ) );
|
703 |
+
update_option( 'WPLC_GUID_CHECK', time() );
|
704 |
+
}
|
705 |
+
}
|
706 |
+
}
|
707 |
+
}
|
708 |
}
|
709 |
|
710 |
function wplc_action_callback() {
|
711 |
+
global $wpdb;
|
712 |
+
$check = check_ajax_referer( 'wplc', 'security' );
|
713 |
+
|
714 |
+
if ( $check == 1 ) {
|
715 |
+
if ( $_POST['action'] == 'wplc_a2a_dismiss' ) {
|
716 |
+
$uid = get_current_user_id();
|
717 |
+
update_user_meta( $uid, 'wplc_a2a_upsell', 1 );
|
718 |
+
} else if ( $_POST['action'] == 'delete_offline_message' ) {
|
719 |
+
global $wplc_tblname_offline_msgs;
|
720 |
+
$mid = intval( $_POST['mid'] );
|
721 |
+
$query = $wpdb->Query( $wpdb->prepare( "DELETE FROM `$wplc_tblname_offline_msgs` WHERE `id` = %d", $mid ) );
|
722 |
+
if ( $query ) {
|
723 |
+
echo 1;
|
724 |
+
}
|
725 |
+
} else if ( $_POST['action'] == "wplc_user_send_offline_message" ) {
|
726 |
+
$cid = wplc_return_chat_id_by_rel_or_id( $_POST['cid'] );
|
727 |
+
$name = sanitize_text_field( $_POST['name'] );
|
728 |
+
$email = sanitize_text_field( $_POST['email'] );
|
729 |
+
$msg = sanitize_text_field( $_POST['msg'] );
|
730 |
+
if ( function_exists( 'wplc_send_offline_msg' ) ) {
|
731 |
+
wplc_send_offline_msg( $name, $email, $msg, $cid );
|
732 |
+
}
|
733 |
+
if ( function_exists( 'wplc_store_offline_message' ) ) {
|
734 |
+
wplc_store_offline_message( $name, $email, $msg );
|
735 |
+
}
|
736 |
+
do_action( "wplc_hook_offline_message", array(
|
737 |
+
"cid" => $cid,
|
738 |
+
"name" => $name,
|
739 |
+
"email" => $email,
|
740 |
+
"url" => get_site_url(),
|
741 |
+
"msg" => $msg
|
742 |
+
) );
|
743 |
+
} else if ( $_POST['action'] == "wplc_admin_set_transient" ) {
|
744 |
+
do_action( "wplc_hook_set_transient" );
|
745 |
+
echo wplc_return_online_agents_array();
|
746 |
+
} else if ( $_POST['action'] == "wplc_admin_remove_transient" ) {
|
747 |
+
do_action( "wplc_hook_remove_transient" );
|
748 |
+
echo wplc_return_online_agents_array();
|
749 |
+
} else if ( $_POST['action'] == 'wplc_hide_ftt' ) {
|
750 |
+
update_option( "WPLC_FIRST_TIME_TUTORIAL", true );
|
751 |
+
}
|
752 |
+
|
753 |
+
do_action( "wplc_hook_action_callback" );
|
754 |
+
}
|
755 |
+
die(); // this is required to return a proper result
|
756 |
}
|
757 |
|
758 |
/**
|
760 |
* @return array
|
761 |
* @since 6.0.00
|
762 |
*/
|
763 |
+
add_filter( "wplc_ma_filter_menu_control", "wplc_filter_control_menu_control", 10, 1 );
|
764 |
function wplc_filter_control_menu_control() {
|
765 |
+
if ( current_user_can( 'wplc_ma_agent' ) ) {
|
766 |
+
$array = array(
|
767 |
+
0 => 'wplc_ma_agent', /* main menu */
|
768 |
+
1 => 'manage_options', /* settings */
|
769 |
+
2 => 'wplc_ma_agent', /* history */
|
770 |
+
3 => 'wplc_ma_agent', /* missed chats */
|
771 |
+
4 => 'wplc_ma_agent', /* offline messages */
|
772 |
+
5 => 'manage_options', /* feedback */
|
773 |
+
);
|
774 |
+
} else if ( current_user_can( 'manage_options' ) ) {
|
775 |
+
$array = array(
|
776 |
+
0 => 'manage_options', /* main menu */
|
777 |
+
1 => 'manage_options', /* settings */
|
778 |
+
2 => 'manage_options', /* history */
|
779 |
+
3 => 'manage_options', /* missed chats */
|
780 |
+
4 => 'manage_options', /* offline messages */
|
781 |
+
5 => 'manage_options', /* feedback */
|
782 |
+
);
|
783 |
+
} else {
|
784 |
+
$array = array(
|
785 |
+
0 => 'manage_options', /* main menu */
|
786 |
+
1 => 'manage_options', /* settings */
|
787 |
+
2 => 'manage_options', /* history */
|
788 |
+
3 => 'manage_options', /* missed chats */
|
789 |
+
4 => 'manage_options', /* offline messages */
|
790 |
+
5 => 'manage_options', /* feedback */
|
791 |
+
);
|
792 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
793 |
|
794 |
+
return $array;
|
795 |
+
}
|
796 |
+
|
797 |
+
add_action( 'admin_init', 'wplc_metric_dashboard_redirect' );
|
798 |
+
function wplc_metric_dashboard_redirect() {
|
799 |
+
try {
|
800 |
+
$cap = apply_filters( "wplc_ma_filter_menu_control", array() );
|
801 |
+
if ( current_user_can( $cap[1] ) ) {
|
802 |
+
if ( isset( $_GET['page'] ) ) {
|
803 |
+
if ( $_GET['page'] === 'wplivechat-menu' ) {
|
804 |
+
// check if we are overriding this redirect because the user pressed the "Chat now" button in the dashboard
|
805 |
+
if ( isset( $_GET['subaction'] ) && $_GET['subaction'] == 'override' ) {
|
806 |
+
} else {
|
807 |
+
if ( ! isset( $_COOKIE['wplcfirstsession'] ) ) {
|
808 |
+
@setcookie( "wplcfirstsession", true, time() + ( 60 * 60 * 24 ) ); // 60s * 60m * 24h (Life span of cookie)
|
809 |
+
@Header( "Location: ./admin.php?page=wplivechat-menu-dashboard" );
|
810 |
+
exit();
|
811 |
+
}
|
812 |
+
}
|
813 |
+
|
814 |
+
}
|
815 |
+
}
|
816 |
+
}
|
817 |
+
} catch ( Exception $ex ) {
|
818 |
|
819 |
+
}
|
820 |
}
|
821 |
|
822 |
function wplc_admin_menu() {
|
823 |
+
$cap = apply_filters( "wplc_ma_filter_menu_control", array() );
|
824 |
+
/* If user is either an agent or an admin, access the page. */
|
825 |
+
if ( wplc_user_is_agent() || current_user_can( "wplc_ma_agent" ) ) {
|
826 |
+
add_menu_page( 'WP Live Chat', __( 'Live Chat', 'wp-live-chat-support' ), $cap[0], 'wplivechat-menu', 'wplc_admin_menu_layout', 'dashicons-format-chat' );
|
827 |
+
add_submenu_page( 'wplivechat-menu', __( 'Dashboard', 'wp-live-chat-support' ), __( 'Dashboard', 'wp-live-chat-support' ), $cap[1], 'wplivechat-menu-dashboard', 'wplc_admin_dashboard_layout' );
|
828 |
+
add_submenu_page( 'wplivechat-menu', __( 'Settings', 'wp-live-chat-support' ), __( 'Settings', 'wp-live-chat-support' ), $cap[1], 'wplivechat-menu-settings', 'wplc_admin_settings_layout' );
|
829 |
+
}
|
830 |
+
|
831 |
+
/* only if user is both an agent and an admin that has the cap assigned, can they access these pages */
|
832 |
+
if ( wplc_user_is_agent() && current_user_can( "wplc_ma_agent" ) ) {
|
833 |
+
add_submenu_page( 'wplivechat-menu', __( 'History', 'wp-live-chat-support' ), __( 'History', 'wp-live-chat-support' ), $cap[2], 'wplivechat-menu-history', 'wplc_admin_history_layout' );
|
834 |
+
add_submenu_page( 'wplivechat-menu', __( 'Missed Chats', 'wp-live-chat-support' ), __( 'Missed Chats', 'wp-live-chat-support' ), $cap[3], 'wplivechat-menu-missed-chats', 'wplc_admin_missed_chats' );
|
835 |
+
add_submenu_page( 'wplivechat-menu', __( 'Offline Messages', 'wp-live-chat-support' ), __( 'Offline Messages', 'wp-live-chat-support' ), $cap[4], 'wplivechat-menu-offline-messages', 'wplc_admin_offline_messages' );
|
836 |
+
do_action( "wplc_hook_menu_mid", $cap );
|
837 |
+
add_submenu_page( 'wplivechat-menu', __( 'Support', 'wp-live-chat-support' ), __( 'Support', 'wp-live-chat-support' ), 'manage_options', 'wplivechat-menu-support-page', 'wplc_support_menu' );
|
838 |
+
}
|
839 |
+
do_action( "wplc_hook_menu" );
|
840 |
+
}
|
841 |
+
|
842 |
+
|
843 |
+
add_action( "wplc_hook_menu", "wplc_hook_control_menu" );
|
844 |
function wplc_hook_control_menu() {
|
845 |
+
$check = apply_filters( "wplc_filter_menu_api", 0 );
|
846 |
}
|
847 |
|
848 |
/**
|
850 |
* @return void
|
851 |
* @since 6.0.00
|
852 |
*/
|
853 |
+
add_action( "wplc_hook_menu_mid", "wplc_mid_hook_control_menu", 10, 1 );
|
854 |
+
function wplc_mid_hook_control_menu( $cap ) {
|
855 |
+
add_submenu_page( 'wplivechat-menu', __( 'Reports', 'wp-live-chat-support' ), __( 'Reports', 'edit_posts' ), $cap[1], 'wplivechat-menu-reporting', 'wplc_reporting_page' );
|
856 |
+
add_submenu_page( 'wplivechat-menu', __( 'Triggers', 'wp-live-chat-support' ), __( 'Triggers', 'edit_posts' ), $cap[1], 'wplivechat-menu-triggers', 'wplc_triggers_page' );
|
857 |
+
add_submenu_page( 'wplivechat-menu', __( 'Custom Fields', 'wp-live-chat-support' ), __( 'Custom Fields', 'edit_posts' ), $cap[1], 'wplivechat-menu-custom-fields', 'wplc_custom_fields_page' );
|
858 |
}
|
859 |
|
860 |
|
861 |
+
add_action( "wp_head", "wplc_load_user_js", 0 );
|
862 |
+
|
863 |
|
864 |
+
function wplc_load_user_js() {
|
865 |
+
if ( ! is_admin() ) {
|
866 |
+
if ( in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) ) {
|
867 |
+
return false;
|
868 |
+
}
|
869 |
|
870 |
+
if ( function_exists( 'wplc_is_user_banned' ) ) {
|
871 |
+
$user_banned = wplc_is_user_banned();
|
872 |
+
} else {
|
873 |
+
$user_banned = 0;
|
874 |
+
}
|
875 |
|
876 |
+
$display_contents = wplc_display_chat_contents();
|
|
|
|
|
|
|
|
|
|
|
|
|
877 |
|
878 |
+
if ( $display_contents && $user_banned == 0 ) {
|
879 |
+
if ( ! class_exists( 'Mobile_Detect' ) ) {
|
880 |
+
require_once( plugin_dir_path( __FILE__ ) . 'includes/Mobile_Detect.php' );
|
881 |
+
}
|
882 |
+
$wplc_detect_device = new Mobile_Detect;
|
883 |
+
$wplc_is_mobile = $wplc_detect_device->isMobile();
|
884 |
+
wplc_push_js_to_front();
|
885 |
+
}
|
886 |
+
}
|
887 |
}
|
888 |
|
889 |
function wplc_push_js_to_front() {
|
890 |
+
global $wplc_is_mobile;
|
891 |
+
global $wplc_default_settings_array;
|
892 |
|
893 |
+
wp_register_script( 'wplc-user-jquery-cookie', wplc_plugins_url( '/js/jquery-cookie.js', __FILE__ ), array( 'jquery' ), WPLC_PLUGIN_VERSION, true );
|
894 |
+
wp_enqueue_script( 'wplc-user-jquery-cookie' );
|
895 |
|
896 |
+
wp_enqueue_script( 'jquery' );
|
897 |
|
898 |
+
wplc_register_common_node();
|
899 |
|
900 |
+
$wplc_settings = wplc_get_options();
|
901 |
+
$wplc_ga_enabled = get_option( "WPLC_GA_SETTINGS" );
|
902 |
|
903 |
+
if ( $wplc_settings['wplc_display_to_loggedin_only'] ) {
|
904 |
+
/* Only show to users that are logged in */
|
905 |
+
if ( ! is_user_logged_in() ) {
|
906 |
+
return;
|
907 |
+
}
|
908 |
+
}
|
909 |
|
910 |
+
/* is the chat enabled? */
|
911 |
+
if ( $wplc_settings["wplc_settings_enabled"] == 2 ) {
|
912 |
+
return;
|
913 |
+
}
|
914 |
|
915 |
+
wp_register_script( 'wplc-md5', wplc_plugins_url( '/js/md5.js', __FILE__ ), array( 'wplc-user-script' ), WPLC_PLUGIN_VERSION, true );
|
916 |
+
wp_enqueue_script( 'wplc-md5' );
|
917 |
|
918 |
+
$ajax_nonce = wp_create_nonce( "wplc" );
|
919 |
+
$ajaxurl = admin_url( 'admin-ajax.php' );
|
920 |
+
$wplc_ajaxurl = $ajaxurl;
|
921 |
|
922 |
+
wp_register_script( 'wplc-server-script', wplc_plugins_url( '/js/wplc_server.js', __FILE__ ), array( 'jquery' ), WPLC_PLUGIN_VERSION, true );
|
923 |
+
wp_enqueue_script( 'wplc-server-script' );
|
924 |
|
925 |
+
wp_localize_script( 'wplc-server-script', 'wplc_datetime_format', array(
|
926 |
+
'date_format' => get_option( 'date_format' ),
|
927 |
'time_format' => get_option( 'time_format' ),
|
928 |
) );
|
929 |
|
930 |
+
if ( $wplc_settings['wplc_use_node_server'] ) {
|
931 |
+
wp_localize_script( 'wplc-server-script', 'tcx_api_key', wplc_node_server_token_get() );
|
932 |
+
wp_register_script( 'wplc-node-server-script', WPLC_PLUGIN_URL . "js/vendor/sockets.io/socket.io.slim.js", array( 'jquery' ), WPLC_PLUGIN_VERSION, true );
|
933 |
+
wp_enqueue_script( 'wplc-node-server-script' );
|
934 |
+
wp_register_script( 'wplc-user-events-script', wplc_plugins_url( '/js/wplc_u_node_events.js', __FILE__ ), array(
|
935 |
+
'jquery',
|
936 |
+
'wplc-server-script'
|
937 |
+
), WPLC_PLUGIN_VERSION, true );
|
938 |
+
/* Not used in front-end
|
939 |
wp_localize_script('wplc-server-script', 'tcx_override_upload_url', rest_url( 'wp_live_chat_support/v1/remote_upload' ) );
|
940 |
*/
|
941 |
|
942 |
+
//For node verification
|
943 |
+
wp_localize_script( 'wplc-server-script', 'wplc_guid', get_option( 'WPLC_GUID', '' ) );
|
944 |
+
|
945 |
+
//Emoji Libs
|
946 |
+
if ( ! $wplc_settings['wplc_disable_emojis'] ) {
|
947 |
+
wp_register_script( 'wplc-user-js-emoji-concat', WPLC_PLUGIN_URL . "js/vendor/wdt-emoji/wdt-emoji-concat.min.js", array(
|
948 |
+
"wplc-server-script",
|
949 |
+
"wplc-server-script"
|
950 |
+
), WPLC_PLUGIN_VERSION, false );
|
951 |
+
wp_enqueue_script( 'wplc-user-js-emoji-concat' );
|
952 |
+
wp_register_style( 'wplc-admin-style-emoji', WPLC_PLUGIN_URL . "js/vendor/wdt-emoji/wdt-emoji-bundle.css", array(), WPLC_PLUGIN_VERSION );
|
953 |
wp_enqueue_style( 'wplc-admin-style-emoji' );
|
954 |
}
|
955 |
+
wp_register_script( 'wplc-user-node-node-primary', wplc_plugins_url( '/js/wplc_node.js', __FILE__ ), array(
|
956 |
+
'jquery',
|
957 |
+
'wplc-server-script',
|
958 |
+
'wplc-user-script'
|
959 |
+
), WPLC_PLUGIN_VERSION, true );
|
960 |
+
wp_enqueue_script( 'wplc-user-node-node-primary' );
|
961 |
+
wp_localize_script( 'wplc-user-node-node-primary', 'wplc_strings', array(
|
962 |
+
'restart_chat' => __( 'Restart Chat', 'wp-live-chat-support' )
|
963 |
+
) );
|
964 |
+
} else {
|
965 |
+
/* not using the node server, load traditional event handler JS */
|
966 |
+
wp_register_script( 'wplc-user-events-script', wplc_plugins_url( '/js/wplc_u_events.js', __FILE__ ), array(
|
967 |
+
'jquery',
|
968 |
+
'wplc-server-script'
|
969 |
+
), WPLC_PLUGIN_VERSION, true );
|
970 |
+
}
|
971 |
+
|
972 |
+
wp_register_script( 'wplc-user-script', wplc_plugins_url( '/js/wplc_u.js', __FILE__ ), array(
|
973 |
+
'jquery',
|
974 |
+
'wplc-server-script'
|
975 |
+
), WPLC_PLUGIN_VERSION, true );
|
976 |
+
|
977 |
+
wp_enqueue_script( 'wplc-user-script' );
|
978 |
+
wp_enqueue_script( 'wplc-user-events-script' );
|
979 |
+
|
980 |
+
switch ( $wplc_settings['wplc_newtheme'] ) {
|
981 |
+
case 'theme-1':
|
982 |
+
wp_register_script( 'wplc-theme-classic', wplc_plugins_url( '/js/themes/classic.js', __FILE__ ), array( 'wplc-user-script' ), WPLC_PLUGIN_VERSION, true );
|
983 |
+
wp_enqueue_script( 'wplc-theme-classic' );
|
984 |
+
$avatars = wplc_all_avatars();
|
985 |
+
wp_localize_script( 'wplc-theme-classic', 'wplc_user_avatars', $avatars );
|
986 |
+
break;
|
987 |
+
|
988 |
+
default:
|
989 |
+
wp_register_script( 'wplc-theme-modern', wplc_plugins_url( '/js/themes/modern.js', __FILE__ ), array( 'wplc-user-script' ), WPLC_PLUGIN_VERSION, true );
|
990 |
+
wp_enqueue_script( 'wplc-theme-modern' );
|
991 |
+
$avatars = wplc_all_avatars();
|
992 |
+
wp_localize_script( 'wplc-theme-modern', 'wplc_user_avatars', $avatars );
|
993 |
+
break;
|
994 |
+
}
|
995 |
+
|
996 |
+
$ajax_url = admin_url( 'admin-ajax.php' );
|
997 |
+
$home_ajax_url = $ajax_url;
|
998 |
+
|
999 |
+
$wplc_ajax_url = apply_filters( "wplc_filter_ajax_url", $ajax_url );
|
1000 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_ajaxurl', $wplc_ajax_url );
|
1001 |
+
wp_localize_script( 'wplc-ma-js', 'wplc_home_ajaxurl', $home_ajax_url );
|
1002 |
+
|
1003 |
+
//Added rest security nonces
|
1004 |
+
if ( class_exists( "WP_REST_Request" ) ) {
|
1005 |
+
wp_localize_script( 'wplc-user-script', 'wplc_restapi_enabled', array( 'value' => true ) );
|
1006 |
+
wp_localize_script( 'wplc-user-script', 'wplc_restapi_token', get_option( 'wplc_api_secret_token' ) );
|
1007 |
+
wp_localize_script( 'wplc-user-script', 'wplc_restapi_endpoint', rest_url( 'wp_live_chat_support/v1' ) );
|
1008 |
+
wp_localize_script( 'wplc-user-script', 'wplc_restapi_nonce', wp_create_nonce( 'wp_rest' ) );
|
1009 |
+
} else {
|
1010 |
+
wp_localize_script( 'wplc-user-script', 'wplc_restapi_enabled', array( 'value' => false ) );
|
1011 |
+
wp_localize_script( 'wplc-user-script', 'wplc_restapi_nonce', null );
|
1012 |
+
}
|
1013 |
+
|
1014 |
+
if ( isset( $wplc_ga_enabled['wplc_enable_ga'] ) && $wplc_ga_enabled['wplc_enable_ga'] == '1' ) {
|
1015 |
+
//wp_localize_script('wplc-user-script', 'wplc_enable_ga', '1'); TODO: check and re-enable
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
wp_localize_script( 'wplc-user-script', 'tcx_message_override', apply_filters( 'wplc_filter_message_sound', '' ) );
|
1019 |
+
|
1020 |
+
$wplc_detect_device = new Mobile_Detect;
|
1021 |
+
$wplc_is_mobile = $wplc_detect_device->isMobile() ? 'true' : 'false';
|
1022 |
+
wp_localize_script( 'wplc-user-script', 'wplc_is_mobile', $wplc_is_mobile );
|
1023 |
+
|
1024 |
+
wp_localize_script( 'wplc-user-script', 'wplc_ajaxurl', $wplc_ajax_url );
|
1025 |
+
wp_localize_script( 'wplc-user-script', 'wplc_ajaxurl_site', admin_url( 'admin-ajax.php' ) );
|
1026 |
+
wp_localize_script( 'wplc-user-script', 'wplc_nonce', $ajax_nonce );
|
1027 |
+
wp_localize_script( 'wplc-user-script', 'wplc_plugin_url', WPLC_PLUGIN_URL );
|
1028 |
+
|
1029 |
+
$wplc_images = apply_filters( 'wplc_get_images_to_preload', array(), $wplc_settings );
|
1030 |
+
wp_localize_script( 'wplc-user-script', 'wplc_preload_images', $wplc_images );
|
1031 |
+
|
1032 |
+
$wplc_chat_detail = array(
|
1033 |
+
'name' => $wplc_settings['wplc_show_name'],
|
1034 |
+
'avatar' => $wplc_settings['wplc_show_avatar'],
|
1035 |
+
'date' => $wplc_settings['wplc_show_date'],
|
1036 |
+
'time' => $wplc_settings['wplc_show_time']
|
1037 |
+
);
|
1038 |
+
|
1039 |
+
wp_localize_script( 'wplc-user-script', 'wplc_show_chat_detail', $wplc_chat_detail );
|
1040 |
+
|
1041 |
+
/**
|
1042 |
+
* Create a JS object for all Agent ID's and Gravatar MD5's
|
1043 |
+
*/
|
1044 |
+
$user_array = wplc_get_agent_users();
|
1045 |
+
$a_array = array();
|
1046 |
+
foreach ( $user_array as $user ) {
|
1047 |
+
$a_array[ $user->ID ] = array();
|
1048 |
+
$a_array[ $user->ID ]['name'] = apply_filters( "wplc_decide_agents_name", sanitize_text_field( $user->display_name ), $wplc_settings );
|
1049 |
+
$a_array[ $user->ID ]['md5'] = md5( $user->user_email );
|
1050 |
+
$a_array[ $user->ID ]['tagline'] = get_user_meta( $user->ID, 'wplc_user_tagline', true );
|
1051 |
+
}
|
1052 |
+
wp_localize_script( 'wplc-user-script', 'wplc_agent_data', $a_array );
|
1053 |
|
1054 |
$wplc_error_messages = array(
|
1055 |
+
'please_enter_name' => __( "Please enter your name", 'wp-live-chat-support' ),
|
1056 |
+
'please_enter_email' => __( "Please enter your email address", 'wp-live-chat-support' ),
|
1057 |
+
'please_enter_valid_email' => __( "Please enter a valid email address", 'wp-live-chat-support' ),
|
1058 |
+
'server_connection_lost' => __( "Connection to Server Lost. Please Reload This Page. Error:", 'wp-live-chat-support' ) . ' ',
|
1059 |
+
'chat_ended_by_operator' => ( empty( $wplc_settings['wplc_text_chat_ended'] ) ) ? __( "The chat has been ended by the agent.", 'wp-live-chat-support' ) : sanitize_text_field( $wplc_settings['wplc_text_chat_ended'] ),
|
1060 |
+
'empty_message' => __( "Please Enter a Message", 'wp-live-chat-support' ),
|
1061 |
+
'disconnected_message' => __( "Disconnected, Attempting to Reconnect...", 'wp-live-chat-support' ),
|
1062 |
+
);
|
1063 |
+
|
1064 |
+
$wplc_error_messages = apply_filters( "wplc_user_error_messages_filter", $wplc_error_messages );
|
1065 |
+
|
1066 |
+
wp_localize_script( 'wplc-user-script', 'wplc_error_messages', $wplc_error_messages );
|
1067 |
+
wp_localize_script( 'wplc-user-script', 'wplc_enable_ding', array( 'value' => boolval( $wplc_settings['wplc_enable_msg_sound'] ) ) );
|
1068 |
+
$wplc_run_override = apply_filters( "wplc_filter_run_override", $wplc_run_override = 0 );
|
1069 |
+
wp_localize_script( 'wplc-user-script', 'wplc_filter_run_override', array( 'value' => boolval( $wplc_run_override ) ) );
|
1070 |
+
|
1071 |
+
if ( ! isset( $wplc_settings['wplc_pro_offline1'] ) ) {
|
1072 |
+
$wplc_settings["wplc_pro_offline1"] = $wplc_default_settings_array['wplc_pro_offline1'];
|
1073 |
+
}
|
1074 |
+
if ( ! isset( $wplc_settings['wplc_pro_offline2'] ) ) {
|
1075 |
+
$wplc_settings["wplc_pro_offline2"] = $wplc_default_settings_array['wplc_pro_offline2'];
|
1076 |
+
}
|
1077 |
+
if ( ! isset( $wplc_settings['wplc_pro_offline3'] ) ) {
|
1078 |
+
$wplc_settings["wplc_pro_offline3"] = $wplc_default_settings_array['wplc_pro_offline3'];
|
1079 |
+
}
|
1080 |
+
|
1081 |
+
wp_localize_script( 'wplc-user-script', 'wplc_offline_msg', __( stripslashes( $wplc_settings['wplc_pro_offline2'] ), 'wp-live-chat-support' ) );
|
1082 |
+
wp_localize_script( 'wplc-user-script', 'wplc_offline_msg3', __( stripslashes( $wplc_settings['wplc_pro_offline3'] ), 'wp-live-chat-support' ) );
|
1083 |
+
wp_localize_script( 'wplc-user-script', 'wplc_welcome_msg', __( stripslashes( $wplc_settings['wplc_welcome_msg'] ), 'wp-live-chat-support' ) );
|
1084 |
+
wp_localize_script( 'wplc-user-script', 'wplc_pro_sst1', __( stripslashes( $wplc_settings['wplc_pro_sst1'] ), 'wp-live-chat-support' ) );
|
1085 |
+
wp_localize_script( 'wplc-user-script', 'wplc_pro_offline_btn_send', __( stripslashes( $wplc_settings['wplc_pro_offline_btn_send'] ), 'wp-live-chat-support' ) );
|
1086 |
+
wp_localize_script( 'wplc-user-script', 'wplc_user_default_visitor_name', wplc_get_user_name( '', $wplc_settings ) );
|
1087 |
+
|
1088 |
+
if ( $wplc_settings['wplc_use_wp_name'] ) {
|
1089 |
+
if ( isset( $_COOKIE['wplc_cid'] ) ) {
|
1090 |
+
$chat_data = wplc_get_chat_data( $_COOKIE['wplc_cid'] );
|
1091 |
+
if ( isset( $chat_data->agent_id ) ) {
|
1092 |
+
$user_info = get_userdata( intval( $chat_data->agent_id ) );
|
1093 |
+
if ( $user_info ) {
|
1094 |
+
$agent = $user_info->display_name;
|
1095 |
+
} else {
|
1096 |
+
$agent = "agent";
|
1097 |
+
}
|
1098 |
+
} else {
|
1099 |
+
$agent = 'agent';
|
1100 |
+
}
|
1101 |
+
} else {
|
1102 |
+
$agent = 'agent';
|
1103 |
+
}
|
1104 |
+
} else {
|
1105 |
+
if ( ! empty( $wplc_settings['wplc_chat_name'] ) ) {
|
1106 |
+
$agent = $wplc_settings['wplc_chat_name'];
|
1107 |
+
} else {
|
1108 |
+
$agent = 'agent';
|
1109 |
+
}
|
1110 |
+
}
|
1111 |
+
wp_localize_script( 'wplc-user-script', 'wplc_localized_string_is_typing', sanitize_text_field( $agent ) . ' ' . __( "is typing...", 'wp-live-chat-support' ) );
|
1112 |
+
|
1113 |
+
$tcx_string_array = array(
|
1114 |
+
' ' . __( "has joined.", 'wp-live-chat-support' ),
|
1115 |
+
' ' . __( "has left.", 'wp-live-chat-support' ),
|
1116 |
+
' ' . __( "has ended the chat.", 'wp-live-chat-support' ),
|
1117 |
+
' ' . __( "has disconnected.", 'wp-live-chat-support' ),
|
1118 |
+
__( "(edited)", 'wp-live-chat-support' ),
|
1119 |
+
__( "Type here", 'wp-live-chat-support' )
|
1120 |
+
);
|
1121 |
+
|
1122 |
+
wp_localize_script( 'wplc-user-script', 'tcx_localized_strings', $tcx_string_array );
|
1123 |
+
|
1124 |
+
if ( ! empty( $wplc_settings['wplc_elem_trigger_id'] ) ) {
|
1125 |
+
$wplc_elem_trigger = array(
|
1126 |
+
'action' => intval( $wplc_settings['wplc_elem_trigger_action'] ),
|
1127 |
+
'type' => intval( $wplc_settings['wplc_elem_trigger_type'] ),
|
1128 |
+
'id' => htmlentities( $wplc_settings['wplc_elem_trigger_id'] )
|
1129 |
+
);
|
1130 |
+
wp_localize_script( 'wplc-user-script', 'wplc_elem_trigger', $wplc_elem_trigger );
|
1131 |
+
}
|
1132 |
+
|
1133 |
+
$extra_data_array = array( "object_switch" => true );
|
1134 |
+
$extra_data_array = apply_filters( "wplc_filter_front_js_extra_data", $extra_data_array );
|
1135 |
+
wp_localize_script( 'wplc-user-script', 'wplc_extra_data', $extra_data_array );
|
1136 |
+
|
1137 |
+
if ( isset( $_COOKIE['wplc_email'] ) && $_COOKIE['wplc_email'] != "" ) {
|
1138 |
+
$wplc_user_gravatar = sanitize_text_field( md5( strtolower( trim( $_COOKIE['wplc_email'] ) ) ) );
|
1139 |
+
} else {
|
1140 |
+
$wplc_user_gravatar = "";
|
1141 |
+
}
|
1142 |
+
|
1143 |
+
if ( $wplc_user_gravatar != "" ) {
|
1144 |
+
$wplc_grav_image = "<img src='//www.gravatar.com/avatar/$wplc_user_gravatar?s=30&d=mm' class='wplc-user-message-avatar' />";
|
1145 |
+
} else {
|
1146 |
+
$wplc_grav_image = "";
|
1147 |
+
}
|
1148 |
|
1149 |
if ( ! empty( $wplc_grav_image ) ) {
|
1150 |
+
wp_localize_script( 'wplc-user-script', 'wplc_gravatar_image', $wplc_grav_image );
|
1151 |
+
}
|
1152 |
|
1153 |
+
if ( isset( $wplc_settings['wplc_redirect_to_thank_you_page'] ) && isset( $wplc_settings['wplc_redirect_thank_you_url'] ) && $wplc_settings['wplc_redirect_thank_you_url'] !== "" && $wplc_settings['wplc_redirect_thank_you_url'] !== " " ) {
|
1154 |
+
wp_localize_script( 'wplc-user-script', 'wplc_redirect_thank_you', urldecode( $wplc_settings['wplc_redirect_thank_you_url'] ) );
|
1155 |
+
}
|
1156 |
|
1157 |
+
wp_enqueue_script( 'jquery-ui-core', false, array( 'wplc-user-script' ), false, false );
|
1158 |
+
wp_enqueue_script( 'jquery-ui-draggable', false, array( 'wplc-user-script' ), false, false );
|
1159 |
|
1160 |
+
do_action( "wplc_hook_push_js_to_front" );
|
1161 |
}
|
1162 |
|
1163 |
+
add_action( 'wp_head', 'wplc_user_top_js' );
|
1164 |
|
1165 |
|
1166 |
/**
|
1167 |
* Add to the array to determine which images need to be preloaded via JS on the front end.
|
1168 |
*
|
1169 |
+
* @param array $images Array of images to be preloaded
|
1170 |
+
*
|
1171 |
* @return array
|
1172 |
*/
|
1173 |
add_filter( "wplc_get_images_to_preload", "wplc_filter_control_get_images_to_preload", 10, 2 );
|
1174 |
function wplc_filter_control_get_images_to_preload( $images, $wplc_settings ) {
|
1175 |
+
$icon = wplc_plugins_url( '/images/iconRetina.png', __FILE__ );
|
1176 |
+
$close_icon = wplc_plugins_url( '/images/iconCloseRetina.png', __FILE__ );
|
1177 |
array_push( $images, $icon );
|
1178 |
array_push( $images, $close_icon );
|
1179 |
+
|
1180 |
return $images;
|
1181 |
}
|
1182 |
|
1183 |
function wplc_user_top_js() {
|
1184 |
+
$display_contents = wplc_display_chat_contents();
|
1185 |
+
|
1186 |
+
if ( $display_contents ) {
|
1187 |
+
$ajax_nonce = wp_create_nonce( "wplc" );
|
1188 |
+
$wplc_settings = wplc_get_options();
|
1189 |
+
$ajax_url = admin_url( 'admin-ajax.php' );
|
1190 |
+
$wplc_ajax_url = apply_filters( "wplc_filter_ajax_url", $ajax_url );
|
1191 |
+
$wplc_theme = wplc_get_theme();
|
1192 |
+
?>
|
1193 |
+
<script type="text/javascript">
|
1194 |
+
var wplc_ajaxurl = '<?php echo $wplc_ajax_url; ?>';
|
1195 |
+
var wplc_nonce = '<?php echo $ajax_nonce; ?>';
|
1196 |
+
</script>
|
1197 |
+
<?php
|
1198 |
+
|
1199 |
+
if ( $wplc_theme == 'theme-6' ) {
|
1200 |
+
/* custom */
|
1201 |
+
if ( isset( $wplc_settings["wplc_settings_color1"] ) ) {
|
1202 |
+
$wplc_settings_color1 = sanitize_text_field( $wplc_settings["wplc_settings_color1"] );
|
1203 |
+
} else {
|
1204 |
+
$wplc_settings_color1 = "0596d4";
|
1205 |
+
}
|
1206 |
+
if ( isset( $wplc_settings["wplc_settings_color2"] ) ) {
|
1207 |
+
$wplc_settings_color2 = sanitize_text_field( $wplc_settings["wplc_settings_color2"] );
|
1208 |
+
} else {
|
1209 |
+
$wplc_settings_color2 = "FFFFFF";
|
1210 |
+
}
|
1211 |
+
if ( isset( $wplc_settings["wplc_settings_color3"] ) ) {
|
1212 |
+
$wplc_settings_color3 = sanitize_text_field( $wplc_settings["wplc_settings_color3"] );
|
1213 |
+
} else {
|
1214 |
+
$wplc_settings_color3 = "EEEEEE";
|
1215 |
+
}
|
1216 |
+
if ( isset( $wplc_settings["wplc_settings_color4"] ) ) {
|
1217 |
+
$wplc_settings_color4 = sanitize_text_field( $wplc_settings["wplc_settings_color4"] );
|
1218 |
+
} else {
|
1219 |
+
$wplc_settings_color4 = "373737";
|
1220 |
+
}
|
1221 |
+
?>
|
1222 |
+
<style>
|
1223 |
+
.wplc-color-1 {
|
1224 |
+
color: # <?php echo $wplc_settings_color1; ?> !important;
|
1225 |
+
}
|
1226 |
+
|
1227 |
+
.wplc-color-2 {
|
1228 |
+
color: # <?php echo $wplc_settings_color2; ?> !important;
|
1229 |
+
}
|
1230 |
+
|
1231 |
+
.wplc-color-3 {
|
1232 |
+
color: # <?php echo $wplc_settings_color3; ?> !important;
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
.wplc-color-4 {
|
1236 |
+
color: # <?php echo $wplc_settings_color4; ?> !important;
|
1237 |
+
}
|
1238 |
+
|
1239 |
+
.wplc-color-bg-1 {
|
1240 |
+
background-color: # <?php echo $wplc_settings_color1; ?> !important;
|
1241 |
+
}
|
1242 |
+
|
1243 |
+
.wplc-color-bg-2 {
|
1244 |
+
background-color: # <?php echo $wplc_settings_color2; ?> !important;
|
1245 |
+
}
|
1246 |
+
|
1247 |
+
.wplc-color-bg-3 {
|
1248 |
+
background-color: # <?php echo $wplc_settings_color3; ?> !important;
|
1249 |
+
}
|
1250 |
+
|
1251 |
+
.wplc-color-bg-4 {
|
1252 |
+
background-color: # <?php echo $wplc_settings_color4; ?> !important;
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
.wplc-color-border-1 {
|
1256 |
+
border-color: # <?php echo $wplc_settings_color1; ?> !important;
|
1257 |
+
}
|
1258 |
+
|
1259 |
+
.wplc-color-border-2 {
|
1260 |
+
border-color: # <?php echo $wplc_settings_color2; ?> !important;
|
1261 |
+
}
|
1262 |
+
|
1263 |
+
.wplc-color-border-3 {
|
1264 |
+
border-color: # <?php echo $wplc_settings_color3; ?> !important;
|
1265 |
+
}
|
1266 |
+
|
1267 |
+
.wplc-color-border-4 {
|
1268 |
+
border-color: # <?php echo $wplc_settings_color4; ?> !important;
|
1269 |
+
}
|
1270 |
+
|
1271 |
+
.wplc-color-border-1:before {
|
1272 |
+
border-color: transparent # <?php echo $wplc_settings_color1; ?> !important;
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
.wplc-color-border-2:before {
|
1276 |
+
border-color: transparent # <?php echo $wplc_settings_color2; ?> !important;
|
1277 |
+
}
|
1278 |
+
|
1279 |
+
.wplc-color-border-3:before {
|
1280 |
+
border-color: transparent # <?php echo $wplc_settings_color3; ?> !important;
|
1281 |
+
}
|
1282 |
+
|
1283 |
+
.wplc-color-border-4:before {
|
1284 |
+
border-color: transparent # <?php echo $wplc_settings_color4; ?> !important;
|
1285 |
+
}
|
1286 |
+
</style>
|
1287 |
+
<?php
|
1288 |
+
}
|
1289 |
+
}
|
1290 |
}
|
1291 |
|
1292 |
/**
|
1295 |
* @since 6.0.00
|
1296 |
*/
|
1297 |
function wplc_hook_control_banned_users() {
|
1298 |
+
if ( function_exists( 'wplc_is_user_banned' ) ) {
|
1299 |
+
$user_banned = wplc_is_user_banned();
|
1300 |
+
} else {
|
1301 |
+
$user_banned = 0;
|
1302 |
+
}
|
1303 |
+
if ( $user_banned ) {
|
1304 |
+
remove_action( "wplc_hook_output_box_body", "wplc_hook_control_show_chat_box" );
|
1305 |
+
}
|
1306 |
}
|
1307 |
|
1308 |
/**
|
1311 |
* @since 6.0.00
|
1312 |
*/
|
1313 |
function wplc_hook_control_check_mobile() {
|
1314 |
+
$wplc_settings = wplc_get_options();
|
1315 |
+
$draw_box = true;
|
1316 |
|
1317 |
+
if ( ! class_exists( 'Mobile_Detect' ) ) {
|
1318 |
+
require_once( plugin_dir_path( __FILE__ ) . 'includes/Mobile_Detect.php' );
|
1319 |
+
}
|
1320 |
+
$wplc_detect_device = new Mobile_Detect;
|
1321 |
+
$wplc_is_mobile = $wplc_detect_device->isMobile();
|
1322 |
|
1323 |
+
if ( $wplc_is_mobile && ! $wplc_settings['wplc_enabled_on_mobile'] ) { // if wplc_enabled_on_mobile and user is mobile, hide
|
1324 |
+
$draw_box = false;
|
1325 |
+
}
|
1326 |
|
1327 |
+
if ( $wplc_settings['wplc_hide_when_offline'] && ! wplc_agent_is_available() ) { // if wplc_hide_when_offline and no agents online, hide
|
1328 |
+
$draw_box = false;
|
1329 |
+
}
|
1330 |
|
1331 |
+
if ( ! $draw_box ) {
|
1332 |
+
remove_action( "wplc_hook_output_box_body", "wplc_hook_control_show_chat_box" );
|
1333 |
+
}
|
1334 |
}
|
1335 |
|
1336 |
/**
|
1339 |
* @since 6.0.00
|
1340 |
*/
|
1341 |
function wplc_hook_control_is_chat_enabled() {
|
1342 |
+
$wplc_settings = wplc_get_options();
|
1343 |
+
if ( $wplc_settings["wplc_settings_enabled"] == 2 ) {
|
1344 |
+
remove_action( "wplc_hook_output_box_body", "wplc_hook_control_show_chat_box" );
|
1345 |
+
}
|
1346 |
}
|
1347 |
|
1348 |
/**
|
1350 |
* @return string
|
1351 |
* @since 6.0.00
|
1352 |
*/
|
1353 |
+
function wplc_hook_control_show_chat_box( $cid ) {
|
1354 |
+
echo wplc_output_box_ajax( $cid );
|
1355 |
}
|
1356 |
|
1357 |
/* basic */
|
1358 |
+
add_action( "wplc_hook_output_box_header", "wplc_hook_control_banned_users" );
|
1359 |
+
add_action( "wplc_hook_output_box_header", "wplc_hook_control_check_mobile" );
|
1360 |
+
add_action( "wplc_hook_output_box_header", "wplc_hook_control_is_chat_enabled" );
|
1361 |
|
1362 |
+
add_action( "wplc_hook_output_box_body", "wplc_hook_control_show_chat_box", 10, 1 );
|
1363 |
|
1364 |
/**
|
1365 |
* Build the chat box
|
1366 |
* @return void
|
1367 |
* @since 6.0.00
|
1368 |
*/
|
1369 |
+
function wplc_output_box_5100( $cid = null ) {
|
1370 |
+
do_action( "wplc_hook_output_box_header", $cid );
|
1371 |
+
do_action( "wplc_hook_output_box_body", $cid );
|
1372 |
+
do_action( "wplc_hook_output_box_footer", $cid );
|
1373 |
}
|
1374 |
|
1375 |
/**
|
1376 |
* Filter to control the top MAIN DIV of the chat box
|
1377 |
+
*
|
1378 |
+
* @param array $wplc_settings Live chat settings array
|
1379 |
+
*
|
1380 |
* @return string
|
1381 |
* @since 6.0.00
|
1382 |
*/
|
1383 |
+
function wplc_filter_control_live_chat_box_html_main_div_top( $wplc_settings, $logged_in, $wplc_using_locale ) {
|
1384 |
+
$ret_msg = "";
|
1385 |
+
$wplc_class = "";
|
1386 |
+
|
1387 |
+
if ( $wplc_settings["wplc_settings_align"] == 1 ) {
|
1388 |
+
$original_pos = "bottom_left";
|
1389 |
+
} else if ( $wplc_settings["wplc_settings_align"] == 2 ) {
|
1390 |
+
$original_pos = "bottom_right";
|
1391 |
+
} else if ( $wplc_settings["wplc_settings_align"] == 3 ) {
|
1392 |
+
$original_pos = "left";
|
1393 |
+
$wplc_class = "wplc_left";
|
1394 |
+
} else if ( $wplc_settings["wplc_settings_align"] == 4 ) {
|
1395 |
+
$original_pos = "right";
|
1396 |
+
$wplc_class = "wplc_right";
|
1397 |
+
}
|
1398 |
+
|
1399 |
+
|
1400 |
+
$animations = wplc_return_animations();
|
1401 |
+
if ( $animations ) {
|
1402 |
+
isset( $animations['animation'] ) ? $wplc_animation = $animations['animation'] : $wplc_animation = 'animation-4';
|
1403 |
+
isset( $animations['starting_point'] ) ? $wplc_starting_point = $animations['starting_point'] : $wplc_starting_point = 'display: none;';
|
1404 |
+
isset( $animations['box_align'] ) ? $wplc_box_align = $animations['box_align'] : $wplc_box_align = '';
|
1405 |
+
} else {
|
1406 |
+
|
1407 |
+
if ( $wplc_settings["wplc_settings_align"] == 1 ) {
|
1408 |
+
$original_pos = "bottom_left";
|
1409 |
+
$wplc_box_align = "left:20px; bottom:0px;";
|
1410 |
+
} else if ( $wplc_settings["wplc_settings_align"] == 2 ) {
|
1411 |
+
$original_pos = "bottom_right";
|
1412 |
+
$wplc_box_align = "right:20px; bottom:0px;";
|
1413 |
+
} else if ( $wplc_settings["wplc_settings_align"] == 3 ) {
|
1414 |
+
$original_pos = "left";
|
1415 |
+
$wplc_box_align = "left:0; bottom:100px;";
|
1416 |
+
$wplc_class = "wplc_left";
|
1417 |
+
} else if ( $wplc_settings["wplc_settings_align"] == 4 ) {
|
1418 |
+
$original_pos = "right";
|
1419 |
+
$wplc_box_align = "right:0; bottom:100px;";
|
1420 |
+
$wplc_class = "wplc_right";
|
1421 |
+
}
|
1422 |
+
}
|
1423 |
+
|
1424 |
+
$wplc_extra_attr = apply_filters( "wplc_filter_chat_header_extra_attr", "" );
|
1425 |
+
|
1426 |
+
switch ( $wplc_settings['wplc_newtheme'] ) {
|
1427 |
+
case 'theme-1':
|
1428 |
+
$wplc_theme_type = "classic";
|
1429 |
+
$hovercard_content = "<div class='wplc_hovercard_content_right'>" . apply_filters( "wplc_filter_live_chat_box_html_1st_layer", wplc_filter_control_live_chat_box_html_1st_layer( $wplc_settings, $logged_in, $wplc_using_locale, "wplc-color-2" ) ) . "</div>";
|
1430 |
+
$hovercard_content = apply_filters( "wplc_filter_hovercard_content", $hovercard_content );
|
1431 |
+
$ret_msg .= "<div id='wplc_hovercard' style='display:none' class='" . $wplc_theme_type . "'>";
|
1432 |
+
$ret_msg .= "<div id='wplc_hovercard_content'>" . apply_filters( "wplc_filter_live_chat_box_pre_layer1", "" ) . $hovercard_content . "</div>";
|
1433 |
+
$ret_msg .= "<div id='wplc_hovercard_bottom'>" . apply_filters( "wplc_filter_hovercard_bottom_before", "" ) . apply_filters( "wplc_filter_live_chat_box_hover_html_start_chat_button", "", $wplc_settings, $logged_in, $wplc_using_locale ) . "</div>";
|
1434 |
+
$ret_msg .= "</div>";
|
1435 |
+
break;
|
1436 |
+
|
1437 |
+
default:
|
1438 |
+
$wplc_theme_type = "modern";
|
1439 |
+
$hovercard_content = "";
|
1440 |
+
$msg_left = apply_filters( "wplc_filter_modern_theme_hovercard_content_left", "" );
|
1441 |
+
if ( ! empty( $msg_left ) ) {
|
1442 |
+
$hovercard_content .= "<div class='wplc_hovercard_content_left'>" . $msg_left . "</div>";
|
1443 |
+
}
|
1444 |
+
$hovercard_content .= "<div class='wplc_hovercard_content_right'>" . apply_filters( "wplc_filter_live_chat_box_html_1st_layer", wplc_filter_control_live_chat_box_html_1st_layer( $wplc_settings, $logged_in, $wplc_using_locale, 'wplc-color-4' ) ) . "</div>";
|
1445 |
+
$hovercard_content = apply_filters( "wplc_filter_hovercard_content", $hovercard_content );
|
1446 |
+
$ret_msg .= "<div id='wplc_hovercard' style='display:none' class='" . $wplc_theme_type . "'>";
|
1447 |
+
$ret_msg .= "<div id='wplc_hovercard_content'>" . apply_filters( "wplc_filter_live_chat_box_pre_layer1", "" ) . $hovercard_content . "</div>";
|
1448 |
+
$ret_msg .= "<div id='wplc_hovercard_bottom'>" . apply_filters( "wplc_filter_hovercard_bottom_before", "" ) . apply_filters( "wplc_filter_live_chat_box_hover_html_start_chat_button", "", $wplc_settings, $logged_in, $wplc_using_locale ) . "</div>";
|
1449 |
+
$ret_msg .= "</div>";
|
1450 |
+
|
1451 |
+
}
|
1452 |
+
|
1453 |
+
$additional_class = 'emoji_only';
|
1454 |
+
if ( $wplc_settings["wplc_ux_file_share"] && $wplc_settings["wplc_ux_exp_rating"] ) {
|
1455 |
+
$additional_class = 'file_sharing_ratings_enabled';
|
1456 |
+
} else if ( $wplc_settings["wplc_ux_file_share"] ) {
|
1457 |
+
$additional_class = 'file_sharing_enabled';
|
1458 |
+
} else if ( $wplc_settings["wplc_ux_exp_rating"] ) {
|
1459 |
+
$additional_class = 'rating_enabled';
|
1460 |
+
}
|
1461 |
+
|
1462 |
+
$ret_msg .= "<div id=\"wp-live-chat\" wplc_animation=\"" . $wplc_animation . "\" style=\"" . $wplc_starting_point . " " . $wplc_box_align . ";\" class=\"" . $wplc_theme_type . " " . $wplc_class . " " . $additional_class . " wplc_close\" original_pos=\"" . $original_pos . "\" " . $wplc_extra_attr . " > ";
|
1463 |
+
|
1464 |
+
return $ret_msg;
|
1465 |
+
}
|
1466 |
+
|
1467 |
+
|
1468 |
+
add_filter( "wplc_filter_modern_theme_hovercard_content_left", "wplc_filter_control_modern_theme_hovercard_content_left", 10, 1 );
|
1469 |
+
function wplc_filter_control_modern_theme_hovercard_content_left( $msg ) {
|
1470 |
+
$msg = apply_filters( "wplc_filter_microicon", $msg );
|
1471 |
+
|
1472 |
+
return $msg;
|
1473 |
}
|
1474 |
|
1475 |
/**
|
1476 |
* Filter to control the top HEADER DIV of the chat box
|
1477 |
+
*
|
1478 |
+
* @param array $wplc_settings Live chat settings array
|
1479 |
+
*
|
1480 |
* @return string
|
1481 |
* @since 6.0.00
|
1482 |
*/
|
1483 |
+
function wplc_filter_control_live_chat_box_html_header_div_top( $wplc_settings ) {
|
1484 |
+
$ret_msg = "";
|
1485 |
+
if ( $wplc_settings['wplc_newtheme'] == "theme-1" ) {
|
1486 |
+
$ret_msg .= apply_filters( "wplc_filter_chat_header_above", "", $wplc_settings ); //Ratings/Social Icon Filter
|
1487 |
+
}
|
1488 |
+
$ret_msg .= "<div id=\"wp-live-chat-header\" class='wplc-color-bg-1 wplc-color-2'>";
|
1489 |
+
$ret_msg .= apply_filters( "wplc_filter_chat_header_under", "", $wplc_settings );
|
1490 |
+
|
1491 |
+
return $ret_msg;
|
1492 |
}
|
1493 |
|
1494 |
+
add_filter( "wplc_filter_chat_header_under", "wplc_filter_control_chat_header_under", 1, 2 );
|
1495 |
+
function wplc_filter_control_chat_header_under( $ret_msg, $wplc_settings ) {
|
1496 |
+
if ( $wplc_settings['wplc_newtheme'] == "theme-2" ) {
|
1497 |
+
remove_filter( "wplc_filter_chat_header_under", "wplc_acbc_filter_control_chat_header_under" );
|
1498 |
}
|
1499 |
+
|
1500 |
return $ret_msg;
|
1501 |
}
|
1502 |
|
1503 |
/**
|
1504 |
* Filter to control the user details section - custom fields coming soon
|
1505 |
+
*
|
1506 |
+
* @param array $wplc_settings Live chat settings array
|
1507 |
+
*
|
1508 |
* @return string
|
1509 |
* @since 6.0.00
|
1510 |
*/
|
1511 |
+
function wplc_filter_control_live_chat_box_html_ask_user_detail( $wplc_settings ) {
|
1512 |
+
$ret_msg = "";
|
1513 |
|
1514 |
+
if ( $wplc_settings['wplc_require_user_info'] == 'both' || $wplc_settings['wplc_require_user_info'] == 'name' ) {
|
1515 |
$wplc_ask_user_details = 1;
|
1516 |
} else {
|
1517 |
$wplc_ask_user_details = 0;
|
1518 |
}
|
1519 |
|
1520 |
+
$wplc_loggedin_user_name = "";
|
1521 |
+
$wplc_loggedin_user_email = "";
|
1522 |
+
|
1523 |
+
if ( $wplc_settings['wplc_loggedin_user_info'] && is_user_logged_in() ) {
|
1524 |
+
global $current_user;
|
1525 |
+
|
1526 |
+
if ( $current_user->data != null ) {
|
1527 |
+
//Logged in. Get name and email
|
1528 |
+
$wplc_loggedin_user_name = esc_attr( $current_user->display_name );
|
1529 |
+
$wplc_loggedin_user_email = esc_attr( $current_user->user_email );
|
1530 |
+
}
|
1531 |
+
} else {
|
1532 |
+
if ( $wplc_ask_user_details == 0 ) {
|
1533 |
+
$wplc_loggedin_user_name = stripslashes( wplc_get_user_name( '', $wplc_settings ) );
|
1534 |
+
}
|
1535 |
+
}
|
1536 |
+
|
1537 |
+
switch ( $wplc_settings['wplc_require_user_info'] ) {
|
1538 |
+
|
1539 |
+
case 'both':
|
1540 |
+
$ret_msg .= "<input type=\"text\" maxlength=\"40\" name=\"wplc_name\" id=\"wplc_name\" value='" . $wplc_loggedin_user_name . "' placeholder=\"" . __( "Name", 'wp-live-chat-support' ) . "\" />";
|
1541 |
+
$ret_msg .= "<input type=\"text\" maxlength=\"40\" name=\"wplc_email\" id=\"wplc_email\" wplc_hide=\"0\" value=\"" . $wplc_loggedin_user_email . "\" placeholder=\"" . __( "Email", 'wp-live-chat-support' ) . "\" />";
|
1542 |
+
$ret_msg .= apply_filters( "wplc_start_chat_user_form_after_filter", "" );
|
1543 |
+
break;
|
1544 |
+
|
1545 |
+
case 'email':
|
1546 |
+
if ( $wplc_loggedin_user_name != '' ) {
|
1547 |
+
$wplc_lin = $wplc_loggedin_user_name;
|
1548 |
+
} else {
|
1549 |
+
$wplc_lin = 'user' . rand( 0, 9 ) . rand( 0, 9 ) . rand( 0, 9 ) . rand( 0, 9 ) . rand( 0, 9 ) . rand( 0, 9 );
|
1550 |
+
}
|
1551 |
+
$ret_msg .= "<input type=\"hidden\" maxlength=\"40\" name=\"wplc_name\" id=\"wplc_name\" value=\"" . $wplc_lin . "\" />";
|
1552 |
+
$ret_msg .= "<input type=\"text\" maxlength=\"40\" name=\"wplc_email\" id=\"wplc_email\" wplc_hide=\"0\" value=\"" . $wplc_loggedin_user_email . "\" placeholder=\"" . __( "Email", 'wp-live-chat-support' ) . "\" />";
|
1553 |
+
$ret_msg .= apply_filters( "wplc_start_chat_user_form_after_filter", "" );
|
1554 |
+
break;
|
1555 |
+
|
1556 |
+
case 'name':
|
1557 |
+
if ( $wplc_loggedin_user_email != '' && $wplc_loggedin_user_email != null ) {
|
1558 |
+
$wplc_lie = $wplc_loggedin_user_email;
|
1559 |
+
} else {
|
1560 |
+
$wplc_random_user_number = rand( 0, 9 ) . rand( 0, 9 ) . rand( 0, 9 ) . rand( 0, 9 ) . rand( 0, 9 ) . rand( 0, 9 );
|
1561 |
+
$wplc_lie = $wplc_random_user_number . '@' . $wplc_random_user_number . '.com';
|
1562 |
+
}
|
1563 |
+
$ret_msg .= "<input type=\"text\" maxlength=\"40\" name=\"wplc_name\" id=\"wplc_name\" value='" . $wplc_loggedin_user_name . "' placeholder=\"" . __( "Name", 'wp-live-chat-support' ) . "\" />";
|
1564 |
+
$ret_msg .= "<input type=\"hidden\" maxlength=\"40\" name=\"wplc_email\" id=\"wplc_email\" wplc_hide=\"1\" value=\"" . $wplc_lie . "\" />";
|
1565 |
+
$ret_msg .= apply_filters( "wplc_start_chat_user_form_after_filter", "" );
|
1566 |
+
break;
|
1567 |
+
|
1568 |
+
case 'none':
|
1569 |
+
$ret_msg .= "<div style=\"padding: 7px; text-align: center; font-size:12pt;\">";
|
1570 |
+
if ( isset( $wplc_settings['wplc_user_alternative_text'] ) ) {
|
1571 |
+
$ret_msg .= html_entity_decode( stripslashes( $wplc_settings['wplc_user_alternative_text'] ) );
|
1572 |
+
}
|
1573 |
+
$ret_msg .= '</div>';
|
1574 |
+
$wplc_random_user_number = rand( 0, 9 ) . rand( 0, 9 ) . rand( 0, 9 ) . rand( 0, 9 ) . rand( 0, 9 ) . rand( 0, 9 );
|
1575 |
+
if ( $wplc_loggedin_user_name != '' ) {
|
1576 |
+
$wplc_lin = $wplc_loggedin_user_name;
|
1577 |
+
} else {
|
1578 |
+
$wplc_lin = 'user' . $wplc_random_user_number;
|
1579 |
+
}
|
1580 |
+
if ( $wplc_loggedin_user_email != '' && $wplc_loggedin_user_email != null ) {
|
1581 |
+
$wplc_lie = $wplc_loggedin_user_email;
|
1582 |
+
} else {
|
1583 |
+
$wplc_lie = $wplc_random_user_number . '@' . $wplc_random_user_number . '.com';
|
1584 |
+
}
|
1585 |
+
$ret_msg .= "<input type=\"hidden\" maxlength=\"40\" name=\"wplc_name\" id=\"wplc_name\" value=\"" . $wplc_lin . "\" />";
|
1586 |
+
$ret_msg .= "<input type=\"hidden\" maxlength=\"40\" name=\"wplc_email\" id=\"wplc_email\" wplc_hide=\"1\" value=\"" . $wplc_lie . "\" />";
|
1587 |
+
$ret_msg .= apply_filters( "wplc_start_chat_user_form_after_filter", "" );
|
1588 |
+
break;
|
1589 |
+
}
|
1590 |
+
|
1591 |
+
return $ret_msg;
|
1592 |
}
|
1593 |
|
1594 |
|
1595 |
/**
|
1596 |
* Filter to control the start chat button
|
1597 |
+
*
|
1598 |
+
* @param array $wplc_settings Live chat settings array
|
1599 |
+
*
|
1600 |
* @return string
|
1601 |
* @since 6.0.00
|
1602 |
*/
|
1603 |
+
function wplc_filter_control_live_chat_box_html_start_chat_button( $wplc_settings, $wplc_using_locale ) {
|
1604 |
+
$wplc_sst_1 = __( 'Start chat', 'wp-live-chat-support' );
|
1605 |
+
if ( ! isset( $wplc_settings['wplc_pro_sst1'] ) || $wplc_settings['wplc_pro_sst1'] == "" ) {
|
1606 |
+
$wplc_settings['wplc_pro_sst1'] = $wplc_sst_1;
|
1607 |
+
}
|
1608 |
+
$text = ( $wplc_using_locale ? $wplc_sst_1 : stripslashes( $wplc_settings['wplc_pro_sst1'] ) );
|
1609 |
+
$custom_attr = apply_filters( 'wplc_start_button_custom_attributes_filter', "", $wplc_settings );
|
|
|
1610 |
|
1611 |
+
return "<button id=\"wplc_start_chat_btn\" type=\"button\" class='wplc-color-bg-1 wplc-color-2' $custom_attr>$text</button>";
|
1612 |
+
}
|
1613 |
|
1614 |
|
1615 |
/**
|
1616 |
* Filter to control the hover card start chat button
|
1617 |
+
*
|
1618 |
+
* @param array $wplc_settings Live chat settings array
|
1619 |
+
*
|
1620 |
* @return string
|
1621 |
* @since 6.1.00
|
1622 |
*/
|
1623 |
+
add_filter( "wplc_filter_live_chat_box_hover_html_start_chat_button", "wplc_filter_control_live_chat_box_html_hovercard_chat_button", 10, 4 );
|
1624 |
+
function wplc_filter_control_live_chat_box_html_hovercard_chat_button( $content, $wplc_settings, $logged_in, $wplc_using_locale ) {
|
1625 |
+
if ( $logged_in ) {
|
1626 |
+
$wplc_sst_1 = __( 'Start chat', 'wp-live-chat-support' );
|
1627 |
+
|
1628 |
+
if ( ! isset( $wplc_settings['wplc_pro_sst1'] ) || $wplc_settings['wplc_pro_sst1'] == "" ) {
|
1629 |
+
$wplc_settings['wplc_pro_sst1'] = $wplc_sst_1;
|
1630 |
+
}
|
1631 |
+
$text = ( $wplc_using_locale ? $wplc_sst_1 : stripslashes( $wplc_settings['wplc_pro_sst1'] ) );
|
1632 |
+
|
1633 |
+
return "<button id=\"speeching_button\" type=\"button\" class='wplc-color-bg-1 wplc-color-2'>$text</button>";
|
1634 |
+
} else {
|
1635 |
+
$wplc_sst_1 = stripslashes( $wplc_settings['wplc_pro_offline_btn'] );
|
1636 |
|
1637 |
+
return "<button id=\"speeching_button\" type=\"button\" class='wplc-color-bg-1 wplc-color-2'>$wplc_sst_1</button>";
|
|
|
|
|
|
|
|
|
|
|
1638 |
|
1639 |
+
}
|
1640 |
}
|
1641 |
|
1642 |
/**
|
1643 |
* Filter to control the offline message button
|
1644 |
+
*
|
1645 |
+
* @param array $wplc_settings Live chat settings array
|
1646 |
+
*
|
1647 |
* @return string
|
1648 |
* @since 6.0.00
|
1649 |
*/
|
1650 |
+
function wplc_filter_control_live_chat_box_html_send_offline_message_button( $wplc_settings ) {
|
1651 |
+
$wplc_settings = wplc_get_options();
|
1652 |
+
$wplc_theme = wplc_get_theme();
|
1653 |
+
if ( ! empty( $wplc_settings['theme'] ) ) {
|
1654 |
+
if ( $wplc_theme == 'theme-1' ) {
|
1655 |
+
$wplc_settings_fill = "#DB0000";
|
1656 |
+
$wplc_settings_font = "#FFFFFF";
|
1657 |
+
} else if ( $wplc_theme == 'theme-2' ) {
|
1658 |
+
$wplc_settings_fill = "#000000";
|
1659 |
+
$wplc_settings_font = "#FFFFFF";
|
1660 |
+
} else if ( $wplc_theme == 'theme-3' ) {
|
1661 |
+
$wplc_settings_fill = "#DB30B3";
|
1662 |
+
$wplc_settings_font = "#FFFFFF";
|
1663 |
+
} else if ( $wplc_theme == 'theme-4' ) {
|
1664 |
+
$wplc_settings_fill = "#1A14DB";
|
1665 |
+
$wplc_settings_font = "#F7FF0F";
|
1666 |
+
} else if ( $wplc_theme == 'theme-5' ) {
|
1667 |
+
$wplc_settings_fill = "#3DCC13";
|
1668 |
+
$wplc_settings_font = "#FF0808";
|
1669 |
+
} else if ( $wplc_theme == 'theme-6' ) {
|
1670 |
+
if ( $wplc_settings["wplc_settings_fill"] ) {
|
1671 |
+
$wplc_settings_fill = "#" . $wplc_settings["wplc_settings_fill"];
|
1672 |
+
} else {
|
1673 |
+
$wplc_settings_fill = "#ec832d";
|
1674 |
+
}
|
1675 |
+
if ( $wplc_settings["wplc_settings_font"] ) {
|
1676 |
+
$wplc_settings_font = "#" . $wplc_settings["wplc_settings_font"];
|
1677 |
+
} else {
|
1678 |
+
$wplc_settings_font = "#FFFFFF";
|
1679 |
+
}
|
1680 |
+
}
|
1681 |
+
} else {
|
1682 |
+
if ( $wplc_settings["wplc_settings_fill"] ) {
|
1683 |
+
$wplc_settings_fill = "#" . $wplc_settings["wplc_settings_fill"];
|
1684 |
+
} else {
|
1685 |
+
$wplc_settings_fill = "#ec832d";
|
1686 |
+
}
|
1687 |
+
if ( $wplc_settings["wplc_settings_font"] ) {
|
1688 |
+
$wplc_settings_font = "#" . $wplc_settings["wplc_settings_font"];
|
1689 |
+
} else {
|
1690 |
+
$wplc_settings_font = "#FFFFFF";
|
1691 |
+
}
|
1692 |
+
}
|
1693 |
+
$custom_attr = apply_filters( 'wplc_offline_message_button_custom_attributes_filter', "", $wplc_settings );
|
1694 |
+
$ret_msg = "<input id=\"wplc_na_msg_btn\" class='wplc-color-bg-1 wplc-color-2' type=\"button\" value=\"" . stripslashes( $wplc_settings['wplc_pro_offline_btn_send'] ) . "\" $custom_attr/>";
|
|
|
|
|
1695 |
|
1696 |
+
return $ret_msg;
|
1697 |
+
}
|
1698 |
|
1699 |
|
1700 |
/**
|
1701 |
* Filter to control the 2nd layer of the chat window (online/offline)
|
1702 |
+
*
|
1703 |
+
* @param array $wplc_settings Live chat settings array
|
1704 |
+
* @param bool $logged_in Is the user logged in or not
|
1705 |
+
*
|
1706 |
* @return string
|
1707 |
* @since 6.0.00
|
1708 |
*/
|
1709 |
+
function wplc_filter_control_live_chat_box_html_2nd_layer( $wplc_settings, $logged_in, $wplc_using_locale, $cid ) {
|
1710 |
+
global $wplc_default_settings_array;
|
1711 |
+
|
1712 |
+
if ( $logged_in ) {
|
1713 |
+
$wplc_intro = $wplc_default_settings_array['wplc_pro_intro'];
|
1714 |
+
if ( ! isset( $wplc_settings['wplc_pro_intro'] ) || $wplc_settings['wplc_pro_intro'] == "" ) {
|
1715 |
+
$wplc_settings['wplc_pro_intro'] = $wplc_intro;
|
1716 |
+
}
|
1717 |
+
$text = ( $wplc_using_locale ? $wplc_intro : stripslashes( $wplc_settings['wplc_pro_intro'] ) );
|
1718 |
+
|
1719 |
+
$ret_msg = "<div id=\"wp-live-chat-2-inner\">";
|
1720 |
+
$ret_msg .= " <div id=\"wp-live-chat-2-info\" class='wplc-color-4'>";
|
1721 |
+
$ret_msg .= apply_filters( "wplc_filter_intro_text_heading", $text, $wplc_settings );
|
1722 |
+
$ret_msg .= " </div>";
|
1723 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_ask_user_details", wplc_filter_control_live_chat_box_html_ask_user_detail( $wplc_settings ) );
|
1724 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_start_chat_button", wplc_filter_control_live_chat_box_html_start_chat_button( $wplc_settings, $wplc_using_locale ), $cid );
|
1725 |
+
$ret_msg .= "</div>";
|
1726 |
+
} else {
|
1727 |
+
$wplc_loggedin_user_name = '';
|
1728 |
+
$wplc_loggedin_user_email = '';
|
1729 |
+
if ( $wplc_settings['wplc_loggedin_user_info'] ) {
|
1730 |
+
global $current_user;
|
1731 |
+
|
1732 |
+
if ( $current_user->data != null ) {
|
1733 |
+
if ( is_user_logged_in() ) {
|
1734 |
+
//Logged in. Get name and email
|
1735 |
+
$wplc_loggedin_user_name = esc_attr( $current_user->display_name );
|
1736 |
+
$wplc_loggedin_user_email = esc_attr( $current_user->user_email );
|
1737 |
+
} else {
|
1738 |
+
$wplc_loggedin_user_name = stripslashes( $wplc_settings['wplc_user_default_visitor_name'] );
|
1739 |
+
}
|
1740 |
+
}
|
1741 |
+
}
|
1742 |
+
|
1743 |
+
/* admin not logged in, show offline messages */
|
1744 |
+
$ret_msg = "<div id=\"wp-live-chat-2-info\" class=\"wplc-color-bg-1 wplc-color-2\">";
|
1745 |
+
$ret_msg .= "</div>";
|
1746 |
+
$ret_msg .= "<div id=\"wplc_message_div\">";
|
1747 |
+
$ret_msg .= "<input type=\"text\" name=\"wplc_name\" id=\"wplc_name\" value=\"$wplc_loggedin_user_name\" placeholder=\"" . __( "Name", 'wp-live-chat-support' ) . "\" />";
|
1748 |
+
$ret_msg .= "<input type=\"text\" name=\"wplc_email\" id=\"wplc_email\" value=\"$wplc_loggedin_user_email\" placeholder=\"" . __( "Email", 'wp-live-chat-support' ) . "\" />";
|
1749 |
+
$ret_msg .= "<textarea name=\"wplc_message\" id=\"wplc_message\" placeholder=\"" . __( "Message", 'wp-live-chat-support' ) . "\" maxlength='700'></textarea>";
|
1750 |
+
$ret_msg .= "<span class='wplc_char_counter'></span>";
|
1751 |
+
|
1752 |
+
$offline_ip_address = esc_attr( wplc_get_user_ip() );
|
1753 |
+
|
1754 |
+
$ret_msg .= "<input type=\"hidden\" name=\"wplc_ip_address\" id=\"wplc_ip_address\" value=\"" . $offline_ip_address . "\" />";
|
1755 |
+
$ret_msg .= "<input type=\"hidden\" name=\"wplc_domain_offline\" id=\"wplc_domain_offline\" value=\"" . site_url() . "\" />";
|
1756 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_send_offline_message_button", wplc_filter_control_live_chat_box_html_send_offline_message_button( $wplc_settings ) );
|
1757 |
+
$ret_msg .= "</div>";
|
1758 |
+
}
|
1759 |
+
|
1760 |
+
$data = array(
|
1761 |
+
'ret_msg' => $ret_msg,
|
1762 |
+
'wplc_settings' => $wplc_settings,
|
1763 |
+
'logged_in' => $logged_in,
|
1764 |
+
'wplc_using_locale' => $wplc_using_locale
|
1765 |
+
);
|
1766 |
+
|
1767 |
+
$ret_msg = apply_filters( "wplc_filter_2nd_layer_modify", $data );
|
1768 |
+
if ( is_array( $ret_msg ) ) {
|
1769 |
+
/* if nothing uses this filter is comes back as an array, so return the original message in that array */
|
1770 |
+
return $ret_msg['ret_msg'];
|
1771 |
+
} else {
|
1772 |
+
return $ret_msg;
|
1773 |
+
}
|
1774 |
}
|
1775 |
|
1776 |
/**
|
1777 |
* Filter to control the 3rd layer of the chat window
|
1778 |
+
*
|
1779 |
+
* @param array $wplc_settings live chat settings array
|
1780 |
+
*
|
1781 |
* @return string
|
1782 |
* @since 6.0.00
|
1783 |
*/
|
1784 |
+
function wplc_filter_control_live_chat_box_html_3rd_layer( $wplc_settings, $wplc_using_locale ) {
|
1785 |
+
global $wplc_default_settings_array;
|
1786 |
+
|
1787 |
+
if ( ! isset( $wplc_settings['wplc_pro_sst2'] ) || $wplc_settings['wplc_pro_sst2'] == "" ) {
|
1788 |
+
$wplc_settings['wplc_pro_sst2'] = $wplc_default_settings_array['wplc_pro_sst2'];
|
1789 |
+
}
|
1790 |
+
$text = ( $wplc_using_locale ? $wplc_default_settings_array['wplc_pro_sst2'] : stripslashes( $wplc_settings['wplc_pro_sst2'] ) );
|
1791 |
|
1792 |
+
$ret_msg = "<p class=''wplc-color-4>" . $text . "</p>";
|
|
|
1793 |
|
1794 |
+
return $ret_msg;
|
|
|
1795 |
}
|
1796 |
|
1797 |
+
add_filter( "wplc_filter_intro_text_heading", "wplc_filter_control_intro_text_heading", 10, 2 );
|
1798 |
/**
|
1799 |
* Filters intro text
|
1800 |
+
*/
|
1801 |
+
function wplc_filter_control_intro_text_heading( $content, $wplc_settings ) {
|
1802 |
+
if ( $wplc_settings['wplc_require_user_info'] == 'none' ) {
|
1803 |
+
$content = "";
|
1804 |
+
}
|
1805 |
+
|
1806 |
return $content;
|
1807 |
}
|
1808 |
|
1809 |
+
add_filter( "wplc_filter_live_chat_box_above_main_div", "wplc_filter_control_live_chat_box_above_main_div", 10, 3 );
|
1810 |
function wplc_filter_control_live_chat_box_above_main_div( $msg, $wplc_settings, $cid ) {
|
1811 |
+
if ( $wplc_settings['wplc_newtheme'] == "theme-2" ) {
|
1812 |
+
$agent_string = '';
|
1813 |
+
|
1814 |
+
if ( ! $wplc_settings['wplc_use_node_server'] ) {
|
1815 |
+
if ( $cid ) {
|
1816 |
+
$cid = wplc_return_chat_id_by_rel_or_id( $cid );
|
1817 |
+
$chat_data = wplc_get_chat_data( $cid );
|
1818 |
+
if ( isset( $chat_data->agent_id ) ) {
|
1819 |
+
$agent_id = intval( $chat_data->agent_id );
|
1820 |
+
} else {
|
1821 |
+
$agent_id = get_current_user_id();
|
1822 |
+
}
|
1823 |
+
if ( $agent_id ) {
|
1824 |
+
$user_info = get_userdata( $agent_id );
|
1825 |
+
if ( $wplc_settings['wplc_use_wp_name'] ) {
|
1826 |
+
$agent = $user_info->display_name;
|
1827 |
+
} else {
|
1828 |
+
if ( ! empty( $wplc_settings['wplc_chat_name'] ) ) {
|
1829 |
+
$agent = $wplc_settings['wplc_chat_name'];
|
1830 |
+
} else {
|
1831 |
+
$agent = 'Admin';
|
1832 |
+
}
|
1833 |
+
}
|
1834 |
+
$extra = apply_filters( "wplc_filter_further_live_chat_box_above_main_div", '', $wplc_settings, $cid, $chat_data, $agent );
|
1835 |
+
$title = __( "Minimize Chat", 'wp-live-chat-support' );
|
1836 |
+
$agent_string = '<p style="text-align:center;">
|
1837 |
+
<img class="img-thumbnail img-circle wplc_thumb32 wplc_agent_involved" style="max-width:inherit;" id="agent_grav_' . $agent_id . '" title="' . esc_attr( $agent ) . '" src="https://www.gravatar.com/avatar/' . md5( $user_info->user_email ) . '?s=60&d=mm" /><br />
|
1838 |
+
<span class="wplc_agent_name wplc-color-2" title="' . esc_attr( $agent ) . '">' . esc_html( $agent ) . '</span>
|
1839 |
+
' . $extra . '
|
1840 |
+
<button class="tcx_pullup down" title="' . esc_attr( $title ) . '"><i class="fas fa-angle-down" ></i></button>';
|
1841 |
+
$title = __( "End Chat", 'wp-live-chat-support' );
|
1842 |
+
$text = "<i class='fas fa-angle-down'></i><i class='fas fa-angle-up'></i>";
|
1843 |
+
$text = '<i class="fa fa-times"></i>';
|
1844 |
+
$agent_string .= '<button id="wplc_end_chat_button" title="' . $title . '">' . $text . '</button></p>';
|
1845 |
+
}
|
1846 |
+
}
|
1847 |
+
}
|
1848 |
+
$msg .= "<div id='wplc_chatbox_header_bg'><div id='wplc_chatbox_header' class='wplc-color-bg-1 wplc-color-4'><div class='wplc_agent_info'>" . $agent_string . "</div></div></div>";
|
1849 |
+
}
|
1850 |
+
|
1851 |
+
return $msg;
|
1852 |
}
|
1853 |
|
1854 |
/**
|
1855 |
* Filter to control the 4th layer of the chat window
|
1856 |
+
*
|
1857 |
+
* @param array $wplc_settings live chat settings array
|
1858 |
+
*
|
1859 |
* @return string
|
1860 |
* @since 6.0.00
|
1861 |
*/
|
1862 |
+
function wplc_filter_control_live_chat_box_html_4th_layer( $wplc_settings, $wplc_using_locale, $cid ) {
|
1863 |
+
$ret_msg = "";
|
1864 |
+
if ( $wplc_settings['wplc_newtheme'] == 'theme-1' ) {
|
1865 |
+
$ret_msg .= apply_filters( "wplc_filter_typing_control_div", "" );
|
1866 |
+
}
|
1867 |
+
$ret_msg .= apply_filters( "wplc_filter_inner_live_chat_box_4th_layer", "", $wplc_settings );
|
1868 |
+
$ret_msg .= "<div id=\"wplc_sound_update\" style=\"height:0; width:0; display:none; border:0;\"></div>";
|
1869 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_above_main_div", "", $wplc_settings, $cid );
|
1870 |
+
$ret_msg .= "<div id=\"wplc_chatbox\">";
|
1871 |
+
$ret_msg .= "</div>";
|
1872 |
+
$ret_msg .= "<div id='tcx_chat_ended' style='display:none;'></div>";
|
1873 |
+
$ret_msg .= "<div id='wplc_user_message_div'>";
|
1874 |
+
$ret_msg .= "<div>";
|
1875 |
+
$placeholder = __( 'Type here', 'wp-live-chat-support' );
|
1876 |
+
$ret_msg .= "<textarea type=\"text\" name=\"wplc_chatmsg\" id=\"wplc_chatmsg\" placeholder=\"" . $placeholder . "\" class='wdt-emoji-bundle-enabled' maxlength='2000'></textarea>";
|
1877 |
+
|
1878 |
+
$ret_msg .= '<div class="wplc_usericons_container">';
|
1879 |
+
if ( $wplc_settings['wplc_newtheme'] == 'theme-2' ) {
|
1880 |
+
$ret_msg .= apply_filters( "wplc_filter_typing_control_div_theme_2", "" );
|
1881 |
+
}
|
1882 |
+
$ret_msg .= apply_filters( "wplc_filter_chat_4th_layer_below_input", "", $wplc_settings ); //Ratings/Social Icon Filter
|
1883 |
+
|
1884 |
+
//Upload Controls
|
1885 |
+
$ret_msg .= apply_filters( "wplc_filter_chat_upload", "" );
|
1886 |
+
$ret_msg .= "<input type=\"hidden\" name=\"wplc_cid\" id=\"wplc_cid\" value=\"\" />";
|
1887 |
+
$ret_msg .= "<input id=\"wplc_send_msg\" type=\"button\" value=\"" . __( "Send", 'wp-live-chat-support' ) . "\" style=\"display:none;\" />";
|
1888 |
+
$ret_msg .= "</div>";
|
1889 |
+
$ret_msg .= function_exists( "wplc_emoji_selector_div" ) ? wplc_emoji_selector_div() : "";
|
1890 |
+
$ret_msg .= "</div>"; // wplc_usericons_container
|
1891 |
+
$ret_msg .= "</div>";
|
1892 |
+
$ret_msg .= "</div>";
|
1893 |
+
|
1894 |
+
return $ret_msg;
|
1895 |
}
|
1896 |
|
1897 |
/**
|
1898 |
* Filter to control the 1st layer of the chat window
|
1899 |
+
*
|
1900 |
+
* @param array $wplc_settings live chat settings array
|
1901 |
+
* @param bool $logged_in An agent is available or not
|
1902 |
+
* @param bool $wplc_using_locale Are they using a localization plugin
|
1903 |
+
*
|
1904 |
* @return string
|
1905 |
* @since 6.0.00
|
1906 |
*/
|
1907 |
+
function wplc_filter_control_live_chat_box_html_1st_layer( $wplc_settings, $logged_in, $wplc_using_locale, $class_override = false ) {
|
1908 |
+
global $wplc_default_settings_array;
|
1909 |
+
$ret_msg = "<div id='wplc_first_message'>";
|
1910 |
+
if ( $logged_in ) {
|
1911 |
+
if ( $wplc_settings['wplc_newtheme'] == "theme-2" ) {
|
1912 |
+
$coltheme = "wplc-color-4";
|
1913 |
+
} else {
|
1914 |
+
$coltheme = "wplc-color-2";
|
1915 |
+
}
|
1916 |
+
if ( $class_override ) {
|
1917 |
+
//Override color class
|
1918 |
+
$coltheme = $class_override;
|
1919 |
+
}
|
1920 |
+
$wplc_tl_msg = "<div class='$coltheme'><strong>" . ( $wplc_using_locale ? $wplc_default_settings_array['wplc_pro_fst1'] : stripslashes( $wplc_settings['wplc_pro_fst1'] ) ) . "</strong> " . ( $wplc_using_locale ? $wplc_default_settings_array['wplc_pro_fst2'] : stripslashes( $wplc_settings['wplc_pro_fst2'] ) ) . "</div>";
|
1921 |
+
$ret_msg .= $wplc_tl_msg;
|
1922 |
+
} else {
|
1923 |
+
$wplc_tl_msg = "<div class='wplc_offline'><strong>" . ( $wplc_using_locale ? $wplc_default_settings_array['wplc_pro_na'] : stripslashes( $wplc_settings['wplc_pro_na'] ) ) . "</strong> " . ( $wplc_using_locale ? $wplc_default_settings_array['wplc_pro_offline1'] : stripslashes( $wplc_settings['wplc_pro_offline1'] ) ) . "</div>";
|
1924 |
+
$ret_msg .= $wplc_tl_msg;
|
1925 |
+
}
|
1926 |
+
$ret_msg .= "</div>";
|
1927 |
+
|
1928 |
+
return $ret_msg;
|
1929 |
+
}
|
1930 |
+
|
1931 |
+
function wplc_shortenurl( $url ) {
|
1932 |
+
if ( strlen( $url ) > 45 ) {
|
1933 |
+
return substr( $url, 0, 30 ) . "[...]" . substr( $url, - 15 );
|
1934 |
} else {
|
1935 |
return $url;
|
1936 |
}
|
1938 |
|
1939 |
/**
|
1940 |
* The function that builds the chat box
|
|
|
1941 |
* @return JSON encoded HTML
|
1942 |
+
* @since 6.0.00
|
1943 |
*/
|
1944 |
+
function wplc_output_box_ajax( $cid = null ) {
|
1945 |
+
$ret_msg = array();
|
1946 |
+
$wplc_settings = wplc_get_options();
|
1947 |
+
|
1948 |
+
if ( isset( $wplc_settings['wplc_using_localization_plugin'] ) && $wplc_settings['wplc_using_localization_plugin'] == 1 ) {
|
1949 |
+
$wplc_using_locale = true;
|
1950 |
+
} else {
|
1951 |
+
$wplc_using_locale = false;
|
1952 |
+
}
|
1953 |
+
$logged_in = wplc_agent_is_available();
|
1954 |
+
$ret_msg['cbox'] = apply_filters( "wplc_theme_control", $wplc_settings, $logged_in, $wplc_using_locale, $cid );
|
1955 |
+
$ret_msg['online'] = $logged_in;
|
1956 |
+
|
1957 |
+
if ( $cid !== null && $cid !== '' ) {
|
1958 |
+
$ret_msg['cid'] = $cid;
|
1959 |
+
$chat_data = wplc_get_chat_data( $cid );
|
1960 |
+
|
1961 |
+
$referer = $_SERVER['HTTP_REFERER'];
|
1962 |
+
if ( parse_url( $referer, PHP_URL_HOST ) == $_SERVER['SERVER_NAME'] ) { // keep referers only from site itself
|
1963 |
+
wplc_record_chat_notification( 'user_loaded', $cid, array( 'uri' => $referer, 'chat_data' => $chat_data ) );
|
1964 |
+
}
|
1965 |
+
if ( ! isset( $chat_data ) || ! $chat_data->agent_id ) {
|
1966 |
+
$ret_msg['type'] = 'new';
|
1967 |
+
} else {
|
1968 |
+
$ret_msg['type'] = 'returning';
|
1969 |
+
|
1970 |
+
if ( $wplc_settings['wplc_use_node_server'] ) {
|
1971 |
+
//This is using node, we shouldn't generate the header data as part of the chat box.
|
1972 |
+
//We will do this dynamically on the front end
|
1973 |
+
} else {
|
1974 |
+
/* build the AGENT DATA array */
|
1975 |
+
$user_info = get_userdata( intval( $chat_data->agent_id ) );
|
1976 |
+
$agent_tagline = '';
|
1977 |
+
|
1978 |
+
if ( $wplc_settings['wplc_use_wp_name'] ) {
|
1979 |
+
$agent = $user_info->display_name;
|
1980 |
+
} else {
|
1981 |
+
if ( ! empty( $wplc_settings['wplc_chat_name'] ) ) {
|
1982 |
+
$agent = $wplc_settings['wplc_chat_name'];
|
1983 |
+
} else {
|
1984 |
+
$agent = 'Admin';
|
1985 |
+
}
|
1986 |
+
}
|
1987 |
+
|
1988 |
+
if ( ! isset( $data ) ) {
|
1989 |
+
$data = false;
|
1990 |
+
}
|
1991 |
+
$agent_tagline = apply_filters( "wplc_filter_agent_data_agent_tagline", $agent_tagline, $cid, $chat_data, $agent, $wplc_settings, $user_info, $data );
|
1992 |
+
$ret_msg['agent_data'] = array(
|
1993 |
+
'email' => md5( $user_info->user_email ),
|
1994 |
+
'name' => esc_html( $agent ),
|
1995 |
+
'aid' => $user_info->ID,
|
1996 |
+
'agent_tagline' => $agent_tagline,
|
1997 |
+
);
|
1998 |
+
}
|
1999 |
+
}
|
2000 |
+
} else {
|
2001 |
+
$ret_msg['type'] = 'new';
|
2002 |
+
}
|
2003 |
+
|
2004 |
+
return json_encode( $ret_msg );
|
2005 |
+
}
|
2006 |
+
|
2007 |
+
function wplc_return_default_theme( $wplc_settings, $logged_in, $wplc_using_locale, $cid ) {
|
2008 |
+
$wplc_settings = wplc_get_options();
|
2009 |
+
$wplc_theme = wplc_get_theme();
|
2010 |
+
$ret_msg = apply_filters( "wplc_filter_live_chat_box_html_main_div_top", wplc_filter_control_live_chat_box_html_main_div_top( $wplc_settings, $logged_in, $wplc_using_locale ) );
|
2011 |
+
$ret_msg .= "<div class=\"wp-live-chat-wraper\">";
|
2012 |
+
$ret_msg .= "<div id='tcx_bell' class='wplc-color-bg-1 wplc-color-2' style='display:none;'><i class='fa fa-bell'></i></div>";
|
2013 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_header_div_top", wplc_filter_control_live_chat_box_html_header_div_top( $wplc_settings ) );
|
2014 |
+
$ret_msg .= " <i id=\"wp-live-chat-minimize\" class=\"fa fa-minus wplc-color-bg-2 wplc-color-1\" style=\"display:none;\"></i>";
|
2015 |
+
$ret_msg .= " <i id=\"wp-live-chat-close\" class=\"fa fa-times\" style=\"display:none;\" ></i>";
|
2016 |
+
$ret_msg .= " <div id=\"wp-live-chat-1\" >";
|
2017 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_1st_layer", wplc_filter_control_live_chat_box_html_1st_layer( $wplc_settings, $logged_in, $wplc_using_locale, 'wplc-color-2' ) );
|
2018 |
+
$ret_msg .= " </div>";
|
2019 |
+
$ret_msg .= '<div id="wplc-chat-alert" class="wplc-chat-alert wplc-chat-alert--' . $wplc_theme . '"></div>';
|
2020 |
+
$ret_msg .= " </div>";
|
2021 |
+
$ret_msg .= " <div id=\"wp-live-chat-2\" style=\"display:none;\">";
|
2022 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_2nd_layer", wplc_filter_control_live_chat_box_html_2nd_layer( $wplc_settings, $logged_in, $wplc_using_locale, $cid ), $cid );
|
2023 |
+
$ret_msg .= " </div>";
|
2024 |
+
$ret_msg .= " <div id=\"wp-live-chat-3\" style=\"display:none;\">";
|
2025 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_3rd_layer", wplc_filter_control_live_chat_box_html_3rd_layer( $wplc_settings, $wplc_using_locale ) );
|
2026 |
+
$ret_msg .= " </div>";
|
2027 |
+
$ret_msg .= " <div id=\"wp-live-chat-react\" style=\"display:none;\">";
|
2028 |
+
$ret_msg .= " <p>" . __( "Reactivating your previous chat...", 'wp-live-chat-support' ) . "</p>";
|
2029 |
+
$ret_msg .= " </div>";
|
2030 |
+
$ret_msg .= " <div id=\"wplc-extra-div\" style=\"display:none;\">";
|
2031 |
+
$ret_msg .= apply_filters( "wplc_filter_wplc_extra_div", "", $wplc_settings, $wplc_using_locale );
|
2032 |
+
$ret_msg .= "</div>";
|
2033 |
+
$ret_msg .= "</div>";
|
2034 |
+
$ret_msg .= " <div id=\"wp-live-chat-4\" style=\"display:none;\">";
|
2035 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_4th_layer", wplc_filter_control_live_chat_box_html_4th_layer( $wplc_settings, $wplc_using_locale, $cid ) );
|
2036 |
+
$ret_msg .= apply_filters( "wplc_filter_chat_social_div_hook", "", $wplc_settings ); //Ratings/Social Icon Filter
|
2037 |
+
$ret_msg .= "</div>";
|
2038 |
+
|
2039 |
+
return $ret_msg;
|
2040 |
+
}
|
2041 |
+
|
2042 |
+
add_filter( "wplc_theme_control", "wplc_theme_control_function", 10, 4 );
|
2043 |
+
|
2044 |
+
function wplc_theme_control_function( $wplc_settings, $logged_in, $wplc_using_locale, $cid ) {
|
2045 |
+
$cid = intval( $cid );
|
2046 |
+
$wplc_settings = wplc_get_options();
|
2047 |
+
$wplc_theme = wplc_get_theme();
|
2048 |
+
if ( ! $wplc_settings ) {
|
2049 |
+
return "";
|
2050 |
+
}
|
2051 |
+
$default_theme = wplc_return_default_theme( $wplc_settings, $logged_in, $wplc_using_locale, $cid );
|
2052 |
+
switch ( $wplc_settings['wplc_newtheme'] ) {
|
2053 |
+
case 'theme-1':
|
2054 |
+
$ret_msg = $default_theme;
|
2055 |
+
break;
|
2056 |
+
|
2057 |
+
default:
|
2058 |
+
$ret_msg = apply_filters( "wplc_filter_live_chat_box_html_main_div_top", wplc_filter_control_live_chat_box_html_main_div_top( $wplc_settings, $logged_in, $wplc_using_locale ) );
|
2059 |
+
$ret_msg .= "<div class=\"wp-live-chat-wraper\">";
|
2060 |
+
$ret_msg .= "<div id='tcx_bell' class='wplc-color-bg-1 wplc-color-2' style='display:none;'><i class='fa fa-bell'></i></div>";
|
2061 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_header_div_top", wplc_filter_control_live_chat_box_html_header_div_top( $wplc_settings ) );
|
2062 |
+
$ret_msg .= " </div>";
|
2063 |
+
$ret_msg .= '<div id="wplc-chat-alert" class="wplc-chat-alert wplc-chat-alert--' . $wplc_theme . '"></div>';
|
2064 |
+
$ret_msg .= " <div id=\"wp-live-chat-2\" style=\"display:none;\">";
|
2065 |
+
$ret_msg .= " <i id=\"wp-live-chat-minimize\" class=\"fa fa-minus wplc-color-bg-2 wplc-color-1\" style=\"display:none;\" ></i>";
|
2066 |
+
$ret_msg .= " <i id=\"wp-live-chat-close\" class=\"fa fa-times\" style=\"display:none;\" ></i>";
|
2067 |
+
$ret_msg .= " <div id=\"wplc-extra-div\" style=\"display:none;\">";
|
2068 |
+
$ret_msg .= apply_filters( "wplc_filter_wplc_extra_div", "", $wplc_settings, $wplc_using_locale );
|
2069 |
+
$ret_msg .= " </div>";
|
2070 |
+
$ret_msg .= " <div id='wp-live-chat-inner-container'>";
|
2071 |
+
$ret_msg .= " <div id='wp-live-chat-inner'>";
|
2072 |
+
$ret_msg .= " <div id=\"wp-live-chat-1\" class=\"wplc-color-2 wplc-color-bg-1\" >";
|
2073 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_1st_layer", wplc_filter_control_live_chat_box_html_1st_layer( $wplc_settings, $logged_in, $wplc_using_locale, 'wplc-color-2' ) );
|
2074 |
+
$ret_msg .= " </div>";
|
2075 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_2nd_layer", wplc_filter_control_live_chat_box_html_2nd_layer( $wplc_settings, $logged_in, $wplc_using_locale, $cid ), $cid );
|
2076 |
+
$ret_msg .= " </div>";
|
2077 |
+
$ret_msg .= " <div id=\"wp-live-chat-react\" style=\"display:none;\">";
|
2078 |
+
$ret_msg .= " <p>" . __( "Reactivating your previous chat...", 'wp-live-chat-support' ) . "</p>";
|
2079 |
+
$ret_msg .= " </div>";
|
2080 |
+
$ret_msg .= " </div>";
|
2081 |
+
$ret_msg .= " <div id=\"wp-live-chat-3\" style=\"display:none;\">";
|
2082 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_3rd_layer", wplc_filter_control_live_chat_box_html_3rd_layer( $wplc_settings, $wplc_using_locale ) );
|
2083 |
+
$ret_msg .= " </div>";
|
2084 |
+
$ret_msg .= " </div>";
|
2085 |
+
$ret_msg .= " <div id=\"wp-live-chat-4\" style=\"display:none;\">";
|
2086 |
+
$ret_msg .= apply_filters( "wplc_filter_live_chat_box_html_4th_layer", wplc_filter_control_live_chat_box_html_4th_layer( $wplc_settings, $wplc_using_locale, $cid ) );
|
2087 |
+
$ret_msg .= " </div>";
|
2088 |
+
$ret_msg .= apply_filters( "wplc_filter_chat_social_div_hook", "", $wplc_settings ); //Ratings/Social Icon Filter
|
2089 |
+
$ret_msg .= "</div>";
|
2090 |
+
break;
|
2091 |
+
}
|
2092 |
+
|
2093 |
+
return $ret_msg;
|
2094 |
+
}
|
2095 |
+
|
2096 |
+
|
2097 |
+
function wplc_admin_accept_chat( $cid ) {
|
2098 |
+
$user_ID = get_current_user_id();
|
2099 |
+
wplc_change_chat_status( sanitize_text_field( $cid ), 3, $user_ID );
|
2100 |
+
|
2101 |
+
return true;
|
2102 |
+
}
|
2103 |
+
|
2104 |
+
add_action( 'admin_head', 'wplc_update_chat_statuses' );
|
2105 |
|
2106 |
|
2107 |
function wplc_superadmin_javascript() {
|
2108 |
+
$wplc_settings = wplc_get_options();
|
2109 |
+
if ( $wplc_settings['wplc_use_node_server'] && ( ! isset( $_GET['action'] ) || $_GET['action'] !== "history" ) ) {
|
2110 |
+
//Using node, load remote scripts
|
2111 |
+
if ( $wplc_settings['wplc_enable_all_admin_pages'] ) {
|
2112 |
+
/* Run admin JS on all admin pages */
|
2113 |
+
if ( isset( $_GET['action'] ) && $_GET['action'] == "history" ) {
|
2114 |
+
} else {
|
2115 |
+
wplc_admin_remote_dashboard_scripts( $wplc_settings );
|
2116 |
+
}
|
2117 |
+
} else {
|
2118 |
+
/* Only run admin JS on the chat dashboard page */
|
2119 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == 'wplivechat-menu' && ! isset( $_GET['action'] ) ) {
|
2120 |
+
wplc_admin_remote_dashboard_scripts( $wplc_settings );
|
2121 |
+
}
|
2122 |
+
}
|
2123 |
+
|
2124 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == "wplivechat-menu-offline-messages" ) {
|
2125 |
+
//wplc_admin_output_js();
|
2126 |
+
wp_register_script( 'wplc-om-script', wplc_plugins_url( '/js/offline_messages.js', __FILE__ ), array( 'jquery' ), WPLC_PLUGIN_VERSION, true );
|
2127 |
+
wp_enqueue_script( 'wplc-om-script' );
|
2128 |
+
$ajax_nonce = wp_create_nonce( "wplc" );
|
2129 |
+
wp_localize_script( 'wplc-om-script', 'wplc_ajax_nonce', $ajax_nonce );
|
2130 |
+
}
|
2131 |
+
} else {
|
2132 |
+
do_action( "wplc_hook_superadmin_head" );
|
2133 |
+
if ( isset( $_GET['page'] ) && isset( $_GET['action'] ) && $_GET['page'] == "wplivechat-menu" && ( $_GET['action'] != 'welcome' && $_GET['action'] != 'credits' ) ) {
|
2134 |
+
/* admin chat box page */
|
2135 |
+
/** set the global chat data here so we dont need to keep getting it from the DB or Cloud server */
|
2136 |
+
global $admin_chat_data;
|
2137 |
+
$admin_chat_data = wplc_get_chat_data( $_GET['cid'], __LINE__ );
|
2138 |
+
wplc_return_admin_chat_javascript( sanitize_text_field( $_GET['cid'] ) );
|
2139 |
+
do_action( "wplc_hook_admin_javascript_chat" );
|
2140 |
+
} else {
|
2141 |
+
/* load this on every other admin page */
|
2142 |
+
wplc_admin_javascript();
|
2143 |
+
do_action( "wplc_hook_admin_javascript" );
|
2144 |
+
}
|
2145 |
+
?>
|
2146 |
+
<script type="text/javascript">
|
2147 |
+
function wplc_desktop_notification() {
|
2148 |
+
if (typeof Notification !== 'undefined') {
|
2149 |
+
if (!Notification) {
|
2150 |
+
return;
|
2151 |
+
}
|
2152 |
+
if (Notification.permission !== "granted") {
|
2153 |
+
Notification.requestPermission();
|
2154 |
+
}
|
2155 |
+
var wplc_desktop_notification = new Notification('<?php _e( 'New chat received', 'wp-live-chat-support' ); ?>', {
|
2156 |
+
icon: wplc_notification_icon_url,
|
2157 |
+
body: "<?php _e( "A new chat has been received. Please go the 'Live Chat' page to accept the chat", 'wp-live-chat-support' ); ?>"
|
2158 |
+
});
|
2159 |
+
}
|
2160 |
+
}
|
2161 |
+
</script>
|
2162 |
+
<?php
|
2163 |
+
}
|
2164 |
+
|
2165 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == 'wplivechat-menu-settings' ) {
|
2166 |
+
wp_enqueue_script( 'wplc-admin-js-settings', wplc_plugins_url( '/js/wplc_u_admin_settings.js', __FILE__ ), false, WPLC_PLUGIN_VERSION, false );
|
2167 |
+
wp_localize_script( 'wplc-admin-js-settings', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
|
2168 |
+
}
|
2169 |
|
2170 |
}
|
2171 |
|
2178 |
function wplc_admin_javascript() {
|
2179 |
$wplc_settings = wplc_get_options();
|
2180 |
|
2181 |
+
if ( $wplc_settings['wplc_enable_all_admin_pages'] ) {
|
2182 |
+
/* Run admin JS on all admin pages */
|
2183 |
+
if ( isset( $_GET['action'] ) && $_GET['action'] == "history" ) {
|
2184 |
+
return;
|
2185 |
+
} else {
|
2186 |
+
wplc_admin_output_js();
|
2187 |
+
}
|
2188 |
+
} else {
|
2189 |
+
/* Only run admin JS on the chat dashboard page */
|
2190 |
+
if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'wplivechat-menu' ) && ! isset( $_GET['action'] ) ) {
|
2191 |
+
wplc_admin_output_js();
|
2192 |
+
}
|
2193 |
+
}
|
2194 |
}
|
2195 |
|
2196 |
/**
|
2200 |
* @since 7.1.00
|
2201 |
*/
|
2202 |
function wplc_admin_output_js() {
|
2203 |
+
$ajax_nonce = wp_create_nonce( "wplc" );
|
2204 |
+
if ( wplc_user_is_agent() ) {
|
2205 |
+
$wplc_settings = wplc_get_options();
|
2206 |
+
wp_register_script( 'wplc-admin-js', wplc_plugins_url( '/js/wplc_u_admin.js', __FILE__ ), array(), WPLC_PLUGIN_VERSION, true );
|
2207 |
+
wp_enqueue_script( 'wplc-admin-js' );
|
2208 |
+
wp_localize_script( 'wplc-admin-js', 'tcx_ringer_count', array( 'value' => intval( $wplc_settings['wplc_new_chat_ringer_count'] ) ) );
|
2209 |
+
$not_icon = wplc_plugins_url( '/images/wplc_notification_icon.png', __FILE__ );
|
2210 |
+
$wplc_wav_file = apply_filters( "wplc_filter_wav_file", '' );
|
2211 |
+
wp_localize_script( 'wplc-admin-js', 'wplc_ajax_nonce', $ajax_nonce ); wp_localize_script( 'wplc-admin-js', 'wplc_wav_file', $wplc_wav_file );
|
2212 |
+
|
2213 |
+
wp_localize_script( 'wplc-admin-js', 'wplc_notification_icon', $not_icon );
|
2214 |
+
wp_localize_script( 'wplc-admin-js', 'tcx_favico_noti', WPLC_PLUGIN_URL . 'images/tcx48px_n.png' );
|
2215 |
+
wp_localize_script( 'wplc-admin-js', 'tcx_favico', WPLC_PLUGIN_URL . 'images/tcx48px.png' );
|
2216 |
+
$extra_data = apply_filters( "wplc_filter_admin_javascript", array() );
|
2217 |
+
wp_localize_script( 'wplc-admin-js', 'wplc_extra_data', $extra_data );
|
2218 |
+
$ajax_url = admin_url( 'admin-ajax.php' );
|
2219 |
+
$wplc_ajax_url = apply_filters( "wplc_filter_ajax_url", $ajax_url );
|
2220 |
+
wp_localize_script( 'wplc-admin-js', 'wplc_ajaxurl', $wplc_ajax_url );
|
2221 |
+
wp_localize_script( 'wplc-admin-js', 'wplc_ajaxurl_home', admin_url( 'admin-ajax.php' ) );
|
2222 |
+
$wpc_ma_js_strings = array(
|
2223 |
+
'remove_agent' => __( 'Remove', 'wp-live-chat-support' ),
|
2224 |
+
'nonce' => wp_create_nonce( "wplc" ),
|
2225 |
+
'user_id' => get_current_user_id(),
|
2226 |
+
'typing_string' => __( 'Typing...', 'wp-live-chat-support' )
|
2227 |
+
);
|
2228 |
+
wp_localize_script( 'wplc-admin-js', 'wplc_admin_strings', $wpc_ma_js_strings );
|
2229 |
+
}
|
2230 |
}
|
2231 |
|
2232 |
function wplc_admin_menu_layout() {
|
2233 |
+
do_action( "wplc_hook_admin_menu_layout" );
|
2234 |
+
update_option( 'WPLC_V8_FIRST_TIME', false );
|
2235 |
+
$wplc_settings = wplc_get_options();
|
2236 |
+
if ( $wplc_settings['wplc_use_node_server'] ) {
|
2237 |
+
//Node in use, load remote dashboard
|
2238 |
+
if ( $_GET['page'] === 'wplivechat-menu' ) {
|
2239 |
+
wplc_admin_dashboard_layout_node( 'dashboard' );
|
2240 |
+
if ( isset( $_GET['action'] ) ) {
|
2241 |
+
wplc_admin_menu_layout_display();
|
2242 |
+
}
|
2243 |
+
} else {
|
2244 |
+
// we'll control this in admin_footer
|
2245 |
+
}
|
2246 |
+
} else {
|
2247 |
+
wplc_admin_menu_layout_display();
|
2248 |
+
}
|
2249 |
}
|
2250 |
|
2251 |
function wplc_first_time_tutorial() {
|
2252 |
+
if ( ! get_option( 'WPLC_FIRST_TIME_TUTORIAL' ) ) {
|
2253 |
+
?>
|
2254 |
+
<div id="wplcftt"
|
2255 |
+
style='margin-top:30px; margin-bottom:20px; width: 65%; background-color: #FFF; box-shadow: 1px 1px 3px #ccc; display:block; padding:10px; text-align:center; margin-left:auto; margin-right:auto;'>
|
2256 |
+
<img src='<?php echo WPLC_PLUGIN_URL; ?>images/wplc_notification_icon.png' width="130" align="center"/>
|
2257 |
+
<h1 style='font-weight: 300; font-size: 50px; line-height: 50px;'><strong
|
2258 |
+
style="color: #0596d4;"><?php _e( "Congratulations", 'wp-live-chat-support' ); ?></strong></h1>
|
2259 |
+
<h2>
|
2260 |
+
<strong><?php _e( "You are now accepting live chat requests on your site.", 'wp-live-chat-support' ); ?></strong>
|
2261 |
+
</h2>
|
2262 |
+
<p><?php _e( "The live chat box has automatically been enabled.", 'wp-live-chat-support' ); ?></p>
|
2263 |
+
<p><?php _e( "Chat notifications will start appearing once visitors send a request.", 'wp-live-chat-support' ); ?></p>
|
2264 |
+
<p><?php echo sprintf( __( "You may modify your chat box settings %s", 'wp-live-chat-support' ), '<a href="?page=wplivechat-menu-settings" target="_BLANK">' . __( 'here', 'wp-live-chat-support' ) . '</a>' ); ?></p>
|
2265 |
+
<p><?php _e( "Experiencing issues?", 'wp-live-chat-support' ); ?> <a
|
2266 |
+
href="https://www.3cx.com/wp-live-chat/docs/" target="_BLANK"
|
2267 |
+
title=""><?php _e( "Take a look at our how-to guides.", 'wp-live-chat-support' ); ?></a></p>
|
2268 |
+
<p>
|
2269 |
+
<button id="wplc_close_ftt"
|
2270 |
+
class="button button-secondary"><?php _e( "Hide", 'wp-live-chat-support' ); ?></button>
|
2271 |
+
</p>
|
2272 |
+
</div>
|
2273 |
+
<?php }
|
2274 |
}
|
2275 |
|
2276 |
/**
|
2278 |
* @return void
|
2279 |
* @since 6.0.00
|
2280 |
*/
|
2281 |
+
add_filter( "wplc_filter_chat_dahsboard_visitors_online_bottom", "wplc_filter_control_chat_dashboard_visitors_online_bottom", 10 );
|
2282 |
+
function wplc_filter_control_chat_dashboard_visitors_online_bottom( $text ) {
|
2283 |
+
$text = "<hr />";
|
2284 |
+
$text .= "<p class='wplc-agent-info' id='wplc-agent-info'>";
|
2285 |
+
$text .= " <span class='wplc_agents_online'>1</span>";
|
2286 |
+
$text .= " <a href='javascript:void(0);'>" . __( "Agent(s) online", 'wp-live-chat-support' ) . "</a>";
|
2287 |
+
$text .= "</p>";
|
2288 |
+
|
2289 |
+
return $text;
|
2290 |
}
|
2291 |
|
2292 |
function wplc_admin_menu_layout_display() {
|
2293 |
+
if ( wplc_user_is_agent() ) {
|
2294 |
+
do_action( "wplc_hook_admin_menu_layout_display_top" );
|
2295 |
+
wplc_stats( "chat_dashboard" );
|
2296 |
+
if ( ! isset( $_GET['action'] ) ) {
|
2297 |
+
?>
|
2298 |
+
<div class='wplc_network_issue' style='display:none;'></div>
|
2299 |
+
<div class='wplc_page_title'>
|
2300 |
+
<?php wplc_first_time_tutorial(); ?>
|
2301 |
+
</div>
|
2302 |
+
<div id="wplc_sound"></div>
|
2303 |
+
<div id="wplc_admin_chat_holder">
|
2304 |
+
<div class="wplc_admin_chat_on_premise_header">
|
2305 |
+
<div class="wplc_admin_chat_on_premise_header_left">
|
2306 |
+
<img src="data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAABkAAD/4QMvaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjYtYzE0MiA3OS4xNjA5MjQsIDIwMTcvMDcvMTMtMDE6MDY6MzkgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDQyAyMDE4IChXaW5kb3dzKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpERkVFRTcwRUFENDkxMUU5QjUzM0I0QThEMzhGNzc5MyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpERkVFRTcwRkFENDkxMUU5QjUzM0I0QThEMzhGNzc5MyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkRGRUVFNzBDQUQ0OTExRTlCNTMzQjRBOEQzOEY3NzkzIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkRGRUVFNzBEQUQ0OTExRTlCNTMzQjRBOEQzOEY3NzkzIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+/+4AJkFkb2JlAGTAAAAAAQMAFQQDBgoNAAAH7QAADocAABIGAAAWAv/bAIQAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQICAgICAgICAgICAwMDAwMDAwMDAwEBAQEBAQECAQECAgIBAgIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMD/8IAEQgARgBGAwERAAIRAQMRAf/EAQ8AAAICAgMBAAAAAAAAAAAAAAgJAAcGCgEDBAUBAQACAgMBAAAAAAAAAAAAAAAGCAEHAgMFBBAAAQMCBQMDBAMBAAAAAAAABQMEBgACEAEVFgcRFwggFDUwQBI2JicYKBEAAQMCAgUGBwsKBwAAAAAAAgEDBBEFABIhMRMUBhBBUSIjFSBxgTJCchZhoVLSMySU1DU2pvBikqJDU2OTNLRkJZWl1Sb2EgABAgIDCQoLCQAAAAAAAAABAgMAESESBCAxQVFx0ZIzNDCBkbEigtIToxQQQGGhcqKy4iOzBcEyUlNjk/P0JRMBAQACAQMDBAEFAQAAAAAAAREAITFBUWEQIHHwgZHBoTBAsdHh8f/aAAwDAQACEQMRAAABeIQoUAgw4I4P4+sQgscSyeUhC/TYhLKBwNdOSQwnLJU27OXXyzCv4XsizK9232DhMIvKdaubDtvQNyxiZzHLllcMwgAOViuxs1imANZ1q5sm2tB3FGZjgnr+DWHvRYVuWAvq1eR8pTgq2WQI5rN0p+/833479vlYv6Hk17AdqjfWK7W0edZrImFZ4kbYOpdQam3ziMVnfGMtUZcoQGUQ0U12dPX193oGWjpz2EIfMFpFYB7BMkIf/9oACAEBAAEFAsJfyXD4RkU8o8vzS8ojuV8c8koeUvYv2RNrjzNzVfH1Vl1nK2MD5GkMAIROViJmErlWabGhwxDVS1gQZ00UfWiDq0QfUhCsbB/BU4UikvrygL3qGoz81B5VPAojuFy9XcLl6u4PLtT10/fVbnnbnuhbtn5K2XW8gRn5qEZcqaP/ANBUek3M0ZR7s8g1Lnzskzr2bv8Azl5PgL70ALlJoVHyA0NR3jLqIGjJXLrUldIoixzByVIbea7WlcbZS2PSKPk4sZqLFclmponcTfdc8PHXjtVw9w5I4wC8iMJfx/KYQ5tvuswSSVXU408fiRRZu3QaIYvPZ+1ktnjPe6Ra+Lad8E7VdMf/2gAIAQIAAQUC+zENLHxHISLty0sXWli60sXR4OxtH4xv5gsPEOnOixutGjlaNHKJJpJR/GN/MFtv+6/htNGMYf3bdDUXSTQCYg3CbYoo1Zuq0wbSLVs3wkblFEZ6YyTyWbGCOZB51z9dt11n1//aAAgBAwABBQL7OQEFBgjM+cvu105WuG61w5UVkJS8tjMv10CWkLFnuOaVuOZVuOZUGVcLyzGZfroLdvsv7HogUnAuzd8kqPLLOpNjJmiz0Ii/IMq1ozTl89dZfllUPZuHBr0dMqmgS5s9jwi0QO6Zeu+yxTL63//aAAgBAgIGPwLxNuzO6sznvCf2RLqGuARqWdERqGdERqWdEQu0sNpQ8iV6iYnT5LhrnewYDlue6t6rerpTRTgVG19o3mjau1bzRtXat5oW3ZzWZDYkZzmKMNw1zvZMf6e0Vf1L3Moj+eCiyJrKAnfdHGRGp9ZfShxloSbSgAcIuGnXjJukTygiA66224ZXykGjLGzs6Cc0Hu7aET/CAOLwLaUR1q5ADDf4ro2R4/EaFHoe7xSguJ1AoTkx79/cOSZUS4d3/9oACAEDAgY/AvE3razrkgSyqITPenOK3eX6cSiOKiNptGmrPG02jTVnjabRpqzwix2t1TtndmOVTIymCDfwZJHHcP5UfMTBZ+l2brrPXJn1a1UyFE0nJGwdi90o2HsHulGw9g90obetaalpU8oqEqsjI0Sz03D+VHzEwT9En3OufyvvSp1lOLyeeP60Jct66iFGQMmTTzQY2j1G+hDNotCqzy3SSeabh6z2cVnpAyx1VA8MhBZYdeZE6QlSk05BhjarT+4vPA72866E3qyiZTxT8DT7aT1DUypWAUGjKcW/dD6hZk/BfVIgYHPev5ZwllQHeVcpfpYsib3nw7hJYBAIO+KRwbv/AP/aAAgBAQEGPwLkUL3dQ37LnC1Qh3u5mipUVWO2tI4nTQTxNgvTghsvCSk16D90uWRwvWiRI5iH85cIr/C1pcb5xamTGT8hmL4p+jhti+Qp/Djx0TbnS524VXRQpEZtuWOnnWPlTnVMMzrdLjzocgc7EqI8D7Do9IOtqQl4D/CnCTwd8ImS7XYaGlqzJ/Rw0VFArjReuepjV5/ybsiS87IkPmTrz77hOvPOGuY3HXDUjcMyWqqulfAGRbHyftzjiLcLM+4W4zg0IS5etu0tBTqvCmZKacw1FYt9sz2eNI6jrJ5UkQpQU20OWAquzfZzeIhVCSoqi8k+6sKPeclRttnEqL8/lCeV/KtcyQ2AN2mpVCnPhsJbrjiyXXX5LhmROvFlN9xTcWpqbpJpXXpxQbbGJE/gCa+UlRVVfHj7LjfRQ+Lj7LjfRQ+Lj7LjfRQ+Lh6SxHbjvR8hdkmzEhziJiYJ1V0FXpxHtsh1UsvErrNtlgS9RiaZKFtmpUhEFB89ma6tk4q+inJw1YULsodsfurgJqV24SSiNqX5zYW4qdCH7uInikf27uHYnDXDiXaAs5145KWa5zssk2mENlX4DzTdRbAVovWTN0Ux9yPw1xD9bx9yPw1xD9cx9yPw1xD9cxxDLukbdLjIfdemxt3OLu8gpA7Rrd3O0byr8LrdOnThCFVEhVFEk0KippRUXpTHtjma3z2K7+rl7Lfu5t8y5Oje9GXyYiEXmucM282/VSddW1/XBcRfFI/tncGvBmfulZruaq2DLvmzZ22RLsu3RMmTzepX3a4/8XhmRfJiwmJDqsMubtwvJQnUFTyfNGH1Fcic9Mfb/wDtdm/47F4uE58pEuYqyJDxZUVxxx0FJcoIICnQiIgomhOTYdbbew2+a1rumTvDX8HcPexw5xO0FQYORZZpIlcqPfPICrTUCE2+ir0kmIjz5ZG6uARrqHatG2il0ChFpwrVqvV0gR3T2yt2+4y4zDhkKDtVGO8AERCCJXoTH3p4i/1q4/WcNJdLtcrkLCkrSTp0mUjSuUQ1bR9xxAUkFK05JDRGO1kIANN5uuXaCpLTSuURH8q4hWyE2rsu4S48KM0ms35TostD5TPHspnLce4PZ7aUTPuvd3duenm5tji6cPXDQxcYyto6goRxpAqjkWW2i0q5GkAJonPSmrE6xXdhWJsB5Wz17N5vWzJjkqJtI8huhAvQvTyFCfPtIg5gIlpmjJ7q/uNXq0wbqKuwb7KOOn5NF8+nwnF0+9zY18nt5dWFGHD2zHD7bgf1UskJmTcUza2YgKTYLTS6qqiorenkFJHzC9RGyG23httCNpFXNu0puo71CI9OWqKCrUVSq1Jm+21wI6nlj3OOhP2uV0bGWgoImSfszyOJzjhVAlFVEgXKtKiSZSHxEK8jbLDbjzzpi2000BOOOGS0EGwBFIyJdSJiPeON2XbXahUHW7ISq3c7h6SBMQVQ7bGL0kXt10pQNBYZixWWo8aO0DEdhkBaZZZaFAbaabBEEGwFKIiaETwH+8N23LZrvO+bLddl6W323ZbP1tGCGe7Z2ZNVq5w4l7WOnTT2dbdtnvYzFcpshK12bwcaoHq9hAYOiePH/Q/ZneNn1tx2PfGy/wARvP8Am2T1/A//2gAIAQEDAT8h9ApEay4ynrWWF4ctOGJ5WfGfWwb19JFjN9oJRDKrgFsWAQu0/wBNodMdOnfsaae2xsYFZKGotcNkDRnW4hJRr7OJuPyH0At0gOKY4RgkzrUKVQqbJIjoDckFThEeUKETOUFL3dk25BGYV/E1h1LnT/yvoBf9XFC0Y9QKk0mAQ3KYF8BmqHga3YhY46OjHjNXuYj0S+OsyD3lAtIb0H/Xj8jN534sKHDDSXkPWjb21KX+FCnAmxCmfXRX8cofjVNzRFA1wPSyXhunwLgTVorx+74v/ebPqwnUPypIYx9CwxMvCIE3RxAAB6fWQx3eLjjxj3GnF5OJRqXlMKgLBLvuga4DedPMyqSs6qodjNf7H9MFuj74mxrQob4wHn6+9w2yFV0fNEV0WFozuSHFb6AG2oGfTqePlTi4WFbgE0FMAb2zkxBMNzssaKXcFBXu/nBVE++5OoFtdV2Obha0gO2Um16gmHkfly5DbIsGN0GEj18EwQsEwnKk1SnBy/TpRa2EBYi4MSQgES6klYE6j6G1UMecmgAVXWBiOxZEAaCg+RxCyqeSSdxgEPZ9AED8tgmvVKLxVr5+OuG6x0fZE6S8985/zZj/AC/bb1vs/9oACAECAwE/If7OklVHKNP30++DtQ7t/LV++fXf6z6h/WfXP6ykJQ6oAIdjRlobns/jZdfWhwRhgu1Smtd/QXx8Pj4YdXdYIY0/bXbXs/jZ1ImT+Vl8l53PE9Lfd4cDi+Z6SGKNHYO5v87evshklOgmr4qV6G8U4KO8xEOt3tv0GJJfntJxYL6RFnqbRWdgO+LrlPbXBjl6Xn6I/wCzG+eH8Ozu9uvB0zye9RWSlGaET4TT4/r/AP/aAAgBAwMBPyH+zDkgXwBI69B1kecbd0YB8CB8Bnw3oPHblgYYCVYNBpsCXY1p7N8FDpSa90hGg0dl7Z4mQ6+/oId7NR8tpsn+xWr6mwxZ2y5NdGnQnRye/oh6c+PFmya7zCuxMizFG6rXiAdgADgOPYupBjmjDukh1ddc6C9q9KqHQDq6DKFyo4gPys2MWdMOLeKytEeCK4okqyxB9tOTGFMycn+tHc9xnOeb5HX2NOnPUzxGQOPcMGgpYlDygR6O/wCv/9oADAMBAAIRAxEAABACCQAAAACAG3YgSYaQCQsPiAiEeSQ37gCCgQACSAAf/9oACAEBAwE/EPTZAiVTGSn5I0xvyNaXEqvn+MPnZBsRaVlN/rxKjMF1OUeYIjab+01oGWUETQAh6frf4ws4bFEhjLuGPRoSVKgcqLkiq+x/xnjSegtnRlWRrktTJah6HuWhSgCvBVSxt5WFu5KH9ShV1W6Ic2IgNC+WqG1bvJ8opeNb1H/nNu/wE1BdNbyGpm9rfn44e3qeZFb1DWhINclIUoP7I9BtHfowB8jjxWpkKhQOX6aMpj7mTCTR0PwN8CTLnw/xvgnJJzGPuoc49pQbrL3Z4zRa2mNi0zyDh1jYNmdKCyGxM+QBL5b+XS8plLgRuvOzRGm67UwKJrfXRpHcehjjKTMp2NYCxFtkbdfIDrul7y33Rla/44+SI4dazqdG8UDUwtPQ18Qfl7Hn63ngv8lm2Zt1cMB1wukRgoJALdJiGkVVStMHFokQP5JLIO1AL8K8JzmcofHfFzdOQgZAQWoJAk3tVi9Nr2OXEniYEEtP+DwQZga8hIS4UAqoC584L7hH9C+MTA58/wAQLlI8aXIAoAm75wwVmDIEHQQfjjH474JZiotgAzkCH1tHJa2upQlBn0J+8UtVXutfy4rIhoHm445UE/M+d/nv6VP0vaWRJhZI+xqjaT+x5tAorUdG+pqWPpAk9ApkJ/Cg8FgFcTW/BedAhnm+A0zpzm02zAAE9n6hmT4JPzM35/R+AvVErU6IeTM+RdgrF1qvU0+l+b74PbznsP/aAAgBAgMBPxD+zUIHCiWKInNSIJGhjFEYVWa2Ku6leuX3uw68LfvZSbAJHCuraATNiPqgd4zYC3fY0MNRAla2Whw9NyY5LRB/0vSRTYzMCQHsdp4fKF/Jh8sxZjY6YKANVxpwB2DSpSm8uaGcrqxVAQVKdNUoqlV9g8lY0qwYBuGWWjH5sjXSg03Qjsnrkt0/Lg+lA1zUNAKoNC5E6fxhvlzHDEVFjOguB9gehQ+cRsCOhxV1tGUBRY8D76rAZ2UllCBVZzyPy4qtdvueJaIlj5ypB0pHT/X/AP/aAAgBAwMBPxD+zbVewK0FqkkIiEWEd6aMO4IZwAI40h+Tfb0nZa8gtkVuM1YqtufQSEepRHL/AD4K5eitKO1CSRbqCbNHfMk4vBf1wqbu+x/LB99YDTbHDvnmck1Z9gYWj/jTBsEYXBXSQNZaeTZug+vlxkbJuC0uIUSGMWYIctv6X11MjN1QXkAAdAIAAHqXkFlIXgsBxTDsYLfBiVCXAWNCOADSpeN/36Exn6gqgVpwBoUC8GI4G9X/AHaf4M69EzAZmheRime1RQX4wBGhV7IDUgF2Mji4gAQdLTawTVIUQz/xDAEAHuENFEAwkYU2wBsH+v8A/9k="
|
2307 |
+
align="middle">
|
2308 |
+
<h2>WP Live Chat by 3CX</h2>
|
2309 |
+
<?php do_action( "wplc_hook_chat_dashboard_above" ); ?>
|
2310 |
+
</div>
|
2311 |
+
<div id="wplc_admin_chat_info_new" class="wplc_admin_chat_on_premise_header_right">
|
2312 |
+
<div class="wplc_admin_chat_on_premise_switchery_label">
|
2313 |
+
<b><?php _e( "Keep this window open to get notified of new chats.", 'wp-live-chat-support' ); ?></b>
|
2314 |
+
</div>
|
2315 |
+
<div class='wplc_chat_vis_count_box'>
|
2316 |
+
<?php do_action( "wplc_hook_chat_dahsboard_visitors_online_top" ); ?>
|
2317 |
+
<div class="wplc_chat_dashboard_on_premise_stats">
|
2318 |
+
<span class='wplc_vis_online'>0</span> <?php _e( "Visitor(s) online", 'wp-live-chat-support' ); ?>
|
2319 |
+
</div>
|
2320 |
+
<div class="wplc_chat_dashboard_on_premise_stats">
|
2321 |
+
<?php echo apply_filters( "wplc_filter_chat_dahsboard_visitors_online_bottom", "" ); ?>
|
2322 |
+
</div>
|
2323 |
+
<?php do_action( "wplc_after_chat_visitor_count_hook" ); ?>
|
2324 |
+
</div>
|
2325 |
+
</div>
|
2326 |
+
</div>
|
2327 |
+
<div id="wplc_admin_chat_area_new">
|
2328 |
+
<div style="display:block;">
|
2329 |
+
<div class='wplc_chat_on_premise_header'>
|
2330 |
+
<div class='wplc_header_vh wplc_header_v'><?php _e( "Visitor", 'wp-live-chat-support' ); ?></div>
|
2331 |
+
<div class='wplc_header_vh wplc_header_t'><?php _e( "Time", 'wp-live-chat-support' ); ?></div>
|
2332 |
+
<div class='wplc_header_vh wplc_header_nr'><?php _e( "Type", 'wp-live-chat-support' ); ?></div>
|
2333 |
+
<div class='wplc_header_vh wplc_header_dev'><?php _e( "Device", 'wp-live-chat-support' ); ?></div>
|
2334 |
+
<div class='wplc_header_vh wplc_header_d'><?php _e( "Data", 'wp-live-chat-support' ); ?></div>
|
2335 |
+
<div class='wplc_header_vh wplc_header_s'><?php _e( "Status", 'wp-live-chat-support' ); ?></div>
|
2336 |
+
<div class='wplc_header_vh wplc_header_a'><?php _e( "Action", 'wp-live-chat-support' ); ?></div>
|
2337 |
+
</div>
|
2338 |
+
<div id='wplc_chat_ul'></div>
|
2339 |
+
</div>
|
2340 |
+
</div>
|
2341 |
+
</div>
|
2342 |
+
<?php
|
2343 |
+
} else {
|
2344 |
+
if ( isset( $_GET['aid'] ) ) {
|
2345 |
+
$aid = intval( $_GET['aid'] );
|
2346 |
+
} else {
|
2347 |
+
$aid = null;
|
2348 |
+
}
|
2349 |
+
if ( ! is_null( $aid ) ) {
|
2350 |
+
do_action( "wplc_hook_update_agent_id", intval( $_GET['cid'] ), $aid );
|
2351 |
+
}
|
2352 |
+
if ( $_GET['action'] == 'ac' ) {
|
2353 |
+
do_action( 'wplc_hook_accept_chat', $_GET, $aid );
|
2354 |
+
}
|
2355 |
+
do_action( "wplc_hook_admin_menu_layout_display", $_GET['action'], intval( $_GET['cid'] ), $aid );
|
2356 |
+
}
|
2357 |
+
} else {
|
2358 |
+
?>
|
2359 |
+
<h1><?php _e( "Chat Dashboard", 'wp-live-chat-support' ); ?></h1>
|
2360 |
+
<div id="welcome-panel" class="welcome-panel">
|
2361 |
+
<div class="welcome-panel-content">
|
2362 |
+
<h2><?php _e( "Oh no!", 'wp-live-chat-support' ); ?></h2>
|
2363 |
+
<p class="about-description">
|
2364 |
+
<?php echo sprintf( __( "You do not have access to this page as %s.", 'wp-live-chat-support' ), '<strong>' . __( 'you are not a chat agent', 'wp-live-chat-support' ) . '</strong>' ); ?>
|
2365 |
+
</p>
|
2366 |
+
</div>
|
2367 |
+
</div>
|
2368 |
+
<?php
|
2369 |
+
}
|
2370 |
}
|
2371 |
|
2372 |
+
add_action( "wplc_hook_change_status_on_answer", "wplc_hook_control_change_status_on_answer", 10, 2 );
|
2373 |
+
function wplc_hook_control_change_status_on_answer( $get_data, $chat_data = false ) {
|
2374 |
|
2375 |
+
$user_ID = get_current_user_id();
|
2376 |
+
wplc_change_chat_status( sanitize_text_field( $get_data['cid'] ), 3, $user_ID );
|
2377 |
+
wplc_record_chat_notification( "joined", $get_data['cid'], array( "aid" => $user_ID ) );
|
2378 |
}
|
2379 |
|
2380 |
|
2381 |
+
add_action( 'wplc_hook_accept_chat', 'wplc_hook_control_accept_chat', 10, 2 );
|
2382 |
+
function wplc_hook_control_accept_chat( $get_data, $aid ) {
|
2383 |
|
2384 |
global $admin_chat_data;
|
2385 |
|
2386 |
+
if ( ! $admin_chat_data ) {
|
2387 |
+
$chat_data = wplc_get_chat_data( $get_data['cid'], __LINE__ );
|
2388 |
} else {
|
2389 |
+
if ( isset( $admin_chat_data->id ) && intval( $admin_chat_data->id ) === intval( $get_data['cid'] ) ) {
|
2390 |
$chat_data = $admin_chat_data;
|
2391 |
} else {
|
2392 |
/* chat ID's dont match, get the data for the correct chat ID */
|
2393 |
+
$chat_data = wplc_get_chat_data( $get_data['cid'], __LINE__ );
|
2394 |
}
|
2395 |
}
|
2396 |
|
2397 |
|
2398 |
+
do_action( "wplc_hook_accept_chat_url", $get_data, $chat_data );
|
2399 |
+
do_action( "wplc_hook_change_status_on_answer", $get_data, $chat_data );
|
2400 |
+
do_action( "wplc_hook_draw_chat_area", $get_data, $chat_data );
|
2401 |
|
2402 |
|
2403 |
}
|
2404 |
|
2405 |
/**
|
2406 |
+
* Hook to accept chat
|
2407 |
+
*
|
2408 |
+
* @param
|
2409 |
+
*
|
2410 |
+
* @return void
|
2411 |
+
*
|
2412 |
+
* @since 7.1.00
|
2413 |
+
*/
|
2414 |
+
add_action( 'wplc_hook_accept_chat_url', 'wplc_b_hook_control_accept_chat_url', 5, 2 );
|
2415 |
+
function wplc_b_hook_control_accept_chat_url( $get_data, $chat_data = false ) {
|
2416 |
+
if ( ! isset( $get_data['agent_id'] ) ) {
|
2417 |
+
/* free version */
|
2418 |
+
wplc_b_update_agent_id( sanitize_text_field( $get_data['cid'] ), get_current_user_id() );
|
2419 |
+
} else {
|
2420 |
+
wplc_b_update_agent_id( sanitize_text_field( $get_data['cid'] ), sanitize_text_field( $get_data['agent_id'] ) );
|
2421 |
+
}
|
2422 |
|
2423 |
}
|
2424 |
|
2425 |
/**
|
2426 |
+
* Assign the chat to the agent
|
2427 |
+
*
|
2428 |
+
* Replaces the same function of a different name in the older pro version
|
2429 |
+
*
|
2430 |
+
* @param
|
2431 |
+
*
|
2432 |
+
* @return void
|
2433 |
+
*
|
2434 |
+
* @since 7.1.00
|
2435 |
+
*/
|
2436 |
+
function wplc_b_update_agent_id( $cid, $aid ) {
|
2437 |
+
global $wpdb;
|
2438 |
+
global $wplc_tblname_chats;
|
2439 |
+
$result = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM `$wplc_tblname_chats` WHERE `id` = '%d' LIMIT 1", $cid ) );
|
2440 |
+
if ( $result ) {
|
2441 |
+
if ( intval( $result->status ) != 3 ) {
|
2442 |
+
$wpdb->query( $wpdb->prepare( "UPDATE `$wplc_tblname_chats` SET `agent_id` = %d WHERE `id` = %d LIMIT 1", $aid, $cid ) );
|
2443 |
+
}
|
2444 |
}
|
2445 |
}
|
2446 |
|
2447 |
|
2448 |
+
add_action( "wplc_hook_draw_chat_area", "wplc_hook_control_draw_chat_area", 10, 2 );
|
2449 |
+
function wplc_hook_control_draw_chat_area( $get_data, $chat_data = false ) {
|
2450 |
|
2451 |
+
wplc_draw_chat_area( sanitize_text_field( $get_data['cid'] ), $chat_data );
|
2452 |
}
|
2453 |
|
2454 |
+
function wplc_draw_chat_area( $cid, $chat_data = false ) {
|
2455 |
|
2456 |
+
global $wpdb;
|
2457 |
+
global $wplc_tblname_chats;
|
2458 |
|
2459 |
+
$results = $wpdb->get_results( $wpdb->prepare( "
|
2460 |
SELECT *
|
2461 |
FROM $wplc_tblname_chats
|
2462 |
WHERE `id` = %s
|
2463 |
LIMIT 1
|
2464 |
+
", $cid )
|
2465 |
+
);
|
2466 |
+
|
2467 |
+
if ( $results ) {
|
2468 |
+
|
2469 |
+
$result = apply_filters( "wplc_filter_chat_area_data", $results[0], $cid );
|
2470 |
+
|
2471 |
+
?>
|
2472 |
+
<style>
|
2473 |
+
|
2474 |
+
.wplc-clear-float-message {
|
2475 |
+
clear: both;
|
2476 |
+
}
|
2477 |
+
|
2478 |
+
.rating {
|
2479 |
+
background-color: lightgray;
|
2480 |
+
width: 80px;
|
2481 |
+
padding: 2px;
|
2482 |
+
border-radius: 4px;
|
2483 |
+
text-align: center;
|
2484 |
+
color: white;
|
2485 |
+
float: right;
|
2486 |
+
}
|
2487 |
+
|
2488 |
+
.rating-bad {
|
2489 |
+
background-color: #AF0B0B !important;
|
2490 |
+
}
|
2491 |
+
|
2492 |
+
.rating-good {
|
2493 |
+
background-color: #368437 !important;
|
2494 |
+
}
|
2495 |
+
|
2496 |
+
#wpcontent {
|
2497 |
+
margin-left: 0 !important;
|
2498 |
+
padding: 15px;
|
2499 |
+
}
|
2500 |
+
|
2501 |
+
#wpbody-content {
|
2502 |
+
padding-bottom: 0;
|
2503 |
+
}
|
2504 |
+
|
2505 |
+
html.wp-toolbar {
|
2506 |
+
padding-top: 0 !important;
|
2507 |
+
}
|
2508 |
+
|
2509 |
+
@media screen and (max-width: 600px) {
|
2510 |
+
#wpbody {
|
2511 |
+
padding-top: 0px !important;
|
2512 |
+
}
|
2513 |
+
}
|
2514 |
+
|
2515 |
+
</style>
|
2516 |
+
<?php
|
2517 |
+
|
2518 |
+
$user_data = maybe_unserialize( $result->ip );
|
2519 |
+
$browser = isset( $user_data['user_agent'] ) ? wplc_return_browser_string( $user_data['user_agent'] ) : "Unknown";
|
2520 |
+
$browser_image = wplc_return_browser_image( $browser, "16" );
|
2521 |
+
|
2522 |
+
if ( $result->status == 1 ) {
|
2523 |
+
$status = __( "Previous", 'wp-live-chat-support' );
|
2524 |
+
} else {
|
2525 |
+
$status = __( "Active", 'wp-live-chat-support' );
|
2526 |
}
|
2527 |
+
|
2528 |
+
echo "<div class=\"wplc_on_premise_chat_window\">";
|
2529 |
+
echo "<div class=\"wplc_on_premise_chat_window_header\">";
|
2530 |
+
echo "<h2>$status " . __( 'Chat with', 'wp-live-chat-support' ) . " " . esc_html( $result->name ) . "</h2>";
|
2531 |
+
|
2532 |
+
if ( isset( $_GET['action'] ) && $_GET['action'] === "ac" ) {
|
2533 |
+
echo "<div class=\"end_chat_div\">";
|
2534 |
+
|
2535 |
+
do_action( "wplc_admin_chat_area_before_end_chat_button", $result );
|
2536 |
+
|
2537 |
+
echo "<a href=\"javascript:void(0);\" class=\"wplc_admin_close_chat button\" id=\"wplc_admin_close_chat\"><i class=\"fa fa-times\" aria-hidden=\"true\"></i> " . __( "End chat", 'wp-live-chat-support' ) . "</a>";
|
2538 |
+
|
2539 |
+
do_action( "wplc_admin_chat_area_after_end_chat_button", $result );
|
2540 |
+
do_action( "wplc_hook_admin_visitor_info_display_after", $cid );
|
2541 |
+
|
2542 |
+
echo "</div>";
|
2543 |
}
|
2544 |
+
echo "</div>";
|
2545 |
+
|
2546 |
+
if ( isset( $_GET['action'] ) && 'history' === $_GET['action'] ) {
|
2547 |
+
echo "<span class='wplc-history__date'><strong>" . __( 'Starting Time:', 'wp-live-chat-support' ) . ' </strong>' . date( 'Y-m-d H:i:s', current_time( strtotime( $result->timestamp ) ) ) . "</span>";
|
2548 |
+
echo "<span class='wplc-history__date wplc-history__date-end'><strong>" . __( 'Ending Time:', 'wp-live-chat-support' ) . ' </strong>' . date( 'Y-m-d H:i:s', current_time( strtotime( $result->last_active_timestamp ) ) ) . "</span>";
|
2549 |
}
|
2550 |
+
echo "<style>#adminmenuwrap { display:none; } #adminmenuback { display:none; } #wpadminbar { display:none; } #wpfooter { display:none; } .update-nag { display:none; }</style>";
|
2551 |
+
|
2552 |
+
if ( empty( $chat_data ) ) {
|
2553 |
+
$chat_data = wplc_get_chat_data( $cid );
|
2554 |
}
|
2555 |
+
do_action( "wplc_add_js_admin_chat_area", $cid, $chat_data );
|
2556 |
+
|
2557 |
+
echo "<div id='admin_chat_box'>";
|
2558 |
+
|
2559 |
+
$result->continue = true;
|
2560 |
+
|
2561 |
+
//do_action("wplc_hook_wplc_draw_chat_area",$result);
|
2562 |
+
|
2563 |
+
if ( ! $result->continue ) {
|
2564 |
+
return;
|
2565 |
}
|
2566 |
|
2567 |
+
echo "<div class='wplc_on_premise_chat_box_user_info'>";
|
2568 |
+
echo "<div class='wplc_on_premise_chat_box_user_info_avatar'><img src=\"//www.gravatar.com/avatar/" . md5( $result->email ) . "?d=mm\" class=\"admin_chat_img\" width=\"50px\" /></div>";
|
2569 |
+
echo sprintf( "<div class='wplc_on_premise_chat_box_user_info_details'>%s, (%s)<br>", sanitize_text_field( $result->name ), sanitize_text_field( $result->email ) );
|
2570 |
+
echo "<span class='part1'><b>" . __( "Chat initiated on:", 'wp-live-chat-support' ) . "</b></span> <span class='part2'>" . esc_url( $result->url ) . "</span><br>";
|
2571 |
+
echo "<span class='part1'><b>" . __( "Browser:", 'wp-live-chat-support' ) . "</b></span><span class='part2'> $browser <img src='" . WPLC_PLUGIN_URL . "images/$browser_image' alt='$browser' title='$browser' align='absmiddle' /></span>";
|
2572 |
|
2573 |
+
echo( apply_filters( "wplc_filter_advanced_info", "", sanitize_text_field( $result->id ), sanitize_text_field( $result->name ), $result ) );
|
2574 |
+
echo "</div>";
|
2575 |
+
echo "</div>";
|
2576 |
|
2577 |
+
echo "<div class='admin_chat_box'><div class='admin_chat_box_inner' id='admin_chat_box_area_" . intval( $result->id ) . "'>";
|
2578 |
+
if ( isset( $_GET['action'] ) && 'history' === $_GET['action'] ) {
|
2579 |
+
echo wplc_return_chat_messages( $cid, true );
|
2580 |
+
}
|
2581 |
+
echo "</div>";
|
2582 |
|
2583 |
+
if ( isset( $_GET['action'] ) && $_GET['action'] === "ac" ) {
|
2584 |
+
echo "<div class='admin_chat_box_inner_bottom'>" . wplc_return_chat_response_box( $cid, $result ) . "</div>";
|
2585 |
+
}
|
|
|
|
|
|
|
2586 |
|
2587 |
+
echo "</div>";
|
2588 |
|
2589 |
+
echo "</div>";
|
2590 |
|
2591 |
+
if ( $result->status != 1 ) {
|
|
|
2592 |
|
2593 |
+
do_action( "wplc_hook_admin_below_chat_box", $result );
|
2594 |
+
}
|
2595 |
+
|
2596 |
+
} else {
|
2597 |
+
wp_die( __( "Invalid Chat ID", 'wp-live-chat-support' ) );
|
2598 |
}
|
2599 |
+
|
2600 |
+
}
|
2601 |
+
|
2602 |
+
function wplc_return_chat_response_box( $cid, $chat_data = false ) {
|
2603 |
+
$ret = "<div class=\"chat_response_box\">";
|
2604 |
+
$ret .= apply_filters( "wplc_filter_typing_control_div", "" );
|
2605 |
+
$ret .= "<input type='text' name='wplc_admin_chatmsg' id='wplc_admin_chatmsg' value='' placeholder='" . __( "type here...", 'wp-live-chat-support' ) . "' />";
|
2606 |
+
|
2607 |
+
$ret .= apply_filters( "wplc_filter_chat_upload", "" );
|
2608 |
+
|
2609 |
+
$ret .= "<input id='wplc_admin_cid' type='hidden' value='" . esc_attr( $cid ) . "' />";
|
2610 |
+
$ret .= "<input id='wplc_admin_send_msg' type='button' value='" . __( "Send", 'wp-live-chat-support' ) . "' style=\"display:none;\" />";
|
2611 |
+
$ret .= "</div>";
|
2612 |
+
|
2613 |
+
return $ret;
|
2614 |
+
}
|
2615 |
+
|
2616 |
+
function wplc_return_admin_chat_javascript( $cid ) {
|
2617 |
+
$ajax_nonce = wp_create_nonce( "wplc" );
|
2618 |
+
$wplc_settings = wplc_get_options();
|
2619 |
+
|
2620 |
+
wp_register_script( 'wplc-admin-chat-server', wplc_plugins_url( '/js/wplc_server.js', __FILE__ ), array(), WPLC_PLUGIN_VERSION, true );
|
2621 |
+
wp_enqueue_script( 'wplc-admin-chat-server' );
|
2622 |
+
|
2623 |
+
wp_localize_script( 'wplc-admin-chat-server', 'wplc_datetime_format', array(
|
2624 |
+
'date_format' => get_option( 'date_format' ),
|
2625 |
+
'time_format' => get_option( 'time_format' ),
|
2626 |
+
) );
|
2627 |
+
|
2628 |
+
global $admin_chat_data;
|
2629 |
+
if ( ! $admin_chat_data ) {
|
2630 |
+
$cdata = wplc_get_chat_data( $cid, __LINE__ );
|
2631 |
+
} else {
|
2632 |
+
/* copy the stored admin chat data variable - more efficient */
|
2633 |
+
$cdata = $admin_chat_data;
|
2634 |
}
|
|
|
2635 |
|
2636 |
+
if ( empty( $cdata ) ) {
|
2637 |
+
wp_die( __( "Invalid Chat ID", 'wp-live-chat-support' ) );
|
2638 |
+
}
|
2639 |
+
|
2640 |
+
$other = maybe_unserialize( $cdata->other );
|
2641 |
+
|
2642 |
+
if ( $wplc_settings['wplc_use_node_server'] ) {
|
2643 |
+
if ( isset( $other['socket'] ) && ( $other['socket'] == true || $other['socket'] == "true" ) ) {
|
2644 |
+
wp_localize_script( 'wplc-admin-chat-server', 'tcx_api_key', wplc_node_server_token_get() );
|
2645 |
+
}
|
2646 |
+
}
|
2647 |
|
2648 |
+
/**
|
2649 |
+
* Create a JS object for all Agent ID's and Gravatar MD5's
|
2650 |
+
*/
|
2651 |
+
$user_array = wplc_get_agent_users();
|
2652 |
+
$a_array = array();
|
2653 |
+
foreach ( $user_array as $user ) {
|
2654 |
+
$a_array[ $user->ID ] = array();
|
2655 |
+
$a_array[ $user->ID ]['name'] = sanitize_text_field( $user->display_name );
|
2656 |
+
$a_array[ $user->ID ]['md5'] = md5( $user->user_email );
|
2657 |
+
}
|
2658 |
+
wp_localize_script( 'wplc-admin-chat-server', 'wplc_agent_data', $a_array );
|
2659 |
+
|
2660 |
+
/**
|
2661 |
+
* Get the CURRENT agent's data
|
2662 |
+
*/
|
2663 |
+
if ( isset( $_GET['aid'] ) ) {
|
2664 |
+
$agent_data = get_user_by( 'ID', intval( $_GET['aid'] ) );
|
2665 |
+
wp_localize_script( 'wplc-admin-chat-server', 'wplc_admin_agent_name', sanitize_text_field( $agent_data->display_name ) );
|
2666 |
+
wp_localize_script( 'wplc-admin-chat-server', 'wplc_admin_agent_email', md5( $agent_data->user_email ) );
|
2667 |
+
} else {
|
2668 |
+
$agent_data = get_user_by( 'ID', intval( get_current_user_id() ) );
|
2669 |
+
wp_localize_script( 'wplc-admin-chat-server', 'wplc_admin_agent_name', sanitize_text_field( $agent_data->display_name ) );
|
2670 |
+
wp_localize_script( 'wplc-admin-chat-server', 'wplc_admin_agent_email', md5( $agent_data->user_email ) );
|
2671 |
+
}
|
2672 |
|
2673 |
+
if ( ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'history' ) {
|
2674 |
+
// do not load if displaying chat history
|
2675 |
+
} else {
|
2676 |
+
wp_register_script( 'wplc-admin-chat-js', wplc_plugins_url( '/js/wplc_u_admin_chat.js', __FILE__ ), array( 'wplc-admin-chat-server' ), WPLC_PLUGIN_VERSION, false );
|
2677 |
+
wp_enqueue_script( 'wplc-admin-chat-js' );
|
2678 |
+
}
|
2679 |
|
|
|
2680 |
|
2681 |
+
$wplc_theme = wplc_get_theme();
|
2682 |
+
|
2683 |
+
switch ( $wplc_theme ) {
|
2684 |
+
case 'theme-default':
|
2685 |
+
wp_register_style( 'wplc-theme-palette-default', wplc_plugins_url( '/css/themes/theme-default.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
2686 |
+
wp_enqueue_style( 'wplc-theme-palette-default' );
|
2687 |
+
break;
|
2688 |
+
case 'theme-1':
|
2689 |
+
case 'theme-2':
|
2690 |
+
case 'theme-3':
|
2691 |
+
case 'theme-4':
|
2692 |
+
case 'theme-5':
|
2693 |
+
$tid = substr( $wplc_theme, - 1, 1 );
|
2694 |
+
wp_register_style( 'wplc-theme-palette-' . $tid, wplc_plugins_url( '/css/themes/theme-' . $tid . '.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
2695 |
+
wp_enqueue_style( 'wplc-theme-palette-' . $tid );
|
2696 |
+
break;
|
2697 |
+
case 'theme-6':
|
2698 |
+
/* custom */
|
2699 |
+
/* handled elsewhere */
|
2700 |
+
break;
|
2701 |
+
}
|
2702 |
|
2703 |
+
if ( isset( $cdata->agent_id ) ) {
|
2704 |
+
$wplc_agent_data = get_user_by( 'id', intval( $cdata->agent_id ) );
|
2705 |
+
}
|
|
|
|
|
2706 |
|
2707 |
+
$wplc_chat_detail = array(
|
2708 |
+
'name' => $wplc_settings['wplc_show_name'],
|
2709 |
+
'avatar' => $wplc_settings['wplc_show_avatar'],
|
2710 |
+
'date' => $wplc_settings['wplc_show_date'],
|
2711 |
+
'time' => $wplc_settings['wplc_show_time']
|
2712 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2713 |
|
2714 |
+
wp_enqueue_script( 'wplc-admin-chat-js' );
|
2715 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_show_chat_detail', $wplc_chat_detail );
|
2716 |
|
2717 |
+
if ( ! empty( $wplc_agent_data ) ) {
|
2718 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_name', sanitize_text_field( $wplc_agent_data->display_name ) );
|
2719 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_email', md5( $wplc_agent_data->user_email ) );
|
2720 |
+
} else {
|
2721 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_name', null );
|
2722 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_email', null );
|
2723 |
+
}
|
2724 |
|
2725 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_chat_name', sanitize_text_field( $cdata->name ) );
|
2726 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_chat_email', md5( $cdata->email ) );
|
2727 |
|
2728 |
+
if ( class_exists( "WP_REST_Request" ) ) {
|
2729 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_restapi_enabled', array( 'value' => true ) );
|
2730 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_restapi_token', get_option( 'wplc_api_secret_token' ) );
|
2731 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_restapi_endpoint', rest_url( 'wp_live_chat_support/v1' ) );
|
2732 |
+
} else {
|
2733 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_restapi_enabled', array( 'value' => false ) );
|
2734 |
+
}
|
2735 |
+
|
2736 |
+
$src = wplc_get_admin_picture();
|
2737 |
+
if ( $src ) {
|
2738 |
+
$image = "<img src=" . $src . " width='20px' id='wp-live-chat-2-img'/>";
|
2739 |
+
} else {
|
2740 |
+
$image = " ";
|
2741 |
+
}
|
2742 |
+
|
2743 |
+
$admin_pic = $image;
|
2744 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_localized_string_is_typing', __( "is typing...", 'wp-live-chat-support' ) );
|
2745 |
+
wp_localize_script( 'wplc-user-script', 'wplc_localized_string_admin_name', apply_filters( 'wplc_filter_admin_name', 'Admin' ) );
|
2746 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_ajax_nonce', $ajax_nonce );
|
2747 |
+
wp_localize_script( 'wplc-admin-chat-js', 'admin_pic', $admin_pic );
|
2748 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_ding_file', apply_filters( 'wplc_filter_message_sound', '' ) );
|
2749 |
+
|
2750 |
+
$extra_data = apply_filters( "wplc_filter_admin_javascript", array() );
|
2751 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_extra_data', $extra_data );
|
2752 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_enable_ding', array( 'value' => boolval( $wplc_settings['wplc_enable_msg_sound'] ) ) );
|
2753 |
+
|
2754 |
+
$ajax_url = admin_url( 'admin-ajax.php' );
|
2755 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_ajaxurl', apply_filters( "wplc_filter_ajax_url", $ajax_url ) );
|
2756 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_home_ajaxurl', $ajax_url );
|
2757 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_url', admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid=' . $cid ) );
|
2758 |
+
|
2759 |
+
$wplc_string1 = __( "User has opened the chat window", 'wp-live-chat-support' );
|
2760 |
+
$wplc_string2 = __( "User has minimized the chat window", 'wp-live-chat-support' );
|
2761 |
+
$wplc_string3 = __( "User has maximized the chat window", 'wp-live-chat-support' );
|
2762 |
+
$wplc_string4 = __( "The chat has been ended", 'wp-live-chat-support' );
|
2763 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_string1', $wplc_string1 );
|
2764 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_string2', $wplc_string2 );
|
2765 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_string3', $wplc_string3 );
|
2766 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_string4', $wplc_string4 );
|
2767 |
+
wp_localize_script( 'wplc-admin-chat-js', 'wplc_cid', $cid );
|
2768 |
+
do_action( "wplc_hook_admin_chatbox_javascript" );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2769 |
}
|
2770 |
|
2771 |
function wplc_activate() {
|
2772 |
+
wplc_set_defaults();
|
2773 |
+
wplc_check_guid();
|
2774 |
+
wplc_handle_db();
|
2775 |
+
|
2776 |
+
$wplc_settings = wplc_get_options( true );
|
2777 |
+
if ( current_user_can( 'manage_options' ) ) {
|
2778 |
+
global $user_ID;
|
2779 |
+
$user = new WP_User( $user_ID );
|
2780 |
+
foreach ( $user->roles as $urole ) {
|
2781 |
+
if ( $urole == "administrator" ) {
|
2782 |
+
$admins = get_role( 'administrator' );
|
2783 |
+
$admins->add_cap( 'edit_wplc_quick_response' );
|
2784 |
+
$admins->add_cap( 'edit_wplc_quick_response' );
|
2785 |
+
$admins->add_cap( 'edit_other_wplc_quick_response' );
|
2786 |
+
$admins->add_cap( 'publish_wplc_quick_response' );
|
2787 |
+
$admins->add_cap( 'read_wplc_quick_response' );
|
2788 |
+
$admins->add_cap( 'read_private_wplc_quick_response' );
|
2789 |
+
$admins->add_cap( 'delete_wplc_quick_response' );
|
2790 |
+
}
|
2791 |
+
}
|
2792 |
+
}
|
2793 |
+
$wplc_settings = wplc_cleanup_old_options( $wplc_settings );
|
2794 |
+
update_option( 'WPLC_SETTINGS', $wplc_settings );
|
2795 |
+
$uid = get_current_user_id();
|
2796 |
+
wplc_set_agent_accepting( $uid, true );
|
2797 |
+
update_user_meta( $uid, 'wplc_ma_agent', 1 );
|
2798 |
+
wplc_update_agent_time( $uid );
|
2799 |
+
|
2800 |
+
$admins = get_role( 'administrator' );
|
2801 |
+
if ( $admins !== null ) {
|
2802 |
+
$admins->add_cap( 'wplc_ma_agent' );
|
2803 |
+
}
|
2804 |
+
add_option( "WPLC_HIDE_CHAT", "true" );
|
2805 |
+
do_action( "wplc_activate_hook" );
|
2806 |
}
|
2807 |
|
2808 |
|
2811 |
* @return void
|
2812 |
* @since 1.0.00
|
2813 |
*/
|
2814 |
+
if ( ! function_exists( "wplc_choose_activate" ) ) {
|
2815 |
+
register_activation_hook( __FILE__, 'wplc_choose_activate' );
|
2816 |
function wplc_choose_activate( $networkwide ) {
|
2817 |
+
wplc_set_agent_accepting( get_current_user_id(), true );
|
2818 |
+
wplc_mrg_update_db( $networkwide ); //Run update db
|
2819 |
}
|
2820 |
}
|
2821 |
|
2824 |
* @return void
|
2825 |
* @since 1.0.00
|
2826 |
*/
|
2827 |
+
if ( ! function_exists( "wplc_choose_deactivate" ) ) {
|
2828 |
+
register_deactivation_hook( __FILE__, 'wplc_choose_deactivate' );
|
2829 |
function wplc_choose_deactivate() {
|
2830 |
+
wplc_set_agent_accepting( get_current_user_id(), false );
|
2831 |
}
|
2832 |
}
|
2833 |
|
2834 |
function wplc_handle_db() {
|
2835 |
+
global $wpdb;
|
2836 |
+
global $wplc_tblname_chats;
|
2837 |
+
global $wplc_tblname_msgs;
|
2838 |
+
global $wplc_tblname_offline_msgs;
|
2839 |
|
2840 |
+
$sql = "
|
2841 |
CREATE TABLE " . $wplc_tblname_chats . " (
|
2842 |
id int(11) NOT NULL AUTO_INCREMENT,
|
2843 |
timestamp datetime NOT NULL,
|
2855 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
2856 |
";
|
2857 |
|
2858 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
2859 |
+
dbDelta( $sql );
|
|
|
|
|
2860 |
|
2861 |
+
|
2862 |
+
$sql = '
|
2863 |
CREATE TABLE ' . $wplc_tblname_msgs . ' (
|
2864 |
id int(11) NOT NULL AUTO_INCREMENT,
|
2865 |
chat_sess_id int(11) NOT NULL,
|
2876 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
2877 |
';
|
2878 |
|
2879 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
2880 |
+
@dbDelta( $sql );
|
2881 |
|
2882 |
+
/* check for previous versions containing 'from' instead of 'msgfrom' */
|
2883 |
+
$results = $wpdb->get_results( "DESC $wplc_tblname_msgs" );
|
2884 |
+
$founded = 0;
|
2885 |
+
foreach ( $results as $row ) {
|
2886 |
+
if ( $row->Field == "from" ) {
|
2887 |
+
$founded ++;
|
2888 |
+
}
|
2889 |
+
}
|
2890 |
|
2891 |
+
if ( $founded > 0 ) {
|
2892 |
+
$wpdb->query( "ALTER TABLE " . $wplc_tblname_msgs . " CHANGE `from` `msgfrom` varchar(150)" );
|
2893 |
+
}
|
2894 |
|
2895 |
|
2896 |
+
$sql2 = "
|
2897 |
CREATE TABLE " . $wplc_tblname_offline_msgs . " (
|
2898 |
id int(11) NOT NULL AUTO_INCREMENT,
|
2899 |
timestamp datetime NOT NULL,
|
2906 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
|
2907 |
";
|
2908 |
|
2909 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
2910 |
+
@dbDelta( $sql2 );
|
2911 |
|
2912 |
+
add_option( "wplc_db_version", WPLC_PLUGIN_VERSION );
|
2913 |
+
update_option( "wplc_db_version", WPLC_PLUGIN_VERSION );
|
2914 |
}
|
2915 |
|
2916 |
function wplc_add_user_stylesheet() {
|
2917 |
+
$show_chat_contents = wplc_display_chat_contents();
|
2918 |
+
$wplc_settings = wplc_get_options();
|
2919 |
+
|
2920 |
+
if ( $show_chat_contents ) {
|
2921 |
+
if ( $wplc_settings['wplc_enable_font_awesome'] ) {
|
2922 |
+
wp_register_style( 'wplc-font-awesome', wplc_plugins_url( '/css/fontawesome-all.min.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
2923 |
+
wp_enqueue_style( 'wplc-font-awesome' );
|
2924 |
+
}
|
2925 |
+
wp_register_style( 'wplc-style', wplc_plugins_url( '/css/wplcstyle.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
2926 |
+
wp_enqueue_style( 'wplc-style' );
|
2927 |
+
|
2928 |
+
if ( ! empty( $wplc_settings['wplc_elem_trigger_id'] ) ) {
|
2929 |
+
$wplc_elem_style_prefix = ".";
|
2930 |
+
if ( ! empty( $wplc_settings['wplc_elem_trigger_type'] ) ) {
|
2931 |
+
$wplc_elem_style_prefix = "#";
|
2932 |
+
}
|
2933 |
+
$wplc_elem_inline_style = $wplc_elem_style_prefix . stripslashes( $wplc_settings['wplc_elem_trigger_id'] ) . ":hover { cursor:pointer; }";
|
2934 |
+
wp_add_inline_style( 'wplc-style', stripslashes( $wplc_elem_inline_style ) );
|
2935 |
+
}
|
2936 |
+
|
2937 |
+
// Serve the icon up over HTTPS if needs be
|
2938 |
+
$icon = wplc_plugins_url( '/images/iconRetina.png', __FILE__ );
|
2939 |
+
$close_icon = wplc_plugins_url( '/images/iconCloseRetina.png', __FILE__ );
|
2940 |
+
|
2941 |
+
$bg = '';
|
2942 |
+
$bg_string = '';
|
2943 |
+
if ( ! empty( $wplc_settings['wplc_settings_bg'] ) ) {
|
2944 |
+
$bg = sanitize_text_field( $wplc_settings['wplc_settings_bg'] );
|
2945 |
+
}
|
2946 |
+
if ( $bg ) {
|
2947 |
+
$bg = wplc_plugins_url( '/images/bg/' . htmlentities( $bg ), __FILE__ );
|
2948 |
+
$bg_string = "#wp-live-chat-4 { background:url('" . htmlentities( $bg ) . "') repeat; background-size: cover; }";
|
2949 |
+
} else {
|
2950 |
+
$bg_string = "#wp-live-chat-4 { background-color: #fff; }";
|
2951 |
+
}
|
2952 |
+
if ( $wplc_settings['wplc_chatbox_height'] != 70 ) {
|
2953 |
+
if ( $wplc_settings['wplc_chatbox_height'] == 0 ) {
|
2954 |
+
$bg_string .= "#wp-live-chat-4 { height: " . $wplc_settings['wplc_chatbox_absolute_height'] . "px !important; }";
|
2955 |
+
} else {
|
2956 |
+
$bg_string .= "#wp-live-chat-4 { height: " . $wplc_settings['wplc_chatbox_height'] . "% !important; }";
|
2957 |
+
}
|
2958 |
+
}
|
2959 |
+
|
2960 |
+
$icon = str_replace( "http://", "//", str_replace( "https://", "//", $icon ) );
|
2961 |
+
$close_icon = str_replace( "http://", "//", str_replace( "https://", "//", $close_icon ) );
|
2962 |
+
|
2963 |
+
/* if (isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] ){ $icon = preg_replace('/^http:\/\//', 'https:\/\/', $icon); }
|
2964 |
+
if (isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] ){ $close_icon = preg_replace('/^http:\/\//', 'https:\/\/', $close_icon); }*/
|
2965 |
+
$icon = apply_filters( "wplc_filter_chaticon", $icon );
|
2966 |
+
$close_icon = apply_filters( "wplc_filter_chaticon_close", $close_icon );
|
2967 |
+
$wplc_elem_inline_style = "#wp-live-chat-header { background:url('$icon') no-repeat; background-size: cover; } #wp-live-chat-header.active { background:url('$close_icon') no-repeat; background-size: cover; } $bg_string";
|
2968 |
+
wp_add_inline_style( 'wplc-style', stripslashes( $wplc_elem_inline_style ) );
|
2969 |
+
|
2970 |
+
$wplc_theme = wplc_get_theme();
|
2971 |
+
switch ( $wplc_theme ) {
|
2972 |
+
case 'theme-default':
|
2973 |
+
wp_register_style( 'wplc-theme-palette-default', wplc_plugins_url( '/css/themes/theme-default.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
2974 |
+
wp_enqueue_style( 'wplc-theme-palette-default' );
|
2975 |
+
break;
|
2976 |
+
case 'theme-1':
|
2977 |
+
case 'theme-2':
|
2978 |
+
case 'theme-3':
|
2979 |
+
case 'theme-4':
|
2980 |
+
case 'theme-5':
|
2981 |
+
$tid = substr( $wplc_theme, - 1, 1 );
|
2982 |
+
wp_register_style( 'wplc-theme-palette-' . $tid, wplc_plugins_url( '/css/themes/theme-' . $tid . '.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
2983 |
+
wp_enqueue_style( 'wplc-theme-palette-' . $tid );
|
2984 |
+
break;
|
2985 |
+
case 'theme-6':
|
2986 |
+
/* custom */
|
2987 |
+
/* handled elsewhere */
|
2988 |
+
break;
|
2989 |
+
}
|
2990 |
+
|
2991 |
+
switch ( $wplc_settings['wplc_newtheme'] ) {
|
2992 |
+
case 'theme-1':
|
2993 |
+
wp_register_style( 'wplc-theme-classic', wplc_plugins_url( '/css/themes/classic.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
2994 |
+
wp_enqueue_style( 'wplc-theme-classic' );
|
2995 |
+
break;
|
2996 |
+
|
2997 |
+
default:
|
2998 |
+
wp_register_style( 'wplc-theme-modern', wplc_plugins_url( '/css/themes/modern.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
2999 |
+
wp_enqueue_style( 'wplc-theme-modern' );
|
3000 |
+
break;
|
3001 |
+
}
|
3002 |
+
|
3003 |
+
switch ( $wplc_settings["wplc_settings_align"] ) {
|
3004 |
+
case 1:
|
3005 |
+
wp_register_style( 'wplc-theme-position', wplc_plugins_url( '/css/themes/position-bottom-left.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3006 |
+
wp_enqueue_style( 'wplc-theme-position' );
|
3007 |
+
break;
|
3008 |
+
case 2:
|
3009 |
+
wp_register_style( 'wplc-theme-position', wplc_plugins_url( '/css/themes/position-bottom-right.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3010 |
+
wp_enqueue_style( 'wplc-theme-position' );
|
3011 |
+
break;
|
3012 |
+
case 3:
|
3013 |
+
wp_register_style( 'wplc-theme-position', wplc_plugins_url( '/css/themes/position-left.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3014 |
+
wp_enqueue_style( 'wplc-theme-position' );
|
3015 |
+
break;
|
3016 |
+
case 4:
|
3017 |
+
wp_register_style( 'wplc-theme-position', wplc_plugins_url( '/css/themes/position-right.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3018 |
+
wp_enqueue_style( 'wplc-theme-position' );
|
3019 |
+
break;
|
3020 |
+
default:
|
3021 |
+
wp_register_style( 'wplc-theme-position', wplc_plugins_url( '/css/themes/position-bottom-right.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3022 |
+
wp_enqueue_style( 'wplc-theme-position' );
|
3023 |
+
break;
|
3024 |
+
}
|
3025 |
+
|
3026 |
+
// Gutenberg template styles - user
|
3027 |
+
wp_register_style( 'wplc-gutenberg-template-styles-user', wplc_plugins_url( '/includes/blocks/wplc-chat-box/wplc_gutenberg_template_styles.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3028 |
+
wp_enqueue_style( 'wplc-gutenberg-template-styles-user' );
|
3029 |
+
}
|
3030 |
|
3031 |
}
|
3032 |
|
3036 |
* @return void
|
3037 |
*/
|
3038 |
function wplc_online_check_script() {
|
3039 |
+
if ( wplc_user_is_agent() ) {
|
3040 |
+
$ajax_nonce = wp_create_nonce( "wplc" );
|
3041 |
+
wp_register_script( 'wplc-heartbeat', wplc_plugins_url( '/js/wplc_heartbeat.js', __FILE__ ), array( 'jquery' ), WPLC_PLUGIN_VERSION, true );
|
3042 |
+
wp_enqueue_script( 'wplc-heartbeat' );
|
3043 |
+
wp_localize_script( 'wplc-heartbeat', 'wplc_transient_nonce', $ajax_nonce );
|
3044 |
+
$wplc_ajax_url = apply_filters( "wplc_filter_ajax_url", admin_url( 'admin-ajax.php' ) );
|
3045 |
+
wp_localize_script( 'wplc-heartbeat', 'wplc_ajaxurl', $wplc_ajax_url );
|
3046 |
+
}
|
3047 |
+
}
|
3048 |
+
|
3049 |
+
function wplc_protocol_agnostic_url($url){
|
3050 |
+
return str_replace( "http://", "//", str_replace( "https://", "//", $url ) );
|
3051 |
+
}
|
3052 |
+
|
3053 |
+
function wplc_plugins_url( $path, $plugin ) {
|
3054 |
+
|
3055 |
+
$url = plugins_url( $path, $plugin );
|
3056 |
+
|
3057 |
+
return wplc_protocol_agnostic_url($url);
|
3058 |
}
|
3059 |
|
3060 |
/**
|
3064 |
add_filter( 'heartbeat_received', 'wplc_heartbeat_receive', 10, 2 );
|
3065 |
add_filter( 'heartbeat_nopriv_received', 'wplc_heartbeat_receive', 10, 2 );
|
3066 |
function wplc_heartbeat_receive( $response, $data ) {
|
3067 |
+
if ( array_key_exists( 'client', $data ) && $data['client'] == 'wplc_heartbeat' ) {
|
3068 |
+
if ( wplc_user_is_agent() ) {
|
3069 |
+
wplc_update_agent_time();
|
3070 |
+
}
|
3071 |
+
}
|
3072 |
+
|
3073 |
+
return $response;
|
3074 |
}
|
3075 |
|
3076 |
/**
|
3078 |
* @return void
|
3079 |
*/
|
3080 |
function wplc_add_admin_stylesheet() {
|
3081 |
+
wp_register_style( 'wplc-ace-styles', wplc_plugins_url( '/css/ace.min.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3082 |
+
wp_enqueue_style( 'wplc-ace-styles' );
|
3083 |
+
|
3084 |
+
wp_register_style( 'wplc-fontawesome-iconpicker', wplc_plugins_url( '/css/fontawesome-iconpicker.min.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3085 |
+
wp_enqueue_style( 'wplc-fontawesome-iconpicker' );
|
3086 |
+
|
3087 |
+
$wplc_settings = wplc_get_options();
|
3088 |
+
if ( $wplc_settings['wplc_use_node_server'] && ( ! isset( $_GET['action'] ) || $_GET['action'] != "history" ) ) {
|
3089 |
+
//Using node, remote styles
|
3090 |
+
//Using node, remote scripts
|
3091 |
+
if ( $wplc_settings['wplc_enable_all_admin_pages'] ) {
|
3092 |
+
/* Run admin JS on all admin pages */
|
3093 |
+
wplc_admin_remote_dashboard_styles();
|
3094 |
+
} else {
|
3095 |
+
/* Only run admin JS on the chat dashboard page */
|
3096 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == 'wplivechat-menu' && ! isset( $_GET['action'] ) ) {
|
3097 |
+
wplc_admin_remote_dashboard_styles();
|
3098 |
+
}
|
3099 |
+
}
|
3100 |
+
|
3101 |
+
wp_register_style( 'wplc-admin-remote-addition-styles', wplc_plugins_url( '/css/remote_dash_styles.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3102 |
+
wp_enqueue_style( 'wplc-admin-remote-addition-styles' );
|
3103 |
+
}
|
3104 |
+
|
3105 |
+
//Special new check to see if we need to add the node history styling
|
3106 |
+
if ( $wplc_settings['wplc_use_node_server'] && isset( $_GET['action'] ) && $_GET['action'] == 'history' ) {
|
3107 |
+
wp_register_style( 'wplc-admin-node-history-styles', wplc_plugins_url( '/css/node_history_styles.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3108 |
+
wp_enqueue_style( 'wplc-admin-node-history-styles' );
|
3109 |
+
}
|
3110 |
+
|
3111 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == 'wplivechat-menu' && isset( $_GET['action'] ) && ( $_GET['action'] == "ac" || $_GET['action'] == "history" ) ) {
|
3112 |
+
wp_register_style( 'wplc-admin-chat-box-style', wplc_plugins_url( '/css/admin-chat-box-style.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3113 |
+
wp_enqueue_style( 'wplc-admin-chat-box-style' );
|
3114 |
+
}
|
3115 |
+
|
3116 |
+
wp_register_style( 'wplc-font-awesome', wplc_plugins_url( '/css/fontawesome-all.min.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3117 |
+
wp_enqueue_style( 'wplc-font-awesome' );
|
3118 |
+
|
3119 |
+
if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'wplivechat-menu' || $_GET['page'] == 'wplivechat-menu-settings' || $_GET['page'] == 'wplivechat-menu-offline-messages' || $_GET['page'] == 'wplivechat-menu-history' || $_GET['page'] == 'wplivechat-menu-missed-chats' || $_GET['page'] == 'wplivechat-menu-dashboard' ) ) {
|
3120 |
+
wp_register_style( 'wplc-jquery-ui', wplc_plugins_url( '/js/vendor/jquery-ui/jquery-ui.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3121 |
+
wp_enqueue_style( 'wplc-jquery-ui' );
|
3122 |
+
|
3123 |
+
wp_enqueue_script( 'jquery-ui-core' );
|
3124 |
+
wp_enqueue_script( 'jquery-effects-core' );
|
3125 |
+
|
3126 |
+
// Gutenberg template styles - admin
|
3127 |
+
wp_register_style( 'wplc-gutenberg-template-styles', wplc_plugins_url( '/includes/blocks/wplc-chat-box/wplc_gutenberg_template_styles.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3128 |
+
wp_enqueue_style( 'wplc-gutenberg-template-styles' );
|
3129 |
+
|
3130 |
+
wp_register_style( 'wplc-admin-styles', wplc_plugins_url( '/css/admin_styles.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3131 |
+
wp_enqueue_style( 'wplc-admin-styles' );
|
3132 |
+
|
3133 |
+
if ( $wplc_settings['wplc_use_node_server'] ) {
|
3134 |
+
wp_register_style( 'wplc-admin-chat-style', wplc_plugins_url( '/css/admin-chat-style.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3135 |
+
wp_enqueue_style( 'wplc-admin-chat-style' );
|
3136 |
+
} else {
|
3137 |
+
wp_register_style( 'wplc-chat-style', wplc_plugins_url( '/css/chat-style.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3138 |
+
wp_enqueue_style( 'wplc-chat-style' );
|
3139 |
+
}
|
3140 |
+
}
|
3141 |
+
|
3142 |
+
// This loads the chat styling on all admin pages as we are using the popout dashboard
|
3143 |
+
if ( $wplc_settings['wplc_use_node_server'] && $wplc_settings['wplc_enable_all_admin_pages'] ) {
|
3144 |
+
wp_register_style( 'wplc-admin-chat-style', wplc_plugins_url( '/css/admin-chat-style.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3145 |
+
wp_enqueue_style( 'wplc-admin-chat-style' );
|
3146 |
+
}
|
3147 |
+
|
3148 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == "wplivechat-menu-support-page" ) {
|
3149 |
+
wp_register_style( 'fontawesome', wplc_plugins_url( '/css/fontawesome-all.min.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3150 |
+
wp_enqueue_style( 'fontawesome' );
|
3151 |
+
wp_register_style( 'wplc-support-page-css', wplc_plugins_url( '/css/support-css.css', __FILE__ ), array(), WPLC_PLUGIN_VERSION );
|
3152 |
+
wp_enqueue_style( 'wplc-support-page-css' );
|
3153 |
+
}
|
3154 |
+
|
3155 |
+
if ( isset( $_GET['immersive_mode'] ) ) {
|
3156 |
+
wp_add_inline_style( 'wplc-admin-style', "#wpcontent { margin-left: 0px !important;} #wpadminbar, #wpfooter, #adminmenumain {display: none !important;}" );
|
3157 |
+
}
|
3158 |
+
}
|
3159 |
+
|
3160 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == 'wplivechat-menu-settings' ) {
|
3161 |
+
add_action( 'admin_print_scripts', 'wplc_admin_scripts' );
|
3162 |
}
|
3163 |
|
3164 |
/**
|
3167 |
*/
|
3168 |
function wplc_admin_scripts() {
|
3169 |
|
3170 |
+
$gutenberg_default_html = '<!-- Default HTML -->
|
3171 |
<div class="wplc_block">
|
3172 |
<span class="wplc_block_logo">{wplc_logo}</span>
|
3173 |
<span class="wplc_block_text">{wplc_text}</span>
|
3174 |
<span class="wplc_block_icon">{wplc_icon}</span>
|
3175 |
</div>';
|
3176 |
+
|
3177 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == "wplivechat-menu-settings" ) {
|
3178 |
+
wp_enqueue_script( 'jquery' );
|
3179 |
+
wp_enqueue_script( 'jquery-ui-core' );
|
3180 |
+
wp_enqueue_script( 'jquery-ui-tooltip' );
|
3181 |
+
wp_enqueue_script( 'jquery-ui-tabs' );
|
3182 |
+
wp_register_script( 'my-wplc-tabs', wplc_plugins_url( '/js/wplc_tabs.js', __FILE__ ), array( 'jquery-ui-core' ), WPLC_PLUGIN_VERSION, true );
|
3183 |
+
wp_enqueue_script( 'my-wplc-tabs' );
|
3184 |
+
wp_enqueue_media();
|
3185 |
+
wp_register_script( 'wplc-fontawesome-iconpicker', wplc_plugins_url( '/js/fontawesome-iconpicker.js', __FILE__ ), array( 'jquery' ), WPLC_PLUGIN_VERSION, true );
|
3186 |
+
wp_enqueue_script( 'wplc-fontawesome-iconpicker' );
|
3187 |
+
wp_register_script( 'wplc-gutenberg', wplc_plugins_url( '/js/wplc_gutenberg.js', __FILE__ ), array( 'jquery' ), WPLC_PLUGIN_VERSION, true );
|
3188 |
+
wp_enqueue_script( 'wplc-gutenberg' );
|
3189 |
+
wp_localize_script( 'wplc-gutenberg', 'default_html', $gutenberg_default_html );
|
3190 |
+
}
|
3191 |
}
|
3192 |
|
3193 |
/**
|
3195 |
* @return void
|
3196 |
*/
|
3197 |
function wplc_admin_settings_layout() {
|
3198 |
+
wplc_settings_page();
|
3199 |
}
|
3200 |
|
3201 |
/**
|
3203 |
* @return void
|
3204 |
*/
|
3205 |
function wplc_admin_dashboard_layout() {
|
3206 |
+
include 'includes/dashboard_page.php';
|
3207 |
}
|
3208 |
|
3209 |
+
add_action( "wplc_hook_history_draw_area", "wplc_hook_control_history_draw_area", 10, 1 );
|
3210 |
/**
|
3211 |
* Display normal history page
|
3212 |
+
*
|
3213 |
+
* @param int $cid Chat ID
|
3214 |
+
*
|
3215 |
* @return void
|
3216 |
* @since 6.1.00
|
3217 |
*/
|
3218 |
+
function wplc_hook_control_history_draw_area( $cid ) {
|
3219 |
+
wplc_draw_chat_area( $cid );
|
3220 |
}
|
3221 |
|
3222 |
/**
|
3223 |
* What to display for the chat history
|
3224 |
+
*
|
3225 |
+
* @param int $cid Chat ID
|
3226 |
+
*
|
3227 |
* @return void
|
3228 |
* @since 6.1.00
|
3229 |
*/
|
3230 |
+
function wplc_admin_view_chat_history( $cid ) {
|
3231 |
+
do_action( "wplc_hook_history_draw_area", $cid );
|
3232 |
}
|
3233 |
|
3234 |
|
3235 |
+
add_action( 'wplc_hook_admin_menu_layout_display', 'wplc_hook_control_history_get_control', 1, 3 );
|
3236 |
/**
|
3237 |
* Control history GET calls
|
3238 |
+
*
|
3239 |
+
* @param string $action The GET action
|
3240 |
+
* @param int $cid The chat id
|
3241 |
+
* @param int $aid AID
|
3242 |
+
*
|
3243 |
* @return void
|
3244 |
* @since 6.1.00
|
3245 |
*/
|
3246 |
+
function wplc_hook_control_history_get_control( $action, $cid, $aid ) {
|
3247 |
+
|
3248 |
+
if ( $action == 'history' ) {
|
3249 |
+
if ( ! isset( $_GET['wplc_history_nonce'] ) || ! wp_verify_nonce( $_GET['wplc_history_nonce'], 'wplc_history_nonce' ) ) {
|
3250 |
+
wp_die( __( "You do not have permission do perform this action", 'wp-live-chat-support' ) );
|
3251 |
+
}
|
3252 |
+
wplc_admin_view_chat_history( sanitize_text_field( $cid ) );
|
3253 |
+
} else if ( $action == 'download_history' ) {
|
3254 |
|
3255 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3256 |
|
3257 |
|
3258 |
}
|
3259 |
|
3260 |
|
3261 |
+
add_action( "wplc_hook_chat_history", "wplc_hook_control_chat_history" );
|
3262 |
/**
|
3263 |
* Renders the chat history content
|
3264 |
* @return string
|
3265 |
*/
|
3266 |
function wplc_hook_control_chat_history() {
|
3267 |
+
if ( is_admin() ) {
|
3268 |
+
global $wpdb;
|
3269 |
+
global $wplc_tblname_chats;
|
3270 |
+
global $wplc_tblname_msgs;
|
3271 |
+
if ( isset( $_GET['wplc_action'] ) && $_GET['wplc_action'] == 'remove_cid' ) {
|
3272 |
+
if ( isset( $_GET['cid'] ) ) {
|
3273 |
+
if ( isset( $_GET['wplc_confirm'] ) ) {
|
3274 |
+
//Confirmed - delete
|
3275 |
+
if ( ! isset( $_GET['wplc_history_nonce'] ) || ! wp_verify_nonce( $_GET['wplc_history_nonce'], 'wplc_history_nonce' ) ) {
|
3276 |
+
wp_die( __( "You do not have permission do perform this action", 'wp-live-chat-support' ) );
|
3277 |
+
}
|
3278 |
+
$wplc_was_error = false;
|
3279 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wplc_tblname_chats WHERE `id` = %d", intval( $_GET['cid'] ) ) );
|
3280 |
+
$wplc_was_error = $wpdb->last_error || $wplc_was_error;
|
3281 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM $wplc_tblname_msgs WHERE `chat_sess_id` = %d", intval( $_GET['cid'] ) ) );
|
3282 |
+
$wplc_was_error = $wpdb->last_error || $wplc_was_error;
|
3283 |
+
|
3284 |
+
if ( $wplc_was_error ) {
|
3285 |
+
echo "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>" . __( "Error: Could not delete chat", 'wp-live-chat-support' ) . "<br></div>";
|
3286 |
+
} else {
|
3287 |
+
echo "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;border-color:#67d552;'>" . __( "Chat Deleted", 'wp-live-chat-support' ) . "<br></div>";
|
3288 |
+
}
|
3289 |
+
} else {
|
3290 |
+
//Prompt
|
3291 |
+
$hist_nonce = wp_create_nonce( 'wplc_history_nonce' );
|
3292 |
+
echo "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>" . __( "Are you sure you would like to delete this chat?", 'wp-live-chat-support' );
|
3293 |
+
echo "<br><a class='button' href='?page=wplivechat-menu-history&wplc_action=remove_cid&cid=" . esc_attr( $_GET['cid'] );
|
3294 |
+
echo "&wplc_confirm=1&wplc_history_nonce=" . $hist_nonce . "'>" . __( "Yes", 'wp-live-chat-support' ) . "</a> <a class='button' href='?page=wplivechat-menu-history'>";
|
3295 |
+
echo __( "No", 'wp-live-chat-support' ) . "</a></div>";
|
3296 |
+
}
|
3297 |
+
}
|
3298 |
+
}
|
3299 |
+
|
3300 |
+
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
|
3301 |
+
$limit = 20; // number of rows in page
|
3302 |
+
$offset = ( $pagenum - 1 ) * $limit;
|
3303 |
+
$total = $wpdb->get_var( "SELECT COUNT(`id`) FROM $wplc_tblname_chats" );
|
3304 |
+
$num_of_pages = ceil( $total / $limit );
|
3305 |
+
|
3306 |
+
$results = $wpdb->get_results( $wpdb->prepare( "
|
3307 |
SELECT * FROM $wplc_tblname_chats
|
3308 |
WHERE `name` NOT LIKE 'agent-to-agent chat'
|
3309 |
AND (`status` = 1 OR `status` = 2 OR `status` = 3 OR `status` = 6 OR `status` = 8)
|
3310 |
ORDER BY `timestamp` DESC
|
3311 |
LIMIT %d OFFSET %d
|
3312 |
+
", $limit, $offset )
|
3313 |
+
);
|
3314 |
+
echo "<form method=\"post\" >
|
3315 |
+
<input type=\"submit\" value=\"" . __( 'Delete History', 'wp-live-chat-support' ) . "\" class='button' id=\"wplc-delete-chat-history\" name=\"wplc-delete-chat-history\" /><br /><br />
|
3316 |
</form>
|
3317 |
|
3318 |
<table class=\"wp-list-table wplc_list_table widefat fixed \" cellspacing=\"0\">
|
3319 |
<thead>
|
3320 |
<tr>
|
3321 |
+
<th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><span>" . __( "Date", 'wp-live-chat-support' ) . "</span></th>
|
3322 |
+
<th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><span>" . __( "Name", 'wp-live-chat-support' ) . "</span></th>
|
3323 |
+
<th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\">" . __( "Email", 'wp-live-chat-support' ) . "</th>
|
3324 |
+
<th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\">" . __( "URL", 'wp-live-chat-support' ) . "</th>
|
3325 |
+
<th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\">" . __( "Status", 'wp-live-chat-support' ) . "</th>
|
3326 |
+
<th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><span>" . __( "Action", 'wp-live-chat-support' ) . "</span></th>
|
3327 |
</tr>
|
3328 |
</thead>
|
3329 |
<tbody id=\"the-list\" class='list:wp_list_text_link'>";
|
3330 |
+
if ( ! $results ) {
|
3331 |
+
echo "<tr><td></td><td>" . __( "No chats available at the moment", 'wp-live-chat-support' ) . "</td></tr>";
|
3332 |
+
} else {
|
3333 |
+
foreach ( $results as $result ) {
|
3334 |
+
unset( $trstyle );
|
3335 |
+
unset( $actions );
|
3336 |
+
$tcid = sanitize_text_field( $result->id );
|
3337 |
+
$hist_nonce = wp_create_nonce( 'wplc_history_nonce' );
|
3338 |
+
$url = admin_url( 'admin.php?page=wplivechat-menu&action=history&cid=' . $tcid . "&wplc_history_nonce=" . $hist_nonce );
|
3339 |
+
$url2 = admin_url( 'admin.php?page=wplivechat-menu&action=download_history&type=csv&cid=' . $tcid . "&wplc_history_nonce=" . $hist_nonce );
|
3340 |
+
$url3 = "?page=wplivechat-menu-history&wplc_action=remove_cid&cid=" . $tcid;
|
3341 |
+
$actions = "<a href='$url' class='button' title='" . __( 'View Chat History', 'wp-live-chat-support' ) . "' target='_BLANK' id=''>";
|
3342 |
+
$actions .= "<i class='fa fa-eye'></i></a> <a href='$url2' class='button' title='" . __( 'Download Chat History', 'wp-live-chat-support' ) . "' target='_BLANK' id=''>";
|
3343 |
+
$actions .= "<i class='fa fa-download'></i></a> <a href='$url3' class='button'><i class='far fa-trash-alt'></i></a>";
|
3344 |
+
$trstyle = "style='height:30px;'";
|
3345 |
+
|
3346 |
+
echo "<tr id=\"record_" . $tcid . "\" $trstyle>";
|
3347 |
+
echo "<td class='chat_id column-chat_d'>" . date( "Y-m-d H:i:s", current_time( strtotime( $result->timestamp ) ) ) . "</td>";
|
3348 |
+
echo "<td class='chat_name column_chat_name' id='chat_name_" . $tcid . "'><img src=\"//www.gravatar.com/avatar/" . md5( $result->email ) . "?s=40&d=mm\" align=\"absmiddle\"/> " . sanitize_text_field( $result->name ) . "</td>";
|
3349 |
+
echo "<td class='chat_email column_chat_email' id='chat_email_" . $tcid . "'><a href='mailto:" . esc_attr( $result->email ) . "' title='Email " . esc_attr( $result->email ) . "'>" . sanitize_text_field( $result->email ) . "</a></td>";
|
3350 |
+
echo "<td class='chat_name column_chat_url' id='chat_url_" . $tcid . "'>" . esc_url( $result->url ) . "</td>";
|
3351 |
+
echo "<td class='chat_status column_chat_status' id='chat_status_" . $tcid . "'><strong>" . wplc_return_status( $result->status ) . "</strong></td>";
|
3352 |
+
echo "<td class='chat_action column-chat_action' id='chat_action_" . $tcid . "'>$actions</td>";
|
3353 |
+
echo "</tr>";
|
3354 |
+
}
|
3355 |
+
}
|
3356 |
+
echo "</table>";
|
3357 |
+
|
3358 |
+
$page_links = paginate_links( array(
|
3359 |
+
'base' => add_query_arg( 'pagenum', '%#%' ),
|
3360 |
+
'format' => '',
|
3361 |
+
'prev_text' => '«',
|
3362 |
+
'next_text' => '»',
|
3363 |
+
'total' => $num_of_pages,
|
3364 |
+
'current' => $pagenum
|
3365 |
+
) );
|
3366 |
+
if ( $page_links ) {
|
3367 |
+
echo '<div class="tablenav"><div class="tablenav-pages" style="margin: 1em 0;float:none;text-align:center;">' . $page_links . '</div></div>';
|
3368 |
+
}
|
3369 |
+
}
|
3370 |
}
|
3371 |
|
3372 |
/**
|
3374 |
* @return string
|
3375 |
*/
|
3376 |
function wplc_admin_history_layout() {
|
3377 |
+
wplc_stats( "history" );
|
3378 |
+
echo "<div class=\"wrap wplc_wrap\"><h2>" . __( "History", 'wp-live-chat-support' ) . "</h2>";
|
3379 |
+
do_action( "wplc_before_history_table_hook" );
|
3380 |
+
do_action( "wplc_hook_chat_history" );
|
3381 |
}
|
3382 |
|
3383 |
|
3384 |
+
add_action( "wplc_hook_chat_missed", "wplc_hook_control_missed_chats", 10 );
|
3385 |
/**
|
3386 |
* Loads missed chats contents
|
3387 |
* @return string
|
3388 |
*/
|
3389 |
function wplc_hook_control_missed_chats() {
|
3390 |
+
if ( function_exists( 'wplc_admin_display_missed_chats' ) ) {
|
3391 |
+
wplc_admin_display_missed_chats();
|
3392 |
+
}
|
3393 |
}
|
3394 |
|
3395 |
/**
|
3397 |
* @return string
|
3398 |
*/
|
3399 |
function wplc_admin_missed_chats() {
|
3400 |
+
wplc_stats( "missed" );
|
3401 |
+
echo "<div class=\"wrap wplc_wrap\"><h2>" . __( "Missed Chats", 'wp-live-chat-support' ) . "</h2>";
|
3402 |
+
do_action( "wplc_hook_chat_missed" );
|
3403 |
}
|
3404 |
|
3405 |
+
add_action( "wplc_hook_offline_messages_display", "wplc_hook_control_offline_messages_display", 10 );
|
3406 |
/**
|
3407 |
* Loads the offline messages page contents
|
3408 |
* @return string
|
3409 |
*/
|
3410 |
function wplc_hook_control_offline_messages_display() {
|
3411 |
+
wplc_admin_display_offline_messages();
|
3412 |
}
|
3413 |
|
3414 |
/**
|
3416 |
* @return void
|
3417 |
*/
|
3418 |
function wplc_admin_offline_messages() {
|
3419 |
+
wplc_stats( "offline_messages" );
|
3420 |
+
echo "<div class=\"wrap wplc_wrap\"><h2>" . __( "Offline Messages", 'wp-live-chat-support' ) . "</h2>";
|
3421 |
+
do_action( "wplc_hook_offline_messages_display" );
|
3422 |
}
|
3423 |
|
3424 |
/**
|
3427 |
*/
|
3428 |
function wplc_admin_display_offline_messages() {
|
3429 |
|
3430 |
+
global $wpdb;
|
3431 |
+
global $wplc_tblname_offline_msgs;
|
3432 |
|
3433 |
+
echo "
|
3434 |
<table class=\"wp-list-table wplc_list_table widefat \" cellspacing=\"0\">
|
3435 |
<thead>
|
3436 |
<tr>
|
3437 |
+
<th class='manage-column column-id' style='width: 15%'><span>" . __( "Date", 'wp-live-chat-support' ) . "</span></th>
|
3438 |
+
<th scope='col' id='wplc_name_colum' class='manage-column column-id' style='width: 10%'><span>" . __( "Name", 'wp-live-chat-support' ) . "</span></th>
|
3439 |
+
<th scope='col' id='wplc_email_colum' class='manage-column column-id' style='width: 15%'>" . __( "Email", 'wp-live-chat-support' ) . "</th>
|
3440 |
+
<th scope='col' id='wplc_message_colum' class='manage-column column-id' style='width: 40%'>" . __( "Message", 'wp-live-chat-support' ) . "</th>
|
3441 |
+
<th scope='col' id='wplc_message_colum' class='manage-column column-id' style='width: 10%'>" . __( "Actions", 'wp-live-chat-support' ) . "</th>
|
3442 |
</tr>
|
3443 |
</thead>
|
3444 |
<tbody id=\"the-list\" class='list:wp_list_text_link'>";
|
3445 |
|
3446 |
+
$pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
|
3447 |
+
$limit = 20; // number of rows in page
|
3448 |
+
$offset = ( $pagenum - 1 ) * $limit;
|
3449 |
+
$total = $wpdb->get_var( "SELECT COUNT(`id`) FROM $wplc_tblname_offline_msgs" );
|
3450 |
$num_of_pages = ceil( $total / $limit );
|
3451 |
|
3452 |
+
$results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wplc_tblname_offline_msgs ORDER BY `timestamp` DESC LIMIT %d OFFSET %d", $limit, $offset ) );
|
3453 |
+
|
3454 |
+
if ( ! $results ) {
|
3455 |
+
echo "<tr><td></td><td>" . __( "You have not received any offline messages.", 'wp-live-chat-support' ) . "</td></tr>";
|
3456 |
+
} else {
|
3457 |
+
foreach ( $results as $result ) {
|
3458 |
+
echo "<tr id=\"record_" . intval( $result->id ) . "\">";
|
3459 |
+
echo "<td class='chat_id column-chat_d'>" . sanitize_text_field( $result->timestamp ) . "</td>";
|
3460 |
+
echo "<td class='chat_name column_chat_name' id='chat_name_" . intval( $result->id ) . "'><img src=\"//www.gravatar.com/avatar/" . md5( $result->email ) . "?s=30&d=mm\" align=\"absmiddle\"/> " . sanitize_text_field( $result->name ) . "</td>";
|
3461 |
+
echo "<td class='chat_email column_chat_email' id='chat_email_" . intval( $result->id ) . "'><a href='mailto:" . sanitize_email( $result->email ) . "' title='Email " . ".$result->email." . "'>" . sanitize_email( $result->email ) . "</a></td>";
|
3462 |
+
echo "<td class='chat_name column_chat_url' id='chat_url_" . intval( $result->id ) . "'>" . nl2br( sanitize_text_field( $result->message ) ) . "</td>";
|
3463 |
+
echo "<td class='chat_name column_chat_delete'><button class='button wplc_delete_message' title='" . __( 'Delete Message', 'wp-live-chat-support' ) . "' class='wplc_delete_message' mid='" . intval( $result->id ) . "'><i class='fa fa-times'></i></button></td>";
|
3464 |
+
echo "</tr>";
|
3465 |
+
}
|
3466 |
+
}
|
3467 |
+
|
3468 |
+
echo "
|
3469 |
</tbody>
|
3470 |
</table>";
|
3471 |
|
3472 |
$page_links = paginate_links( array(
|
3473 |
+
'base' => add_query_arg( 'pagenum', '%#%' ),
|
3474 |
+
'format' => '',
|
3475 |
'prev_text' => '«',
|
3476 |
'next_text' => '»',
|
3477 |
+
'total' => $num_of_pages,
|
3478 |
+
'current' => $pagenum
|
3479 |
) );
|
3480 |
|
3481 |
if ( $page_links ) {
|
3488 |
* @return string
|
3489 |
*/
|
3490 |
function wplc_settings_page() {
|
3491 |
+
include 'includes/settings_page.php';
|
3492 |
}
|
3493 |
|
3494 |
/**
|
3495 |
* Updates chat statistics
|
3496 |
+
*
|
3497 |
+
* @param string $sec Specify which array key of the stats you'd like access to
|
3498 |
+
*
|
3499 |
* @return void
|
3500 |
*/
|
3501 |
+
function wplc_stats( $sec ) {
|
3502 |
+
$wplc_stats = get_option( "wplc_stats" );
|
3503 |
+
if ( $wplc_stats ) {
|
3504 |
+
if ( isset( $wplc_stats[ $sec ]["views"] ) ) {
|
3505 |
+
$wplc_stats[ $sec ]["views"] = $wplc_stats[ $sec ]["views"] + 1;
|
3506 |
+
$wplc_stats[ $sec ]["last_accessed"] = date( "Y-m-d H:i:s" );
|
3507 |
+
} else {
|
3508 |
+
$wplc_stats[ $sec ]["views"] = 1;
|
3509 |
+
$wplc_stats[ $sec ]["last_accessed"] = date( "Y-m-d H:i:s" );
|
3510 |
+
$wplc_stats[ $sec ]["first_accessed"] = date( "Y-m-d H:i:s" );
|
3511 |
+
}
|
3512 |
|
3513 |
|
3514 |
+
} else {
|
3515 |
|
3516 |
+
$wplc_stats[ $sec ]["views"] = 1;
|
3517 |
+
$wplc_stats[ $sec ]["last_accessed"] = date( "Y-m-d H:i:s" );
|
3518 |
+
$wplc_stats[ $sec ]["first_accessed"] = date( "Y-m-d H:i:s" );
|
3519 |
|
3520 |
|
3521 |
+
}
|
3522 |
+
update_option( "wplc_stats", $wplc_stats );
|
3523 |
|
3524 |
}
|
3525 |
|
3526 |
|
3527 |
+
add_action( "wplc_hook_head", "wplc_hook_control_head" );
|
3528 |
/**
|
3529 |
* Deletes the chat history on submission of POST
|
3530 |
* @return bool
|
3531 |
*/
|
3532 |
function wplc_hook_control_head() {
|
3533 |
+
if ( isset( $_POST['wplc-delete-chat-history'] ) ) {
|
3534 |
+
wplc_del_history();
|
3535 |
+
}
|
3536 |
}
|
3537 |
|
3538 |
/**
|
3539 |
* Deletes all chat history
|
3540 |
* @return bool
|
3541 |
*/
|
3542 |
+
function wplc_del_history() {
|
3543 |
+
global $wpdb;
|
3544 |
+
global $wplc_tblname_chats;
|
3545 |
+
global $wplc_tblname_msgs;
|
3546 |
+
$wpdb->query( "TRUNCATE TABLE $wplc_tblname_chats" );
|
3547 |
+
$wpdb->query( "TRUNCATE TABLE $wplc_tblname_msgs" );
|
3548 |
}
|
3549 |
|
3550 |
+
add_filter( "wplc_filter_chat_header_extra_attr", "wplc_filter_control_chat_header_extra_attr", 10, 1 );
|
3551 |
/**
|
3552 |
* Controls if the chat window should popup or not
|
3553 |
+
*
|
3554 |
+
* @param array $wplc_extra_attr Extra chat data passed
|
3555 |
+
*
|
3556 |
* @return string
|
3557 |
*/
|
3558 |
+
function wplc_filter_control_chat_header_extra_attr( $wplc_extra_attr ) {
|
3559 |
+
$wplc_settings = wplc_get_options();
|
3560 |
+
$do_popup = false;
|
3561 |
+
if ( $wplc_settings['wplc_auto_pop_up'] > 0 ) {
|
3562 |
+
if ( $wplc_settings['wplc_auto_pop_up_online'] ) {
|
3563 |
+
$do_popup = wplc_agent_is_available();
|
3564 |
+
} else {
|
3565 |
+
$do_popup = true;
|
3566 |
+
}
|
3567 |
+
}
|
3568 |
+
if ( $do_popup && ! $wplc_settings['wplc_auto_pop_up_mobile'] ) {
|
3569 |
+
if ( ! class_exists( 'Mobile_Detect' ) ) {
|
3570 |
+
require_once( plugin_dir_path( __FILE__ ) . 'includes/Mobile_Detect.php' );
|
3571 |
+
}
|
3572 |
+
$wplc_detect_device = new Mobile_Detect;
|
3573 |
+
$do_popup = ! $wplc_detect_device->isMobile();
|
3574 |
+
}
|
3575 |
+
if ( $do_popup ) {
|
3576 |
+
$wplc_extra_attr .= " wplc-auto-pop-up=\"" . intval( $wplc_settings['wplc_auto_pop_up'] ) . "\"";
|
3577 |
+
}
|
3578 |
+
|
3579 |
+
return $wplc_extra_attr;
|
3580 |
}
|
3581 |
|
3582 |
/**
|
3584 |
* @return string
|
3585 |
*/
|
3586 |
function wplc_head() {
|
3587 |
+
global $wplc_default_settings_array;
|
3588 |
+
|
3589 |
+
do_action( "wplc_hook_head" );
|
3590 |
+
if ( isset( $_POST['wplc_save_settings'] ) ) {
|
3591 |
+
if ( ! isset( $_POST['wplc_save_settings_nonce'] ) || ! wp_verify_nonce( $_POST['wplc_save_settings_nonce'], 'wplc_save_settings' ) ) {
|
3592 |
+
?>
|
3593 |
+
<div class='notice notice-warning wplc_settings_save_notice'>
|
3594 |
+
<?php _e( "You do not have permission to save settings.", 'wp-live-chat-support' ); ?>
|
3595 |
+
</div>
|
3596 |
+
<?php
|
3597 |
+
return false;
|
3598 |
+
}
|
3599 |
+
|
3600 |
+
do_action( "wplc_hook_admin_settings_save" );
|
3601 |
+
$wplc_data = $wplc_default_settings_array;
|
3602 |
+
$wplc_settings = wplc_get_options(); // current settings
|
3603 |
+
|
3604 |
+
$wplc_data['wplc_allow_agents_set_status'] = wplc_force_bool( $_POST, 'wplc_allow_agents_set_status' );
|
3605 |
+
|
3606 |
+
$wplc_data['wplc_include_on_pages'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_include_on_pages' ) ) );
|
3607 |
+
if ( ! empty( $wplc_data['wplc_include_on_pages'] ) ) {
|
3608 |
+
$wplc_data['wplc_include_on_pages'] = implode( ',', explode( ',', $wplc_data['wplc_include_on_pages'] ) );
|
3609 |
+
}
|
3610 |
+
$wplc_data['wplc_exclude_from_pages'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_exclude_from_pages' ) ) );
|
3611 |
+
if ( ! empty( $wplc_data['wplc_exclude_from_pages'] ) ) {
|
3612 |
+
$wplc_data['wplc_exclude_from_pages'] = implode( ',', explode( ',', $wplc_data['wplc_exclude_from_pages'] ) );
|
3613 |
+
}
|
3614 |
+
if ( isset( $_POST['wplc_exclude_post_types'] ) && ! empty( $_POST['wplc_exclude_post_types'] ) ) {
|
3615 |
+
$wplc_data['wplc_exclude_post_types'] = array();
|
3616 |
+
foreach ( $_POST['wplc_exclude_post_types'] as $post_type ) {
|
3617 |
+
$wplc_data['wplc_exclude_post_types'][] = sanitize_text_field( $post_type );
|
3618 |
+
}
|
3619 |
+
}
|
3620 |
+
$wplc_data['wplc_exclude_home'] = wplc_force_bool( $_POST, 'wplc_exclude_home' );
|
3621 |
+
$wplc_data['wplc_exclude_archive'] = wplc_force_bool( $_POST, 'wplc_exclude_archive' );
|
3622 |
+
|
3623 |
+
$wplc_data['wplc_enable_transcripts'] = wplc_force_bool( $_POST, 'wplc_enable_transcripts' );
|
3624 |
+
$wplc_data['wplc_send_transcripts_to'] = trim( stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_send_transcripts_to' ) ) ) );
|
3625 |
+
if ( empty( $wplc_data['wplc_send_transcripts_to'] ) ) {
|
3626 |
+
$wplc_data['wplc_send_transcripts_to'] = $wplc_default_settings_array['wplc_send_transcripts_to'];
|
3627 |
+
}
|
3628 |
+
$wplc_data['wplc_send_transcripts_when_chat_ends'] = wplc_force_bool( $_POST, 'wplc_send_transcripts_when_chat_ends' );
|
3629 |
+
|
3630 |
+
$wplc_data['wplc_et_email_header'] = trim( stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_et_email_header' ) ) ) );
|
3631 |
+
if ( empty( $wplc_data['wplc_et_email_header'] ) ) {
|
3632 |
+
$wplc_data['wplc_et_email_header'] = $wplc_default_settings_array['wplc_et_email_header'];
|
3633 |
+
}
|
3634 |
+
|
3635 |
+
$wplc_data['wplc_et_email_footer'] = trim( stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_et_email_footer' ) ) ) );
|
3636 |
+
if ( empty( $wplc_data['wplc_et_email_footer'] ) ) {
|
3637 |
+
$wplc_data['wplc_et_email_footer'] = $wplc_default_settings_array['wplc_et_email_footer'];
|
3638 |
+
}
|
3639 |
+
|
3640 |
+
$wplc_data['wplc_et_email_body'] = trim( wp_filter_post_kses( wplc_force_string( $_POST, 'wplc_et_email_body' ) ) );
|
3641 |
+
if ( empty( $wplc_data['wplc_et_email_body'] ) ) {
|
3642 |
+
$wplc_data['wplc_et_email_body'] = $wplc_default_settings_array['wplc_et_email_body'];
|
3643 |
+
}
|
3644 |
+
|
3645 |
+
$wplc_data['wplc_quick_response_orderby'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_quick_response_orderby', $wplc_settings ) ) );
|
3646 |
+
$wplc_data['wplc_quick_response_order'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_quick_response_order', $wplc_settings ) ) );
|
3647 |
+
$wplc_data['wplc_enable_voice_notes_on_admin'] = wplc_force_bool( $_POST, 'wplc_enable_voice_notes_on_admin' );
|
3648 |
+
$wplc_data['wplc_enable_voice_notes_on_visitor'] = wplc_force_bool( $_POST, 'wplc_enable_voice_notes_on_visitor' );
|
3649 |
+
|
3650 |
+
$wplc_data['wplc_settings_align'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_settings_align', $wplc_settings ) ) );
|
3651 |
+
$wplc_data['wplc_settings_bg'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_settings_bg', $wplc_settings ) ) );
|
3652 |
+
$wplc_data['wplc_environment'] = wplc_force_int( $_POST, 'wplc_environment', $wplc_settings, 0, 4 );
|
3653 |
+
$wplc_data['wplc_settings_fill'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_settings_fill', $wplc_settings ) ) );
|
3654 |
+
$wplc_data['wplc_settings_font'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_settings_font', $wplc_settings ) ) );
|
3655 |
+
$wplc_data['wplc_settings_color1'] = str_replace( '#', '', stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_settings_color1', $wplc_settings ) ) ) );
|
3656 |
+
$wplc_data['wplc_settings_color2'] = str_replace( '#', '', stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_settings_color2', $wplc_settings ) ) ) );
|
3657 |
+
$wplc_data['wplc_settings_color3'] = str_replace( '#', '', stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_settings_color3', $wplc_settings ) ) ) );
|
3658 |
+
$wplc_data['wplc_settings_color4'] = str_replace( '#', '', stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_settings_color4', $wplc_settings ) ) ) );
|
3659 |
+
$wplc_data['wplc_settings_enabled'] = wplc_force_int( $_POST, 'wplc_settings_enabled', $wplc_settings, 1, 0, 1 );
|
3660 |
+
$wplc_data['wplc_powered_by_link'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_powered_by_link', $wplc_settings ) ) );
|
3661 |
+
$wplc_data['wplc_auto_pop_up'] = wplc_force_int( $_POST, 'wplc_auto_pop_up', $wplc_default_settings_array, 0, 2 );
|
3662 |
+
$wplc_data['wplc_auto_pop_up_online'] = wplc_force_bool( $_POST, 'wplc_auto_pop_up_online' );
|
3663 |
+
$wplc_data['wplc_auto_pop_up_mobile'] = wplc_force_bool( $_POST, 'wplc_auto_pop_up_mobile' );
|
3664 |
+
$wplc_data['wplc_enable_encryption'] = wplc_force_bool( $_POST, 'wplc_enable_encryption' );
|
3665 |
+
$wplc_data['wplc_use_geolocalization'] = wplc_force_bool( $_POST, 'wplc_use_geolocalization' );
|
3666 |
+
|
3667 |
+
$wplc_data['wplc_require_user_info'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_require_user_info', $wplc_settings ) ) );
|
3668 |
+
if ( ! in_array( $wplc_data['wplc_require_user_info'], array( 'both', 'none', 'email', 'name' ) ) ) {
|
3669 |
+
$wplc_data['wplc_require_user_info'] = 'both';
|
3670 |
+
}
|
3671 |
+
|
3672 |
+
$wplc_data['wplc_user_default_visitor_name'] = substr( stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_user_default_visitor_name' ) ) ), 0, 25 );
|
3673 |
+
|
3674 |
+
$wplc_data['wplc_loggedin_user_info'] = wplc_force_bool( $_POST, 'wplc_loggedin_user_info' );
|
3675 |
+
$wplc_data['wplc_enabled_on_mobile'] = wplc_force_bool( $_POST, 'wplc_enabled_on_mobile' );
|
3676 |
+
$wplc_data['wplc_user_alternative_text'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_user_alternative_text', $wplc_settings ) ) );
|
3677 |
+
if ( empty( $wplc_data['wplc_user_alternative_text'] ) ) {
|
3678 |
+
$wplc_data['wplc_user_alternative_text'] = $wplc_default_settings_array['wplc_user_alternative_text'];
|
3679 |
+
}
|
3680 |
+
|
3681 |
+
$wplc_data['wplc_display_to_loggedin_only'] = wplc_force_bool( $_POST, 'wplc_display_to_loggedin_only' );
|
3682 |
+
$wplc_data['wplc_redirect_to_thank_you_page'] = wplc_force_bool( $_POST, 'wplc_redirect_to_thank_you_page' );
|
3683 |
+
$wplc_data['wplc_redirect_thank_you_url'] = esc_url( wplc_force_url( $_POST, 'wplc_redirect_thank_you_url' ) );
|
3684 |
+
$wplc_data['wplc_disable_emojis'] = wplc_force_bool( $_POST, 'wplc_disable_emojis' );
|
3685 |
+
$wplc_data['wplc_chatbox_height'] = wplc_force_int( $_POST, 'wplc_chatbox_height', $wplc_default_settings_array, 0, 80 );
|
3686 |
+
$wplc_data['wplc_chatbox_absolute_height'] = wplc_force_int( $_POST, 'wplc_chatbox_absolute_height', $wplc_default_settings_array, 100, 1000 );
|
3687 |
+
$wplc_data['wplc_record_ip_address'] = "0";
|
3688 |
+
$wplc_data['wplc_enable_msg_sound'] = wplc_force_bool( $_POST, 'wplc_enable_msg_sound' );
|
3689 |
+
$wplc_data['wplc_enable_visitor_sound'] = wplc_force_bool( $_POST, 'wplc_enable_visitor_sound' );
|
3690 |
+
$wplc_data['wplc_enable_font_awesome'] = wplc_force_bool( $_POST, 'wplc_enable_font_awesome' );
|
3691 |
+
$wplc_data['wplc_enable_all_admin_pages'] = wplc_force_bool( $_POST, 'wplc_enable_all_admin_pages' );
|
3692 |
+
$wplc_data['wplc_delete_db_on_uninstall'] = wplc_force_bool( $_POST, 'wplc_delete_db_on_uninstall' );
|
3693 |
+
$wplc_data['wplc_pro_na'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_na', $wplc_settings ) ) );
|
3694 |
+
$wplc_data['wplc_hide_when_offline'] = wplc_force_bool( $_POST, 'wplc_hide_when_offline' );
|
3695 |
+
$wplc_data['wplc_pro_chat_email_address'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_chat_email_address', $wplc_settings ) ) );
|
3696 |
+
$wplc_data['wplc_pro_chat_email_offline_subject'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_chat_email_offline_subject', $wplc_settings ) ) );
|
3697 |
+
$wplc_data['wplc_pro_offline1'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_offline1', $wplc_settings ) ) );
|
3698 |
+
$wplc_data['wplc_pro_offline2'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_offline2', $wplc_settings ) ) );
|
3699 |
+
$wplc_data['wplc_pro_offline3'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_offline3', $wplc_settings ) ) );
|
3700 |
+
$wplc_data['wplc_pro_offline_btn'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_offline_btn', $wplc_settings ) ) );
|
3701 |
+
$wplc_data['wplc_pro_offline_btn_send'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_offline_btn_send', $wplc_settings ) ) );
|
3702 |
+
$wplc_data['wplc_using_localization_plugin'] = wplc_force_bool( $_POST, 'wplc_using_localization_plugin' );
|
3703 |
+
$wplc_data['wplc_pro_fst1'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_fst1', $wplc_settings ) ) );
|
3704 |
+
$wplc_data['wplc_pro_fst2'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_fst2', $wplc_settings ) ) );
|
3705 |
+
$wplc_data['wplc_pro_fst3'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_fst3', $wplc_settings ) ) );
|
3706 |
+
$wplc_data['wplc_pro_sst1'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_sst1', $wplc_settings ) ) );
|
3707 |
+
$wplc_data['wplc_pro_sst2'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_sst2', $wplc_settings ) ) );
|
3708 |
+
$wplc_data['wplc_pro_tst1'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_tst1', $wplc_settings ) ) );
|
3709 |
+
$wplc_data['wplc_pro_intro'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_intro', $wplc_settings ) ) );
|
3710 |
+
$wplc_data['wplc_user_enter'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_user_enter', $wplc_settings ) ) );
|
3711 |
+
$wplc_data['wplc_text_chat_ended'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_text_chat_ended', $wplc_settings ) ) );
|
3712 |
+
$wplc_data['wplc_close_btn_text'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_close_btn_text', $wplc_settings ) ) );
|
3713 |
+
$wplc_data['wplc_user_welcome_chat'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_user_welcome_chat', $wplc_settings ) ) );
|
3714 |
+
$wplc_data['wplc_welcome_msg'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_welcome_msg', $wplc_settings ) ) );
|
3715 |
+
$wplc_data['wplc_typing_enabled'] = wplc_force_bool( $_POST, 'wplc_typing_enabled' );
|
3716 |
+
$wplc_data['wplc_ux_file_share'] = wplc_force_bool( $_POST, 'wplc_ux_file_share' );
|
3717 |
+
$wplc_data['wplc_ux_exp_rating'] = wplc_force_bool( $_POST, 'wplc_ux_exp_rating' );
|
3718 |
+
$wplc_data['wplc_enable_initiate_chat'] = wplc_force_bool( $_POST, 'wplc_enable_initiate_chat' );
|
3719 |
+
$wplc_data['wplc_node_enable_typing_preview'] = wplc_force_bool( $_POST, 'wplc_node_enable_typing_preview' );
|
3720 |
+
$wplc_data['wplc_gdpr_enabled'] = wplc_force_bool( $_POST, 'wplc_gdpr_enabled' );
|
3721 |
+
$wplc_data['wplc_ringtone'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_ringtone', $wplc_settings ) ) );
|
3722 |
+
$wplc_data['wplc_new_chat_ringer_count'] = wplc_force_int( $_POST, 'wplc_new_chat_ringer_count', $wplc_settings, 0, 100 );
|
3723 |
+
$wplc_data['wplc_messagetone'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_messagetone', $wplc_settings ) ) );
|
3724 |
+
$wplc_data['wplc_animation'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_animation', $wplc_settings ) ) );
|
3725 |
+
$wplc_data['wplc_theme'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_theme', $wplc_settings ) ) );
|
3726 |
+
$wplc_data['wplc_newtheme'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_newtheme', $wplc_settings ) ) );
|
3727 |
+
$wplc_data['wplc_elem_trigger_action'] = wplc_force_int( $_POST, 'wplc_elem_trigger_action', $wplc_settings, 0, 1 );
|
3728 |
+
$wplc_data['wplc_elem_trigger_type'] = wplc_force_int( $_POST, 'wplc_elem_trigger_type', $wplc_settings, 0, 1 );
|
3729 |
+
$wplc_data['wplc_elem_trigger_id'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_elem_trigger_id', $wplc_settings ) ) );
|
3730 |
+
$wplc_data['wplc_show_date'] = wplc_force_bool( $_POST, 'wplc_show_date' );
|
3731 |
+
$wplc_data['wplc_show_time'] = wplc_force_bool( $_POST, 'wplc_show_time' );
|
3732 |
+
$wplc_data['wplc_show_name'] = wplc_force_bool( $_POST, 'wplc_show_name' );
|
3733 |
+
$wplc_data['wplc_show_avatar'] = wplc_force_bool( $_POST, 'wplc_show_avatar' );
|
3734 |
+
$wplc_data['wplc_user_no_answer'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_user_no_answer', $wplc_settings ) ) );
|
3735 |
+
$wplc_data['wplc_pro_auto_first_response_chat_msg'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_auto_first_response_chat_msg', $wplc_settings ) ) );
|
3736 |
+
|
3737 |
+
$wplc_data['wplc_gdpr_enabled'] = wplc_force_bool( $_POST, 'wplc_gdpr_enabled' );
|
3738 |
+
if ( $wplc_settings['wplc_gdpr_enabled'] != $wplc_data['wplc_gdpr_enabled'] ) {
|
3739 |
+
if ( $wplc_data['wplc_gdpr_enabled'] ) {
|
3740 |
+
do_action( 'wplc_gdpr_reg_cron_hook' );
|
3741 |
+
update_option( 'WPLC_GDPR_DISABLED_WARNING_DISMISSED', 'false' );
|
3742 |
+
} else {
|
3743 |
+
do_action( 'wplc_gdpr_de_reg_cron_hook' );
|
3744 |
+
}
|
3745 |
+
}
|
3746 |
+
|
3747 |
+
$wplc_data['wplc_gdpr_notice_company'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_gdpr_notice_company', $wplc_settings ) ) );
|
3748 |
+
$wplc_data['wplc_gdpr_notice_retention_purpose'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_gdpr_notice_retention_purpose', $wplc_settings ) ) );
|
3749 |
+
$wplc_data['wplc_gdpr_notice_retention_period'] = wplc_force_int( $_POST, 'wplc_gdpr_notice_retention_period', $wplc_settings, 1, 730 );
|
3750 |
+
$wplc_data['wplc_gdpr_notice_text'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_gdpr_notice_text' ) ) );
|
3751 |
+
$wplc_data['wplc_gdpr_custom'] = wplc_force_bool( $_POST, 'wplc_gdpr_custom' );
|
3752 |
+
|
3753 |
+
$wplc_data['wplc_use_node_server'] = wplc_force_bool( $_POST, 'wplc_use_node_server' );
|
3754 |
+
$wplc_data['wplc_default_department'] = wplc_force_int( $_POST, 'wplc_default_department', $wplc_settings );
|
3755 |
+
$wplc_data['wplc_allow_department_selection'] = wplc_force_bool( $_POST, 'wplc_allow_department_selection' );
|
3756 |
+
$wplc_data['wplc_pro_cta_anim'] = wplc_force_bool( $_POST, 'wplc_pro_cta_anim' );
|
3757 |
+
$wplc_data['wplc_debug_mode'] = wplc_force_bool( $_POST, 'wplc_debug_mode' );
|
3758 |
+
|
3759 |
+
$wplc_data['wplc_chat_name'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_chat_name', $wplc_settings ) ) );
|
3760 |
+
$wplc_data['wplc_use_wp_name'] = wplc_force_bool( $_POST, 'wplc_use_wp_name' );
|
3761 |
+
|
3762 |
+
$wplc_data['wplc_chat_pic'] = $wplc_settings['wplc_chat_pic'];
|
3763 |
+
$wplc_data['wplc_chat_logo'] = $wplc_settings['wplc_chat_logo'];
|
3764 |
+
$wplc_data['wplc_chat_icon'] = $wplc_settings['wplc_chat_icon'];
|
3765 |
+
|
3766 |
+
$wplc_upload_pic = wplc_force_string( $_POST, 'wplc_upload_pic', '' );
|
3767 |
+
$wplc_upload_logo = wplc_force_string( $_POST, 'wplc_upload_logo', '' );
|
3768 |
+
$wplc_upload_icon = wplc_force_string( $_POST, 'wplc_upload_icon', '' );
|
3769 |
+
|
3770 |
+
if ( ! empty( $wplc_upload_pic ) ) {
|
3771 |
+
if ( $wplc_upload_pic == 'remove' ) {
|
3772 |
+
$wplc_data['wplc_chat_pic'] = ''; //$wplc_default_settings_array['wplc_chat_pic']; // cannot be empty, set to default
|
3773 |
+
} else {
|
3774 |
+
$wplc_data['wplc_chat_pic'] = esc_url( base64_decode( $wplc_upload_pic ) );
|
3775 |
+
}
|
3776 |
+
}
|
3777 |
+
if ( ! empty( $wplc_upload_logo ) ) {
|
3778 |
+
if ( $wplc_upload_logo == 'remove' ) {
|
3779 |
+
$wplc_data['wplc_chat_logo'] = '';
|
3780 |
+
} else {
|
3781 |
+
$wplc_data['wplc_chat_logo'] = esc_url( base64_decode( $wplc_upload_logo ) );
|
3782 |
+
}
|
3783 |
+
}
|
3784 |
+
if ( ! empty( $wplc_upload_icon ) ) {
|
3785 |
+
if ( $wplc_upload_icon == 'remove' ) {
|
3786 |
+
$wplc_data['wplc_chat_icon'] = '';
|
3787 |
+
} else {
|
3788 |
+
$wplc_data['wplc_chat_icon'] = esc_url( base64_decode( $wplc_upload_icon ) );
|
3789 |
+
}
|
3790 |
+
|
3791 |
+
}
|
3792 |
+
|
3793 |
+
$wplc_data['wplc_chat_delay'] = wplc_force_int( $_POST, 'wplc_chat_delay', $wplc_default_settings_array, 0, 1000 );
|
3794 |
+
$wplc_data['wplc_pro_chat_notification'] = wplc_force_bool( $_POST, 'wplc_pro_chat_notification' );
|
3795 |
+
$wplc_data['wplc_pro_chat_email_address'] = stripslashes( sanitize_text_field( wplc_force_string( $_POST, 'wplc_pro_chat_email_address', $wplc_settings ) ) );
|
3796 |
+
$wplc_data['wplc_social_fb'] = esc_url( wplc_force_url( $_POST, 'wplc_social_fb' ) );
|
3797 |
+
$wplc_data['wplc_social_tw'] = esc_url( wplc_force_url( $_POST, 'wplc_social_tw' ) );
|
3798 |
+
|
3799 |
+
$wplc_data['wplc_bh_enable'] = wplc_force_bool( $_POST, 'wplc_bh_enable' );
|
3800 |
+
|
3801 |
+
$wplc_data['wplc_bh_days'] = '0000000';
|
3802 |
+
if ( isset( $_POST['wplc_bh_days'] ) && is_array( $_POST['wplc_bh_days'] ) ) {
|
3803 |
+
foreach ( $_POST['wplc_bh_days'] as $k => $v ) {
|
3804 |
+
if ( $k >= 0 && $k < 7 ) {
|
3805 |
+
$wplc_data['wplc_bh_days'][ $k ] = '1';
|
3806 |
+
}
|
3807 |
+
}
|
3808 |
+
}
|
3809 |
+
|
3810 |
+
$wplc_data['wplc_bh_schedule'] = $wplc_default_settings_array['wplc_bh_schedule'];
|
3811 |
+
foreach ( $wplc_data['wplc_bh_schedule'] as $k => $v ) {
|
3812 |
+
if ( isset( $_POST['bh_hs1'][ $k ] ) ) {
|
3813 |
+
$wplc_data['wplc_bh_schedule'][ $k ][0]['hs'] = wplc_force_int_range( intval( $_POST['bh_hs1'][ $k ] ), 0, 23 );
|
3814 |
+
}
|
3815 |
+
if ( isset( $_POST['bh_ms1'][ $k ] ) ) {
|
3816 |
+
$wplc_data['wplc_bh_schedule'][ $k ][0]['ms'] = wplc_force_int_range( intval( $_POST['bh_ms1'][ $k ] ), 0, 59 );
|
3817 |
+
}
|
3818 |
+
if ( isset( $_POST['bh_he1'][ $k ] ) ) {
|
3819 |
+
$wplc_data['wplc_bh_schedule'][ $k ][0]['he'] = wplc_force_int_range( intval( $_POST['bh_he1'][ $k ] ), 0, 23 );
|
3820 |
+
}
|
3821 |
+
if ( isset( $_POST['bh_me1'][ $k ] ) ) {
|
3822 |
+
$wplc_data['wplc_bh_schedule'][ $k ][0]['me'] = wplc_force_int_range( intval( $_POST['bh_me1'][ $k ] ), 0, 59 );
|
3823 |
+
}
|
3824 |
+
if ( isset( $_POST['bh_hs2'][ $k ] ) ) {
|
3825 |
+
$wplc_data['wplc_bh_schedule'][ $k ][1]['hs'] = wplc_force_int_range( intval( $_POST['bh_hs2'][ $k ] ), 0, 23 );
|
3826 |
+
}
|
3827 |
+
if ( isset( $_POST['bh_ms2'][ $k ] ) ) {
|
3828 |
+
$wplc_data['wplc_bh_schedule'][ $k ][1]['ms'] = wplc_force_int_range( intval( $_POST['bh_ms2'][ $k ] ), 0, 59 );
|
3829 |
+
}
|
3830 |
+
if ( isset( $_POST['bh_he2'][ $k ] ) ) {
|
3831 |
+
$wplc_data['wplc_bh_schedule'][ $k ][1]['he'] = wplc_force_int_range( intval( $_POST['bh_he2'][ $k ] ), 0, 23 );
|
3832 |
+
}
|
3833 |
+
if ( isset( $_POST['bh_me2'][ $k ] ) ) {
|
3834 |
+
$wplc_data['wplc_bh_schedule'][ $k ][1]['me'] = wplc_force_int_range( intval( $_POST['bh_me2'][ $k ] ), 0, 59 );
|
3835 |
+
}
|
3836 |
+
}
|
3837 |
+
|
3838 |
+
$wplc_data['wplc_iterations'] = wplc_force_int( $_POST, 'wplc_iterations', $wplc_default_settings_array, 10, 200 );
|
3839 |
+
$wplc_data['wplc_delay_between_loops'] = wplc_force_int( $_POST, 'wplc_delay_between_loops', $wplc_default_settings_array['wplc_delay_between_loops'] / 1000, 250, 1000 ) * 1000;
|
3840 |
+
|
3841 |
+
if ( isset( $_POST['wplc_agent_select'] ) && $_POST['wplc_agent_select'] != "" ) {
|
3842 |
+
$user_array = wplc_get_agent_users();
|
3843 |
+
foreach ( $user_array as $user ) {
|
3844 |
+
$uid = $user->ID;
|
3845 |
+
$wplc_ma_user = new WP_User( $uid );
|
3846 |
+
$wplc_ma_user->remove_cap( 'wplc_ma_agent' );
|
3847 |
+
delete_user_meta( $uid, "wplc_ma_agent" );
|
3848 |
+
delete_user_meta( $uid, "wplc_chat_agent_online" );
|
3849 |
+
}
|
3850 |
+
|
3851 |
+
$uid = intval( $_POST['wplc_agent_select'] );
|
3852 |
+
$wplc_ma_user = new WP_User( $uid );
|
3853 |
+
$wplc_ma_user->add_cap( 'wplc_ma_agent' );
|
3854 |
+
update_user_meta( $uid, "wplc_ma_agent", 1 );
|
3855 |
+
wplc_update_agent_time( $uid );
|
3856 |
+
}
|
3857 |
+
|
3858 |
+
if ( isset( $_POST['wplc_ban_users_ip'] ) ) {
|
3859 |
+
$wplc_banned_ip_addresses = explode( '<br />', stripslashes( nl2br( $_POST['wplc_ban_users_ip'] ) ) );
|
3860 |
+
$data = array();
|
3861 |
+
foreach ( $wplc_banned_ip_addresses as $key => $value ) {
|
3862 |
+
$clean_val = trim( sanitize_text_field( $value ) );
|
3863 |
+
if ( ! empty( $clean_val ) ) {
|
3864 |
+
$data[ $key ] = $clean_val;
|
3865 |
+
}
|
3866 |
+
}
|
3867 |
+
$wplc_banned_ip_addresses = maybe_serialize( $data );
|
3868 |
+
update_option( 'WPLC_BANNED_IP_ADDRESSES', $wplc_banned_ip_addresses );
|
3869 |
+
}
|
3870 |
+
|
3871 |
+
ksort( $wplc_data );
|
3872 |
+
$wplc_data['wplc_encryption_key'] = $wplc_settings['wplc_encryption_key'];
|
3873 |
+
update_option( 'WPLC_SETTINGS', $wplc_data );
|
3874 |
+
|
3875 |
+
add_action( 'admin_notices', 'wplc_save_settings_action' );
|
3876 |
+
}
|
3877 |
+
|
3878 |
+
if ( isset( $_GET['override'] ) && $_GET['override'] == '1' ) {
|
3879 |
+
update_option( "WPLC_V8_FIRST_TIME", false );
|
3880 |
+
}
|
3881 |
}
|
3882 |
|
3883 |
function wplc_save_settings_action() { ?>
|
3884 |
<div class='notice notice-success updated wplc_settings_save_notice'>
|
3885 |
+
<?php _e( "Your settings have been saved.", 'wp-live-chat-support' ); ?>
|
3886 |
</div>
|
3887 |
<?php }
|
3888 |
|
3889 |
/**
|
3890 |
* Error checks used to ensure the user's resources meet the plugin's requirements
|
3891 |
*/
|
3892 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == 'wplivechat-menu-settings' ) {
|
3893 |
+
if ( is_admin() ) {
|
3894 |
+
|
3895 |
+
// Only show these warning messages to Legacy users as they will be affected, not Node users.
|
3896 |
+
$wplc_settings = wplc_get_options();
|
3897 |
+
if ( ! $wplc_settings['wplc_use_node_server'] ) {
|
3898 |
+
|
3899 |
+
$wplc_error_count = 0;
|
3900 |
+
$wplc_admin_warnings = "<div class='error'>";
|
3901 |
+
if ( ! function_exists( 'set_time_limit' ) ) {
|
3902 |
+
$wplc_admin_warnings .= "
|
3903 |
+
<p>" . __( "WPLC: set_time_limit() is not enabled on this server. You may experience issues while using WP Live Chat by 3CX as a result of this. Please get in contact your host to get this function enabled.", 'wp-live-chat-support' ) . "</p>
|
3904 |
";
|
3905 |
+
$wplc_error_count ++;
|
3906 |
+
}
|
3907 |
+
if ( ini_get( 'safe_mode' ) ) {
|
3908 |
+
$wplc_admin_warnings .= "
|
3909 |
+
<p>" . __( "WPLC: Safe mode is enabled on this server. You may experience issues while using WP Live Chat by 3CX as a result of this. Please contact your host to get safe mode disabled.", 'wp-live-chat-support' ) . "</p>
|
3910 |
";
|
3911 |
+
$wplc_error_count ++;
|
3912 |
+
}
|
3913 |
+
$wplc_admin_warnings .= "</div>";
|
3914 |
+
if ( $wplc_error_count > 0 ) {
|
3915 |
+
echo $wplc_admin_warnings;
|
3916 |
+
}
|
3917 |
+
}
|
3918 |
+
}
|
3919 |
}
|
3920 |
|
3921 |
/**
|
3923 |
* @return string
|
3924 |
*/
|
3925 |
function wplc_support_menu() {
|
3926 |
+
wplc_stats( "support" );
|
3927 |
+
?>
|
3928 |
+
<div class="wrap wplc_wrap">
|
3929 |
+
<h2><?php _e( "Support", 'wp-live-chat-support' ); ?></h2>
|
3930 |
+
<div class="wplc_row_support">
|
3931 |
+
<div class='wplc_row_col_support' style='background-color:#FFF;'>
|
3932 |
+
<div class="wplc_panel_heading"><i
|
3933 |
+
class="far fa-check-circle"></i> <?php _e( "Plugin Features", 'wp-live-chat-support' ); ?>
|
3934 |
+
</div>
|
3935 |
+
<div class="wplc_row_col_support_inner">
|
3936 |
+
<?php _e( "Check out these features and get up to speed with what you can do with WP Live Chat:", 'wp-live-chat-support' ); ?>
|
3937 |
+
<ul>
|
3938 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/features/' target='_BLANK'
|
3939 |
+
title='<?php _e( "Plugin Features", 'wp-live-chat-support' ); ?>'><?php _e( "Plugin Features", 'wp-live-chat-support' ); ?></a>
|
3940 |
+
</li>
|
3941 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/features/#h.qquuf2facgvf' target='_BLANK'
|
3942 |
+
title='<?php _e( "Reporting", 'wp-live-chat-support' ); ?>'><?php _e( "Reporting", 'wp-live-chat-support' ); ?></a>
|
3943 |
+
</li>
|
3944 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/translation/' target='_BLANK'
|
3945 |
+
title='<?php _e( "Localization", 'wp-live-chat-support' ); ?>'><?php _e( "Localization", 'wp-live-chat-support' ); ?></a>
|
3946 |
+
</li>
|
3947 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/triggers/' target='_BLANK'
|
3948 |
+
title='<?php _e( "Triggers", 'wp-live-chat-support' ); ?>'><?php _e( "Triggers", 'wp-live-chat-support' ); ?></a>
|
3949 |
+
</li>
|
3950 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/features/#h.8yn2kwmystj2' target='_BLANK'
|
3951 |
+
title='<?php _e( "Web Hooks", 'wp-live-chat-support' ); ?>'><?php _e( "Web Hooks", 'wp-live-chat-support' ); ?></a>
|
3952 |
+
</li>
|
3953 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/features/#h.7t9i9vdx2z96' target='_BLANK'
|
3954 |
+
title='<?php _e( "ROI Goals", 'wp-live-chat-support' ); ?>'><?php _e( "ROI Goals", 'wp-live-chat-support' ); ?></a>
|
3955 |
+
</li>
|
3956 |
+
</ul>
|
3957 |
+
</div>
|
3958 |
+
</div>
|
3959 |
+
<div class='wplc_row_col_support' style='background-color:#FFF;'>
|
3960 |
+
<div class="wplc_panel_heading"><i
|
3961 |
+
class="fa fa-book"></i> <?php _e( "Chat FAQs", 'wp-live-chat-support' ); ?></div>
|
3962 |
+
<div class="wplc_row_col_support_inner">
|
3963 |
+
<?php _e( "Learn quickly the ins and outs of Chat and start chatting with visitors and agents:", 'wp-live-chat-support' ); ?>
|
3964 |
+
<ul>
|
3965 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/settings/' target='_BLANK'
|
3966 |
+
title='<?php _e( "Chat with Visitors", 'wp-live-chat-support' ); ?>'><?php _e( "Chat with Visitors", 'wp-live-chat-support' ); ?></a>
|
3967 |
+
</li>
|
3968 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/features/#h.q5e6o9g62hlm' target='_BLANK'
|
3969 |
+
title='<?php _e( "Chat with Agents", 'wp-live-chat-support' ); ?>'><?php _e( "Chat with Agents", 'wp-live-chat-support' ); ?></a>
|
3970 |
+
</li>
|
3971 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/quick-responses/' target='_BLANK'
|
3972 |
+
title='<?php _e( "Quick Responses", 'wp-live-chat-support' ); ?>'><?php _e( "Quick Responses", 'wp-live-chat-support' ); ?></a>
|
3973 |
+
</li>
|
3974 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/offline-chat/' target='_BLANK'
|
3975 |
+
title='<?php _e( "Offline Messages", 'wp-live-chat-support' ); ?>'><?php _e( "Offline Messages", 'wp-live-chat-support' ); ?></a>
|
3976 |
+
</li>
|
3977 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/settings/#h.w4ystw3nh379' target='_BLANK'
|
3978 |
+
title='<?php _e( "Chat History", 'wp-live-chat-support' ); ?>'><?php _e( "Chat History", 'wp-live-chat-support' ); ?></a>
|
3979 |
+
</li>
|
3980 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/features/#h.7cm70gxsp8c6' target='_BLANK'
|
3981 |
+
title='<?php _e( "Chat Invites", 'wp-live-chat-support' ); ?>'><?php _e( "Chat Invites", 'wp-live-chat-support' ); ?></a>
|
3982 |
+
</li>
|
3983 |
+
</ul>
|
3984 |
+
</div>
|
3985 |
+
</div>
|
3986 |
+
<div class='wplc_row_col_support' style='background-color:#FFF;'>
|
3987 |
+
<div class="wplc_panel_heading"><i
|
3988 |
+
class="fas fa-sliders-h"></i> <?php _e( "Settings & Customization", 'wp-live-chat-support' ); ?>
|
3989 |
+
</div>
|
3990 |
+
<div class="wplc_row_col_support_inner">
|
3991 |
+
<?php _e( "Use these guides to learn how to configure and customize WP Live Chat:", 'wp-live-chat-support' ); ?>
|
3992 |
+
<ul>
|
3993 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/chatbox-customization/#h.3y0oqa82jfpo'
|
3994 |
+
target='_BLANK'
|
3995 |
+
title='<?php _e( "General Settings", 'wp-live-chat-support' ); ?>'><?php _e( "General Settings", 'wp-live-chat-support' ); ?></a>
|
3996 |
+
</li>
|
3997 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/chatbox-customization/#h.1u24onjmgol1'
|
3998 |
+
target='_BLANK'
|
3999 |
+
title='<?php _e( "Chat Box Settings", 'wp-live-chat-support' ); ?>'><?php _e( "Chat Box Settings", 'wp-live-chat-support' ); ?></a>
|
4000 |
+
</li>
|
4001 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/chatbox-customization/#h.xwu4yozf3o4v'
|
4002 |
+
target='_BLANK'
|
4003 |
+
title='<?php _e( "Agent Settings", 'wp-live-chat-support' ); ?>'><?php _e( "Agent Settings", 'wp-live-chat-support' ); ?></a>
|
4004 |
+
</li>
|
4005 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/chatbox-customization/#h.skw0v5uc8avz'
|
4006 |
+
target='_BLANK'
|
4007 |
+
title='<?php _e( "Business Hours", 'wp-live-chat-support' ); ?>'><?php _e( "Business Hours", 'wp-live-chat-support' ); ?></a>
|
4008 |
+
</li>
|
4009 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/gutenberg/' target='_BLANK'
|
4010 |
+
title='<?php _e( "Gutenberg Blocks", 'wp-live-chat-support' ); ?>'><?php _e( "Gutenberg Blocks", 'wp-live-chat-support' ); ?></a>
|
4011 |
+
</li>
|
4012 |
+
</ul>
|
4013 |
+
</div>
|
4014 |
+
</div>
|
4015 |
+
<div class='wplc_row_col_support' style='background-color:#FFF;'>
|
4016 |
+
<div class="wplc_panel_heading"><i
|
4017 |
+
class="fa fa-info-circle"></i> <?php _e( "Troubleshooting", 'wp-live-chat-support' ); ?>
|
4018 |
+
</div>
|
4019 |
+
<div class="wplc_row_col_support_inner">
|
4020 |
+
<?php _e( "Reference these troubleshooting guides to quickly resolve any WP Live Chat issues:", 'wp-live-chat-support' ); ?>
|
4021 |
+
<ul>
|
4022 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/chat-box-not-showing/' target='_BLANK'
|
4023 |
+
title='<?php _e( "My Chat Box Is Not Showing", 'wp-live-chat-support' ); ?>'><?php _e( "My Chat Box Is Not Showing", 'wp-live-chat-support' ); ?></a>
|
4024 |
+
</li>
|
4025 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/not-receiving-notifications-of-new-chats/'
|
4026 |
+
target='_BLANK'
|
4027 |
+
title='<?php _e( "Not Receiving Notifications of New Chats", 'wp-live-chat-support' ); ?>'><?php _e( "Not Receiving Notifications of New Chats", 'wp-live-chat-support' ); ?></a>
|
4028 |
+
</li>
|
4029 |
+
<li><a href='https://www.3cx.com/wp-live-chat/docs/javascript-errors/' target='_BLANK'
|
4030 |
+
title='<?php _e( "Check for JavaScript Errors", 'wp-live-chat-support' ); ?>'><?php _e( "Check for JavaScript Errors", 'wp-live-chat-support' ); ?></a>
|
4031 |
+
</li>
|
4032 |
+
</ul>
|
4033 |
+
</div>
|
4034 |
+
</div>
|
4035 |
</div>
|
4036 |
</div>
|
4037 |
+
<?php
|
|
|
4038 |
}
|
4039 |
|
4040 |
//if (!function_exists("wplc_ic_initiate_chat_button")) { TODO: check why
|
4041 |
+
add_action( 'admin_enqueue_scripts', 'wp_button_pointers_load_scripts' );
|
4042 |
//}
|
4043 |
/**
|
4044 |
* Displays the pointers on the live chat dashboard for the initiate chat functionality
|
4045 |
+
*
|
4046 |
+
* @param string $hook returns the page name we're on
|
4047 |
+
*
|
4048 |
* @return string contents of the pointers and their scripts
|
4049 |
*/
|
4050 |
+
function wp_button_pointers_load_scripts( $hook ) {
|
4051 |
+
$wplcrun = false;
|
4052 |
+
$wplc_settings = wplc_get_options();
|
4053 |
+
if ( $wplc_settings['wplc_enable_all_admin_pages'] ) {
|
4054 |
+
/* Run admin JS on all admin pages */
|
4055 |
+
$wplcrun = true;
|
4056 |
+
} else {
|
4057 |
+
if ( $hook === 'toplevel_page_wplivechat-menu' ) {
|
4058 |
+
$wplcrun = true;
|
4059 |
+
} // stop if we are not on the right page
|
4060 |
+
}
|
4061 |
+
if ( $wplcrun ) {
|
4062 |
+
$pointer_localize_strings = array(
|
4063 |
+
"initiate" => "<h3>" . __( "Initiate Chats", 'wp-live-chat-support' ) . "</h3>",
|
4064 |
+
"chats" => "<h3>" . __( "Multiple Chats", 'wp-live-chat-support' ) . "</h3>",
|
4065 |
+
"agent_info" => "<h3>" . __( "Add unlimited agents", 'wp-live-chat-support' ) . "</h3>",
|
4066 |
+
"transfer" => "<h3>" . __( "Transfer Chats", 'wp-live-chat-support' ) . "</h3>",
|
4067 |
+
"direct_to_page" => "<h3>" . __( "Direct User To Page", 'wp-live-chat-support' ) . "</h3>"
|
4068 |
+
);
|
4069 |
+
wp_enqueue_style( 'wp-pointer' );
|
4070 |
+
wp_enqueue_script( 'wp-pointer' );
|
4071 |
+
wp_register_script( 'wplc-user-admin-pointer', wplc_plugins_url( '/js/wplc-admin-pointers.js', __FILE__ ), array( 'wp-pointer' ), WPLC_PLUGIN_VERSION, true );
|
4072 |
+
wp_enqueue_script( 'wplc-user-admin-pointer' );
|
4073 |
+
wp_localize_script( 'wplc-user-admin-pointer', 'pointer_localize_strings', $pointer_localize_strings );
|
4074 |
+
}
|
4075 |
}
|
4076 |
|
4077 |
add_filter( 'admin_footer_text', 'wplc_footer_mod' );
|
4078 |
/**
|
4079 |
* Adds the WP Live Chat by 3CX footer contents to the relevant pages
|
4080 |
+
*
|
4081 |
+
* @param string $footer_text current footer text available to us
|
4082 |
+
*
|
4083 |
* @return string footer contents with our branding in it
|
4084 |
*/
|
4085 |
function wplc_footer_mod( $footer_text ) {
|
4086 |
+
if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'wplivechat-menu' || $_GET['page'] == 'wplivechat-menu-settings' || $_GET['page'] == 'wplivechat-menu-offline-messages' || $_GET['page'] == 'wplivechat-menu-history' ) ) {
|
4087 |
+
$footer_text_mod = sprintf( __( 'Thank you for using %s! Please %s on %s', 'wp-live-chat-support' ), '<a href="https://www.3cx.com/wp-live-chat/?utm_source=plugin&utm_medium=link&utm_campaign=footer" target="_blank">WP Live Chat by 3CX</a>', '<a href="https://wordpress.org/support/view/plugin-reviews/wp-live-chat-support?filter=5#postform" target="_blank">' . __( 'rate us', 'wp-live-chat-support' ) . '</a>', '<a href="https://wordpress.org/support/view/plugin-reviews/wp-live-chat-support?filter=5#postform" target="_blank">WordPress.org</a>' );
|
4088 |
+
|
4089 |
+
return str_replace( '</span>', '', $footer_text ) . ' | ' . $footer_text_mod;
|
4090 |
+
} else {
|
4091 |
+
return $footer_text;
|
4092 |
+
}
|
4093 |
|
4094 |
}
|
4095 |
|
4096 |
+
add_filter( "wplc_filter_admin_long_poll_chat_loop_iteration", "wplc_filter_control_wplc_admin_long_poll_chat_iteration", 1, 3 );
|
4097 |
/**
|
4098 |
* Alters the admin's long poll chat iteration
|
4099 |
+
*
|
4100 |
+
* @param array $array current chat data available to us
|
4101 |
+
* @param array $post_data current post data available to us
|
4102 |
+
* @param int $i count for each chat available
|
4103 |
+
*
|
4104 |
* @return array additional contents added to the chat data
|
4105 |
*/
|
4106 |
+
function wplc_filter_control_wplc_admin_long_poll_chat_iteration( $array, $post_data, $i ) {
|
4107 |
+
if ( isset( $post_data['action_2'] ) && $post_data['action_2'] == "wplc_long_poll_check_user_opened_chat" ) {
|
4108 |
+
$chat_status = wplc_return_chat_status( sanitize_text_field( $post_data['cid'] ) );
|
4109 |
+
if ( intval( $chat_status ) == 3 ) {
|
4110 |
+
$array['action'] = "wplc_user_open_chat";
|
4111 |
+
}
|
4112 |
+
} else {
|
4113 |
|
4114 |
+
if ( $post_data['first_run'] === "true" ) {
|
4115 |
+
/* get the chat messages for the first run */
|
4116 |
+
$array['chat_history'] = wplc_return_chat_messages( $post_data['cid'], false, true, false, false, 'array', false );
|
4117 |
+
$array['action'] = "wplc_chat_history";
|
4118 |
|
4119 |
+
} else {
|
4120 |
|
4121 |
+
$new_chat_status = wplc_return_chat_status( sanitize_text_field( $post_data['cid'] ) );
|
4122 |
+
if ( $new_chat_status != $post_data['chat_status'] ) {
|
4123 |
+
$array['chat_status'] = $new_chat_status;
|
4124 |
+
$array['action'] = "wplc_update_chat_status";
|
4125 |
+
}
|
4126 |
+
$new_chat_message = wplc_return_admin_chat_messages( sanitize_text_field( $post_data['cid'] ) );
|
4127 |
|
4128 |
+
if ( $new_chat_message ) {
|
4129 |
|
4130 |
+
$array['chat_message'] = $new_chat_message;
|
4131 |
+
$array['action'] = "wplc_new_chat_message";
|
4132 |
+
}
|
4133 |
+
}
|
4134 |
+
}
|
4135 |
|
4136 |
+
return $array;
|
4137 |
}
|
4138 |
|
4139 |
|
|
|
4140 |
/**
|
4141 |
* Returns chat data specific to a chat ID
|
4142 |
+
*
|
4143 |
+
* @param int $cid Chat ID
|
4144 |
+
*
|
4145 |
+
* @return array Contents of the chat based on the ID provided
|
4146 |
*/
|
4147 |
+
function wplc_get_chat_data( $cid ) {
|
4148 |
+
global $wpdb;
|
4149 |
+
global $wplc_tblname_chats;
|
4150 |
+
$cid = wplc_return_chat_id_by_rel_or_id( $cid );
|
4151 |
+
$results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wplc_tblname_chats WHERE `id` = %d LIMIT 1", intval( $cid ) ) );
|
4152 |
+
if ( isset( $results[0] ) ) {
|
4153 |
+
$result = $results[0];
|
4154 |
+
} else {
|
4155 |
+
$result = null;
|
4156 |
+
}
|
4157 |
+
|
4158 |
+
return $result;
|
4159 |
}
|
4160 |
|
4161 |
/**
|
4162 |
* Returns chat messages specific to a chat ID
|
4163 |
+
*
|
4164 |
+
* @param int $cid Chat ID
|
4165 |
+
*
|
4166 |
+
* @return array Chat messages based on the ID provided
|
4167 |
*/
|
4168 |
+
function wplc_get_chat_messages( $cid, $only_read_messages = false, $wplc_settings = false ) {
|
4169 |
+
global $wpdb;
|
4170 |
+
global $wplc_tblname_msgs;
|
4171 |
|
4172 |
+
if ( ! $wplc_settings ) {
|
4173 |
+
$wplc_settings = wplc_get_options();
|
4174 |
+
}
|
4175 |
|
4176 |
+
/**
|
4177 |
+
* Identify if the user is using the node server and if they are, display all messages. Otherwise display read only messages (non-node users)
|
4178 |
+
*/
|
4179 |
+
if ( $wplc_settings['wplc_use_node_server'] ) {
|
4180 |
|
4181 |
+
$sql = "
|
4182 |
SELECT * FROM (
|
4183 |
SELECT *
|
4184 |
FROM $wplc_tblname_msgs
|
4187 |
) sub
|
4188 |
ORDER BY `timestamp` ASC
|
4189 |
";
|
4190 |
+
} else {
|
4191 |
+
if ( $only_read_messages ) {
|
4192 |
+
// only show read messages
|
4193 |
+
$sql =
|
4194 |
+
"
|
4195 |
SELECT * FROM (
|
4196 |
SELECT *
|
4197 |
FROM $wplc_tblname_msgs
|
4200 |
) sub
|
4201 |
ORDER BY `timestamp` ASC
|
4202 |
";
|
4203 |
+
} else {
|
4204 |
+
$sql =
|
4205 |
+
"
|
4206 |
SELECT * FROM (
|
4207 |
SELECT *
|
4208 |
FROM $wplc_tblname_msgs
|
4211 |
) sub
|
4212 |
ORDER BY `timestamp` ASC
|
4213 |
";
|
4214 |
+
}
|
4215 |
|
4216 |
+
}
|
4217 |
+
$results = $wpdb->get_results( $wpdb->prepare( $sql, $cid ) );
|
4218 |
|
4219 |
+
if ( isset( $results[0] ) ) {
|
4220 |
+
} else {
|
4221 |
+
$results = null;
|
4222 |
+
}
|
4223 |
+
$results = apply_filters( "wplc_filter_get_chat_messages", $results, $cid );
|
4224 |
|
4225 |
+
if ( $results == "null" ) {
|
4226 |
+
return false;
|
4227 |
+
} else {
|
4228 |
+
return $results;
|
4229 |
+
}
|
4230 |
}
|
4231 |
|
4232 |
+
add_action( 'admin_init', 'wplc_admin_download_chat_history' );
|
4233 |
/**
|
4234 |
* Downloads the chat history and adds it to a CSV file
|
4235 |
* @return file
|
4236 |
*/
|
4237 |
+
function wplc_admin_download_chat_history() {
|
4238 |
+
if ( ! is_user_logged_in() || ! wplc_user_is_agent() ) {
|
4239 |
+
return;
|
4240 |
}
|
4241 |
|
4242 |
+
if ( isset( $_GET['action'] ) && $_GET['action'] == "download_history" ) {
|
4243 |
|
4244 |
+
global $wpdb;
|
4245 |
|
4246 |
+
if ( ! isset( $_GET['wplc_history_nonce'] ) || ! wp_verify_nonce( $_GET['wplc_history_nonce'], 'wplc_history_nonce' ) ) {
|
4247 |
+
wp_die( __( "You do not have permission do perform this action", 'wp-live-chat-support' ) );
|
4248 |
+
}
|
4249 |
|
4250 |
+
$chat_id = sanitize_text_field( $_GET['cid'] );
|
4251 |
+
$fileName = 'live_chat_history_' . md5( $chat_id ) . '.csv';
|
4252 |
|
4253 |
+
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
|
4254 |
+
header( 'Content-Description: File Transfer' );
|
4255 |
+
header( "Content-type: text/csv" );
|
4256 |
+
header( "Content-Disposition: attachment; filename={$fileName}" );
|
4257 |
+
header( "Expires: 0" );
|
4258 |
+
header( "Pragma: public" );
|
4259 |
|
4260 |
+
$fh = @fopen( 'php://output', 'w' );
|
4261 |
|
4262 |
+
global $wpdb;
|
4263 |
+
global $wplc_tblname_msgs;
|
4264 |
|
4265 |
+
$results = $wpdb->get_results( $wpdb->prepare( "
|
4266 |
SELECT *
|
4267 |
FROM $wplc_tblname_msgs
|
4268 |
WHERE `chat_sess_id` = %s
|
4269 |
ORDER BY `timestamp` ASC
|
4270 |
LIMIT 0,1000
|
4271 |
+
", $chat_id )
|
4272 |
+
);
|
4273 |
+
|
4274 |
+
$fields[] = array(
|
4275 |
+
'id' => __( 'Chat ID', 'wp-live-chat-support' ),
|
4276 |
+
'msgfrom' => __( 'From', 'wp-live-chat-support' ),
|
4277 |
+
'msg' => __( 'Message', 'wp-live-chat-support' ),
|
4278 |
+
'time' => __( 'Timestamp', 'wp-live-chat-support' ),
|
4279 |
+
'orig' => __( 'Origin', 'wp-live-chat-support' ),
|
4280 |
+
);
|
4281 |
+
|
4282 |
+
foreach ( $results as $result => $key ) {
|
4283 |
+
if ( $key->originates == 2 ) {
|
4284 |
+
$user = __( 'user', 'wp-live-chat-support' );
|
4285 |
+
} else {
|
4286 |
+
$user = __( 'agent', 'wp-live-chat-support' );
|
4287 |
+
}
|
4288 |
+
|
4289 |
+
$fields[] = array(
|
4290 |
+
'id' => $key->chat_sess_id,
|
4291 |
+
'msgfrom' => $key->msgfrom,
|
4292 |
+
'msg' => apply_filters( "wplc_filter_message_control_out", $key->msg ),
|
4293 |
+
'time' => $key->timestamp,
|
4294 |
+
'orig' => $user,
|
4295 |
+
);
|
4296 |
+
}
|
4297 |
+
|
4298 |
+
foreach ( $fields as $field ) {
|
4299 |
+
fputcsv( $fh, $field, ",", '"' );
|
4300 |
+
}
|
4301 |
+
// Close the file
|
4302 |
+
fclose( $fh );
|
4303 |
+
// Make sure nothing else is sent, our file is done
|
4304 |
+
exit;
|
4305 |
+
|
4306 |
+
}
|
4307 |
}
|
4308 |
|
4309 |
/**
|
4310 |
* Retrieves the data to start downloadling the chat history
|
4311 |
+
*
|
4312 |
+
* @param string $type Chat history output type
|
4313 |
+
* @param string $cid Chat ID
|
4314 |
+
*
|
4315 |
* @return void
|
4316 |
*/
|
4317 |
+
function wplc_admin_download_history( $type, $cid ) {
|
4318 |
+
if ( ! is_user_logged_in() || ! wplc_user_is_agent( get_current_user_id() ) ) {
|
4319 |
+
return;
|
4320 |
}
|
4321 |
|
4322 |
+
global $wpdb;
|
4323 |
+
global $wplc_tblname_msgs;
|
4324 |
|
4325 |
+
$results = $wpdb->get_results( $wpdb->prepare(
|
4326 |
+
"
|
4327 |
SELECT *
|
4328 |
FROM $wplc_tblname_msgs
|
4329 |
WHERE `chat_sess_id` = %d
|
4330 |
ORDER BY `timestamp` ASC
|
4331 |
LIMIT 0, 100
|
4332 |
"
|
4333 |
+
, intval( $cid ) )
|
4334 |
+
);
|
4335 |
|
4336 |
+
$fields[] = array(
|
4337 |
+
'id' => __( 'Chat ID', 'wp-live-chat-support' ),
|
4338 |
+
'msgfrom' => __( 'From', 'wp-live-chat-support' ),
|
4339 |
+
'msg' => __( 'Message', 'wp-live-chat-support' ),
|
4340 |
+
'time' => __( 'Timestamp', 'wp-live-chat-support' ),
|
4341 |
+
'orig' => __( 'Origin', 'wp-live-chat-support' ),
|
4342 |
+
);
|
4343 |
|
4344 |
+
foreach ( $results as $key ) {
|
4345 |
+
if ( $key->originates == 2 ) {
|
4346 |
+
$user = __( 'user', 'wp-live-chat-support' );
|
4347 |
+
} else {
|
4348 |
+
$user = __( 'agent', 'wp-live-chat-support' );
|
4349 |
+
}
|
4350 |
|
4351 |
+
$fields[] = array(
|
4352 |
+
'id' => $key->chat_sess_id,
|
4353 |
+
'msgfrom' => $key->msgfrom,
|
4354 |
+
'msg' => apply_filters( "wplc_filter_message_control_out", $key->msg ),
|
4355 |
+
'time' => $key->timestamp,
|
4356 |
+
'orig' => $user,
|
4357 |
+
);
|
4358 |
+
}
|
4359 |
|
4360 |
+
ob_end_clean();
|
4361 |
|
4362 |
+
wplc_convert_to_csv( $fields, 'live_chat_history_' . $cid . '.csv', ',' );
|
4363 |
|
4364 |
+
exit();
|
4365 |
}
|
4366 |
|
4367 |
/**
|
4368 |
* Converts contents into a CSV file
|
4369 |
+
*
|
4370 |
+
* @param string $in Contents of file, array of arrays
|
4371 |
+
* @param string $out Output of file
|
4372 |
+
* @param string $del Delimiter for content
|
4373 |
+
*
|
4374 |
* @return void
|
4375 |
*/
|
4376 |
+
function wplc_convert_to_csv( $in, $out, $del ) {
|
4377 |
+
$f = fopen( 'php://memory', 'w' );
|
4378 |
|
4379 |
+
foreach ( $in as $arr ) {
|
4380 |
+
wplc_fputcsv_eol( $f, $arr, $del, "\r\n" );
|
4381 |
+
}
|
4382 |
+
fseek( $f, 0 );
|
4383 |
+
header( 'Content-Type: application/csv' );
|
4384 |
+
header( 'Content-Disposition: attachement; filename="' . $out . '";' );
|
4385 |
+
fpassthru( $f );
|
4386 |
}
|
4387 |
|
4388 |
/**
|
4389 |
* Parses content to add to a CSV file
|
4390 |
+
*
|
4391 |
+
* @param string $fp The open file
|
4392 |
+
* @param array $array The content to be added to the file
|
4393 |
+
* @param string $del Delimiter to use in the file
|
4394 |
+
* @param string $eol Content to be written to the file
|
4395 |
+
*
|
4396 |
* @return void
|
4397 |
*/
|
4398 |
+
function wplc_fputcsv_eol( $fp, $array, $del, $eol ) {
|
4399 |
+
fputcsv( $fp, $array, $del );
|
4400 |
+
if ( "\n\r" != $eol && 0 === fseek( $fp, - 1, SEEK_CUR ) ) {
|
4401 |
+
fwrite( $fp, $eol );
|
4402 |
+
}
|
4403 |
}
|
4404 |
|
4405 |
+
add_filter( "wplc_filter_typing_control_div", "wplc_filter_control_return_chat_response_box_before", 2, 1 );
|
4406 |
+
function wplc_filter_control_return_chat_response_box_before( $string ) {
|
4407 |
+
$string = $string . "<div class='typing_indicator wplc-color-1'></div>";
|
4408 |
|
4409 |
+
return $string;
|
4410 |
}
|
|
|
|
|
|
|
4411 |
|
4412 |
+
add_filter( "wplc_filter_typing_control_div_theme_2", "wplc_filter_control_return_chat_response_box_before_theme2", 2, 1 );
|
4413 |
+
function wplc_filter_control_return_chat_response_box_before_theme2( $string ) {
|
4414 |
+
$string = $string . "<div class='typing_indicator wplc-color-1'></div>";
|
4415 |
+
|
4416 |
+
return $string;
|
4417 |
}
|
4418 |
|
4419 |
|
4420 |
+
add_action( "wplc_hook_admin_settings_main_settings_after", "wplc_hook_control_admin_settings_chat_box_settings_after", 2 );
|
4421 |
/**
|
4422 |
* Adds the settings to allow the user to change their server environment variables
|
4423 |
+
* @return sring
|
4424 |
+
*/
|
4425 |
function wplc_hook_control_admin_settings_chat_box_settings_after() {
|
4426 |
+
$wplc_settings = wplc_get_options();
|
4427 |
+
$wplc_environment = intval( $wplc_settings["wplc_environment"] );
|
4428 |
?>
|
4429 |
+
<h4><?php _e( "Advanced settings", 'wp-live-chat-support' ) ?></h4>
|
4430 |
+
<table class='wp-list-table wplc_list_table widefat fixed striped pages' width='700'>
|
4431 |
+
<?php do_action( "wplc_advanced_settings_above_performance", $wplc_settings ); ?>
|
4432 |
+
</table>
|
4433 |
+
<table class='form-table wp-list-table wplc_list_table widefat fixed striped pages' width='700'>
|
4434 |
+
<tr>
|
4435 |
+
<td colspan='2'>
|
4436 |
+
<p>
|
4437 |
+
<em><small><?php _e( "Only change these settings if you are experiencing performance issues.", 'wp-live-chat-support' ); ?></small></em>
|
4438 |
+
</p>
|
4439 |
+
</td>
|
4440 |
+
</tr>
|
4441 |
+
</tr>
|
4442 |
+
<?php do_action( "wplc_advanced_settings_settings" ); ?>
|
4443 |
+
<tr>
|
4444 |
+
<td valign='top'>
|
4445 |
+
<?php _e( "Website hosting type:", 'wp-live-chat-support' ); ?>
|
4446 |
+
</td>
|
4447 |
+
<td valign='top'>
|
4448 |
+
<select name='wplc_environment' id='wplc_environment'>
|
4449 |
+
<option value='0' <?php if ( $wplc_environment == 0 ) {
|
4450 |
+
echo 'selected';
|
4451 |
+
} ?>><?php _e( "Custom parameters", 'wp-live-chat-support' ); ?></option>
|
4452 |
+
<option value='1' <?php if ( $wplc_environment == 1 ) {
|
4453 |
+
echo 'selected';
|
4454 |
+
} ?>><?php _e( "Shared hosting - low level plan", 'wp-live-chat-support' ); ?></option>
|
4455 |
+
<option value='2' <?php if ( $wplc_environment == 2 ) {
|
4456 |
+
echo 'selected';
|
4457 |
+
} ?>><?php _e( "Shared hosting - normal plan", 'wp-live-chat-support' ); ?></option>
|
4458 |
+
<option value='3' <?php if ( $wplc_environment == 3 ) {
|
4459 |
+
echo 'selected';
|
4460 |
+
} ?>><?php _e( "VPS", 'wp-live-chat-support' ); ?></option>
|
4461 |
+
<option value='4' <?php if ( $wplc_environment == 4 ) {
|
4462 |
+
echo 'selected';
|
4463 |
+
} ?>><?php _e( "Dedicated server", 'wp-live-chat-support' ); ?></option>
|
4464 |
+
</select>
|
4465 |
+
</td>
|
4466 |
+
</tr>
|
4467 |
+
<tr>
|
4468 |
+
<td valign='top'>
|
4469 |
+
<?php _e( "Long poll setup", 'wp-live-chat-support' ); ?>: <i
|
4470 |
+
class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip"
|
4471 |
+
title="<?php _e( "Only change these if you are an experienced developer or if you have received these figures from the WP Live Chat by 3CX team.", 'wp-live-chat-support' ) ?>"></i>
|
4472 |
+
</td>
|
4473 |
+
<td valign='top'>
|
4474 |
+
<table>
|
4475 |
<tr>
|
4476 |
+
<td><?php _e( "Iterations", 'wp-live-chat-support' ); ?></td>
|
4477 |
+
<td><input id="wplc_iterations" name="wplc_iterations" type="number" max='20000'
|
4478 |
+
min='1' <?php if ( $wplc_environment > 0 ) {
|
4479 |
+
echo 'readonly';
|
4480 |
+
} ?> value="<?php echo $wplc_settings['wplc_iterations']; ?>"/></td>
|
4481 |
</tr>
|
4482 |
<tr>
|
4483 |
+
<td><?php _e( "Sleep between loops", 'wp-live-chat-support' ); ?></td>
|
4484 |
+
<td>
|
4485 |
+
<input id="wplc_delay_between_loops" name="wplc_delay_between_loops" type="number"
|
4486 |
+
max='1000000' min='1' <?php if ( $wplc_environment > 0 ) {
|
4487 |
+
echo 'readonly';
|
4488 |
+
} ?> value="<?php echo floor( $wplc_settings['wplc_delay_between_loops'] / 1000 ); ?>"/>
|
4489 |
+
<small><em><?php _e( "milliseconds", 'wp-live-chat-support' ); ?></em></small>
|
4490 |
+
</td>
|
4491 |
+
</tr>
|
4492 |
+
</table>
|
4493 |
|
4494 |
+
</td>
|
4495 |
+
</tr>
|
4496 |
|
4497 |
+
</table>
|
4498 |
+
<?php
|
4499 |
}
|
4500 |
|
4501 |
+
add_action( 'wplc_hook_admin_settings_main_settings_after', 'wplc_powered_by_link_settings_page', 2 );
|
4502 |
/**
|
4503 |
* Adds the necessary checkbox to enable/disable the 'Powered by' link
|
4504 |
* @return string
|
4505 |
*/
|
4506 |
function wplc_powered_by_link_settings_page() {
|
4507 |
+
$wplc_powered_by = get_option( "WPLC_POWERED_BY" );
|
4508 |
+
?>
|
4509 |
<table class='form-table wp-list-table wplc_list_table widefat fixed striped pages' width='700'>
|
4510 |
<tr>
|
4511 |
<td width='350' valign='top'>
|
4512 |
+
<?php _e( "Show 'Powered by' in chat box", 'wp-live-chat-support' ) ?>: <i
|
4513 |
+
class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip"
|
4514 |
+
title="<?php _e( "Checking this will display a 'Powered by WP Live Chat by 3CX' caption at the bottom of your chatbox.", 'wp-live-chat-support' ); ?>"></i>
|
4515 |
</td>
|
4516 |
<td>
|
4517 |
+
<input type="checkbox" value="1"
|
4518 |
+
name="wplc_powered_by" <?php if ( $wplc_powered_by && $wplc_powered_by == 1 ) {
|
4519 |
+
echo "checked";
|
4520 |
+
} ?> />
|
4521 |
</td>
|
4522 |
</tr>
|
4523 |
</table>
|
4524 |
+
<?php
|
4525 |
}
|
4526 |
|
4527 |
add_action( "wplc_hook_head", "wplc_powered_by_link_save_settings" );
|
4529 |
* Saves the 'Powered by' link settings
|
4530 |
* @return void
|
4531 |
*/
|
4532 |
+
function wplc_powered_by_link_save_settings() {
|
4533 |
|
4534 |
+
if ( isset( $_POST['wplc_save_settings'] ) ) {
|
4535 |
|
4536 |
+
if ( isset( $_POST['wplc_powered_by'] ) && $_POST['wplc_powered_by'] == '1' ) {
|
4537 |
+
update_option( "WPLC_POWERED_BY", 1 );
|
4538 |
+
} else {
|
4539 |
+
update_option( "WPLC_POWERED_BY", 0 );
|
4540 |
+
}
|
4541 |
|
4542 |
}
|
4543 |
|
4546 |
add_filter( "wplc_start_chat_user_form_after_filter", "wplc_powered_by_link_in_chat", 12, 1 );
|
4547 |
/**
|
4548 |
* Appends the 'Powered by' link to the chat window
|
4549 |
+
*
|
4550 |
+
* @param string $string the current contents of the chat box
|
4551 |
+
* @param int $cid the current chat ID
|
4552 |
+
*
|
4553 |
+
* @return string the chat contents, with the 'Powered by' link appended to it
|
4554 |
*/
|
4555 |
+
function wplc_powered_by_link_in_chat( $string ) {
|
4556 |
|
4557 |
$show_powered_by = get_option( "WPLC_POWERED_BY" );
|
4558 |
|
4559 |
+
if ( $show_powered_by == 1 ) {
|
4560 |
|
4561 |
+
$ret = "<i style='text-align: center; display: block; padding: 5px 0; font-size: 10px;'><a href='https://www.3cx.com/wp-live-chat/?utm_source=poweredby&utm_medium=click&utm_campaign=" . wp_filter_post_kses( site_url() ) . "'' target='_BLANK' rel='nofollow'>" . __( "Powered by WP Live Chat by 3CX", 'wp-live-chat-support' ) . "</a></i>";
|
4562 |
|
4563 |
} else {
|
4564 |
|
4576 |
* @return void
|
4577 |
*/
|
4578 |
function wplc_custom_scripts_scripts() {
|
4579 |
+
if ( isset( $_GET['page'] ) ) {
|
4580 |
+
if ( $_GET['page'] == 'wplivechat-menu-settings' ) {
|
4581 |
+
wp_enqueue_script( "wplc-custom-script-tab-ace", WPLC_PLUGIN_URL . 'js/vendor/ace/ace.js', array( 'jquery' ), WPLC_PLUGIN_VERSION );
|
4582 |
+
} else if ( $_GET['page'] == 'wplivechat-menu-dashboard' || $_GET['page'] == 'wplivechat-menu' ) {
|
4583 |
+
wplc_register_common_node();
|
4584 |
+
wp_enqueue_script( 'wplc-custom-script-dashboard', WPLC_PLUGIN_URL . 'js/wplc_dashboard.js', array( 'jquery' ), WPLC_PLUGIN_VERSION, true );
|
4585 |
+
wp_localize_script( 'wplc-custom-script-dashboard', 'nifty_api_key', wplc_node_server_token_get() );
|
4586 |
+
} else if ( $_GET['page'] == 'wplivechat-menu-history' ) {
|
4587 |
+
wp_enqueue_script( 'wplc-custom-script-history', WPLC_PLUGIN_URL . 'js/wplc_history.js', array( 'jquery' ), WPLC_PLUGIN_VERSION, true );
|
4588 |
+
wp_localize_script( 'wplc-custom-script-history', 'tcx_messages', array(
|
4589 |
+
'historydeleteconfirm' => __( 'Do you really want to delete all chats?', 'wp-live-chat-support' )
|
4590 |
+
) );
|
4591 |
+
}
|
4592 |
+
}
|
4593 |
}
|
4594 |
|
4595 |
add_filter( "wplc_offline_message_subject_filter", "wplc_change_offline_message", 10, 1 );
|
4596 |
/**
|
4597 |
* Adds a filter to change the email address to the user's preference
|
4598 |
+
*
|
4599 |
+
* @param string $subject The default subject
|
4600 |
+
*
|
4601 |
* @return string
|
4602 |
*/
|
4603 |
+
function wplc_change_offline_message( $subject ) {
|
4604 |
|
4605 |
$wplc_settings = wplc_get_options();
|
4606 |
|
4607 |
+
if ( isset( $wplc_settings['wplc_pro_chat_email_offline_subject'] ) ) {
|
4608 |
$subject = stripslashes( $wplc_settings['wplc_pro_chat_email_offline_subject'] );
|
4609 |
}
|
4610 |
|
4615 |
add_filter( 'wplc_filter_active_chat_box_notification', 'wplc_active_chat_box_notice' );
|
4616 |
add_action( "wplc_hook_chat_dashboard_above", "wplc_active_chat_box_notices" );
|
4617 |
function wplc_active_chat_box_notices() {
|
4618 |
+
echo apply_filters( 'wplc_filter_active_chat_box_notice', '' );
|
4619 |
}
|
4620 |
|
4621 |
/*
|
4622 |
* Returns the WDT emoji selector
|
4623 |
*/
|
4624 |
+
function wplc_emoji_selector_div() {
|
4625 |
$wplc_settings = wplc_get_options();
|
4626 |
|
4627 |
+
if ( $wplc_settings['wplc_disable_emojis'] || ! $wplc_settings['wplc_use_node_server'] ) {
|
4628 |
return;
|
4629 |
+
}
|
4630 |
|
4631 |
+
return '<div class="wdt-emoji-popup">
|
4632 |
<a href="#" class="wdt-emoji-popup-mobile-closer"> × </a>
|
4633 |
<div class="wdt-emoji-menu-content">
|
4634 |
<div id="wdt-emoji-menu-header">
|
4674 |
*/
|
4675 |
function wplc_browser_notifications_admin_warning() {
|
4676 |
|
4677 |
+
if ( ! is_ssl() && isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu-settings' ) {
|
4678 |
|
4679 |
+
if ( isset( $_GET['wplc_dismiss_notice_bn'] ) && 'true' === $_GET['wplc_dismiss_notice_bn'] ) {
|
4680 |
|
4681 |
+
update_option( 'wplc_dismiss_notice_bn', 'true' );
|
4682 |
|
4683 |
+
}
|
4684 |
|
4685 |
+
if ( get_option( 'wplc_dismiss_notice_bn' ) !== 'true' ) {
|
4686 |
|
4687 |
+
?>
|
4688 |
<div class="notice notice-warning is-dismissible">
|
4689 |
+
<p><img src="<?php echo sanitize_text_field( wplc_plugins_url( '/images/wplc-logo.png', __FILE__ ) ); ?>"
|
4690 |
+
style="width:260px;height:auto;max-width:100%;"></p>
|
4691 |
+
<p>
|
4692 |
+
<strong><?php _e( 'Browser notifications will no longer function on insecure (non-SSL) sites.', 'wp-live-chat-support' ); ?></strong>
|
4693 |
+
</p>
|
4694 |
+
<p><?php _e( 'Please add an SSL certificate to your site to continue receiving chat notifications in your browser.', 'wp-live-chat-support' ); ?></p>
|
4695 |
+
<p><a href="?page=<?php echo sanitize_text_field( $_GET['page'] ); ?>&wplc_dismiss_notice_bn=true"
|
4696 |
+
id="wplc_dismiss_notice_bn"
|
4697 |
+
class="button"><?php _e( "Don't Show This Again", 'wp-live-chat-support' ); ?></a></p>
|
4698 |
</div>
|
4699 |
+
<?php
|
4700 |
|
4701 |
+
}
|
4702 |
+
}
|
4703 |
}
|
4704 |
|
4705 |
if ( function_exists( 'wplc_et_first_run_check' ) ) {
|
4706 |
add_action( 'admin_notices', 'wplc_transcript_admin_notice' );
|
4707 |
}
|
4708 |
function wplc_transcript_admin_notice() {
|
4709 |
+
printf( '<div class="notice notice-info">%1$s</div>', __( 'Please deactivate WP Live Chat Suport - Email Transcript plugin. Since WP Live Chat Support 8.0.05 there is build in support for Email Transcript.', 'wp-live-chat-support' ) );
|
4710 |
}
|
4711 |
|
4712 |
add_action( 'wplc_hook_admin_visitor_info_display_after', 'wplc_transcript_add_admin_button' );
|
4713 |
function wplc_transcript_add_admin_button( $cid ) {
|
4714 |
+
$wplc_settings = wplc_get_options();
|
4715 |
+
if ( $wplc_settings['wplc_enable_transcripts'] ) {
|
4716 |
+
echo "<a href=\"javascript:void(0);\" cid='" . esc_attr( $cid ) . "' class=\"wplc_admin_email_transcript button button-secondary\" id=\"wplc_admin_email_transcript\">" . __( "Email transcript to user", 'wp-live-chat-support' ) . "</a>";
|
4717 |
}
|
4718 |
}
|
4719 |
|
4720 |
add_action( 'wplc_hook_admin_javascript_chat', 'wplc_transcript_admin_javascript' );
|
4721 |
function wplc_transcript_admin_javascript() {
|
4722 |
$wplc_et_ajax_nonce = wp_create_nonce( "wplc_et_nonce" );
|
4723 |
+
wp_register_script( 'wplc_transcript_admin', wplc_plugins_url( '/js/wplc_transcript.js', __FILE__ ), array(), WPLC_PLUGIN_VERSION, true );
|
4724 |
$wplc_transcript_localizations = array(
|
4725 |
'ajax_nonce' => $wplc_et_ajax_nonce,
|
4726 |
+
'string_loading' => __( "Sending transcript...", 'wp-live-chat-support' ),
|
4727 |
+
'string_title' => __( "Sending Transcript", 'wp-live-chat-support' ),
|
4728 |
+
'string_close' => __( "Close", 'wp-live-chat-support' ),
|
4729 |
+
'string_chat_emailed' => __( "The chat transcript has been emailed.", 'wp-live-chat-support' ),
|
4730 |
+
'string_error1' => __( "There was a problem emailing the chat.", 'wp-live-chat-support' )
|
4731 |
);
|
4732 |
wp_localize_script( 'wplc_transcript_admin', 'wplc_transcript_nonce', $wplc_transcript_localizations );
|
4733 |
wp_enqueue_script( 'wplc_transcript_admin' );
|
4735 |
|
4736 |
add_action( 'wp_ajax_wplc_et_admin_email_transcript', 'wplc_transcript_callback' );
|
4737 |
function wplc_transcript_callback() {
|
4738 |
+
$check = check_ajax_referer( 'wplc_et_nonce', 'security' );
|
4739 |
+
if ( $check == 1 ) {
|
4740 |
+
if ( isset( $_POST['el'] ) && $_POST['el'] === 'endChat' ) {
|
4741 |
+
$wplc_settings = wplc_get_options();
|
4742 |
+
if ( ! $wplc_settings['wplc_send_transcripts_when_chat_ends'] ) { // TODO: check if this works, should execute next block to send transcript
|
4743 |
+
wp_die();
|
4744 |
+
}
|
4745 |
+
}
|
4746 |
+
|
4747 |
+
if ( $_POST['action'] == "wplc_et_admin_email_transcript" ) {
|
4748 |
+
if ( isset( $_POST['cid'] ) ) {
|
4749 |
+
$cid = wplc_return_chat_id_by_rel_or_id( $_POST['cid'] );
|
4750 |
+
echo json_encode( wplc_send_transcript( $cid ) );
|
4751 |
+
} else {
|
4752 |
+
echo json_encode( array( "error" => "no CID" ) );
|
4753 |
+
}
|
4754 |
+
wp_die();
|
4755 |
+
}
|
4756 |
+
wp_die();
|
4757 |
+
}
|
4758 |
+
wp_die();
|
4759 |
}
|
4760 |
|
4761 |
function wplc_send_transcript( $cid ) {
|
4762 |
+
if ( ! $cid ) {
|
4763 |
+
return array( "error" => "no CID", "cid" => $cid );
|
4764 |
+
}
|
4765 |
+
$cid = wplc_return_chat_id_by_rel_or_id( $cid );
|
4766 |
+
$email = false;
|
4767 |
+
$wplc_settings = wplc_get_options();
|
4768 |
+
|
4769 |
+
if ( $wplc_settings['wplc_enable_transcripts'] ) {
|
4770 |
+
if ( function_exists( "wplc_get_chat_data" ) ) {
|
4771 |
+
$cdata = wplc_get_chat_data( $cid );
|
4772 |
+
if ( $cdata ) {
|
4773 |
+
if ( $wplc_settings['wplc_send_transcripts_to'] === 'admin' ) {
|
4774 |
+
$user = wp_get_current_user();
|
4775 |
+
$email = $user->user_email;
|
4776 |
+
} else {
|
4777 |
+
$email = $cdata->email;
|
4778 |
+
}
|
4779 |
+
if ( ! $email ) {
|
4780 |
+
return array( "error" => "no email" );
|
4781 |
+
}
|
4782 |
+
} else {
|
4783 |
+
return array( "error" => "no chat data" );
|
4784 |
+
}
|
4785 |
+
} else {
|
4786 |
+
return array( "error" => "basic function missing" );
|
4787 |
+
}
|
4788 |
+
|
4789 |
+
$headers = array( 'Content-Type: text/html; charset=UTF-8' );
|
4790 |
+
$subject = sprintf( __( 'Your chat transcript from %1$s', 'wp-live-chat-support' ), get_bloginfo( 'url' ) );
|
4791 |
+
wp_mail( $email, $subject, wplc_transcript_return_chat_messages( $cid ), $headers );
|
4792 |
+
}
|
4793 |
+
|
4794 |
+
return array( "success" => 1 );
|
4795 |
+
}
|
4796 |
+
|
4797 |
+
add_action( 'wplc_send_transcript_hook', 'wplc_send_transcript', 10, 1 );
|
4798 |
|
4799 |
function wplc_transcript_return_chat_messages( $cid ) {
|
4800 |
global $current_chat_id;
|
4801 |
+
$current_chat_id = $cid;
|
4802 |
+
$wplc_settings = wplc_get_options();
|
4803 |
+
$body = html_entity_decode( stripslashes( $wplc_settings['wplc_et_email_body'] ) );
|
4804 |
|
4805 |
+
if ( empty( $body ) ) {
|
4806 |
$body = do_shortcode( wplc_transcript_return_default_email_body() );
|
4807 |
} else {
|
4808 |
$body = do_shortcode( $body );
|
4809 |
}
|
4810 |
+
|
4811 |
return $body;
|
4812 |
}
|
4813 |
|
4881 |
add_action( 'wplc_hook_admin_settings_main_settings_after', 'wplc_hook_admin_transcript_settings' );
|
4882 |
function wplc_hook_admin_transcript_settings() {
|
4883 |
$wplc_settings = wplc_get_options();
|
4884 |
+
echo "<h3>" . __( "Chat Transcript Settings", 'wp-live-chat-support' ) . "</h3>";
|
4885 |
echo "<table class='form-table wp-list-table widefat fixed striped pages' width='700'>";
|
4886 |
echo " <tr>";
|
4887 |
+
echo " <td width='400' valign='top'>" . __( "Enable chat transcripts:", 'wp-live-chat-support' ) . "</td>";
|
4888 |
echo " <td>";
|
4889 |
+
echo " <input type=\"checkbox\" value=\"1\" name=\"wplc_enable_transcripts\" " . ( $wplc_settings['wplc_enable_transcripts'] ? ' checked' : '' );
|
4890 |
echo " />";
|
4891 |
echo " </td>";
|
4892 |
echo " </tr>";
|
4893 |
|
4894 |
echo " <tr>";
|
4895 |
+
echo " <td width='400' valign='top'>" . __( "Send transcripts to:", 'wp-live-chat-support' ) . "</td>";
|
4896 |
echo " <td>";
|
4897 |
echo " <select name=\"wplc_send_transcripts_to\">";
|
4898 |
echo " <option value=\"user\" ";
|
4899 |
if ( $wplc_settings['wplc_send_transcripts_to'] == 'user' ) {
|
4900 |
+
echo "selected";
|
4901 |
+
}
|
4902 |
+
echo ">" . __( "User", 'wp-live-chat-support' ) . "</option>";
|
4903 |
echo " <option value=\"admin\" ";
|
4904 |
if ( $wplc_settings['wplc_send_transcripts_to'] == 'admin' ) {
|
4905 |
echo "selected";
|
4906 |
}
|
4907 |
+
echo ">" . __( "Admin", 'wp-live-chat-support' ) . "</option>";
|
4908 |
echo " </select>";
|
4909 |
echo " </td>";
|
4910 |
echo " </tr>";
|
4911 |
|
4912 |
echo " <tr>";
|
4913 |
+
echo " <td width='400' valign='top'>" . __( "Send transcripts when chat ends:", 'wp-live-chat-support' ) . "</td>";
|
4914 |
echo " <td>";
|
4915 |
+
echo " <input type=\"checkbox\" value=\"1\" name=\"wplc_send_transcripts_when_chat_ends\" " . ( $wplc_settings['wplc_send_transcripts_when_chat_ends'] ? ' checked' : '' );
|
4916 |
echo " />";
|
4917 |
echo " </td>";
|
4918 |
echo " </tr>";
|
4919 |
|
4920 |
echo " <tr>";
|
4921 |
+
echo " <td width='400' valign='top'>" . __( "Email body", 'wp-live-chat-support' ) . "</td>";
|
4922 |
echo " <td>";
|
4923 |
echo " <textarea cols='85' rows='15' name=\"wplc_et_email_body\">";
|
4924 |
+
echo trim( html_entity_decode( stripslashes( $wplc_settings['wplc_et_email_body'] ) ) );
|
4925 |
echo " </textarea>";
|
4926 |
echo " </td>";
|
4927 |
echo " </tr>";
|
4928 |
|
4929 |
|
4930 |
echo " <tr>";
|
4931 |
+
echo " <td width='400' valign='top'>" . __( "Email header", 'wp-live-chat-support' ) . "</td>";
|
4932 |
echo " <td>";
|
4933 |
echo " <textarea cols='85' rows='5' name=\"wplc_et_email_header\">";
|
4934 |
+
echo trim( stripslashes( $wplc_settings['wplc_et_email_header'] ) );
|
4935 |
echo " </textarea>";
|
4936 |
echo " </td>";
|
4937 |
echo " </tr>";
|
4938 |
|
4939 |
echo " <tr>";
|
4940 |
+
echo " <td width='400' valign='top'>" . __( "Email footer", 'wp-live-chat-support' ) . "</td>";
|
4941 |
echo " <td>";
|
4942 |
echo " <textarea cols='85' rows='5' name=\"wplc_et_email_footer\">";
|
4943 |
+
echo trim( stripslashes( $wplc_settings['wplc_et_email_footer'] ) );
|
4944 |
echo " </textarea>";
|
4945 |
echo " </td>";
|
4946 |
echo " </tr>";
|
4947 |
echo "</table>";
|
4948 |
}
|
4949 |
|
4950 |
+
add_shortcode( 'wplc_et_transcript', 'wplc_transcript_get_transcript' );
|
4951 |
function wplc_transcript_get_transcript() {
|
4952 |
global $current_chat_id;
|
4953 |
$cid = $current_chat_id;
|
4956 |
$output_html = wplc_return_chat_messages( intval( $cid ), true );
|
4957 |
|
4958 |
// Remove empty documentation suggestions, and unneeded list items
|
4959 |
+
$output_html = str_replace( '<li></li>', '', $output_html );
|
4960 |
|
4961 |
return $output_html;
|
4962 |
} else {
|
4966 |
|
4967 |
add_shortcode( 'wplc_et_transcript_footer_text', 'wplc_transcript_get_footer_text' );
|
4968 |
function wplc_transcript_get_footer_text() {
|
4969 |
+
$wplc_settings = wplc_get_options();
|
4970 |
+
|
4971 |
+
return html_entity_decode( stripslashes( $wplc_settings['wplc_et_email_footer'] ) );
|
4972 |
}
|
4973 |
|
4974 |
add_shortcode( 'wplc_et_transcript_header_text', 'wplc_transcript_get_header_text' );
|
4975 |
function wplc_transcript_get_header_text() {
|
4976 |
+
$wplc_settings = wplc_get_options();
|
4977 |
|
4978 |
global $current_chat_id;
|
4979 |
$cid = $current_chat_id;
|
4980 |
|
4981 |
$from_email = "Unknown@unknown.com";
|
4982 |
+
$from_name = "User";
|
4983 |
if ( intval( $cid ) > 0 ) {
|
4984 |
$chat_data = wplc_get_chat_data( $cid );
|
4985 |
if ( isset( $chat_data->email ) ) {
|
4989 |
$from_name = $chat_data->name;
|
4990 |
}
|
4991 |
}
|
4992 |
+
|
4993 |
+
return "<h3>" . $from_name . " (" . $from_email . ")" . "</h3>" . html_entity_decode( stripslashes( $wplc_settings['wplc_et_email_header'] ) );
|
4994 |
}
|
4995 |
|
4996 |
function wplc_features_admin_js() {
|
4997 |
+
wp_register_script( 'wplc-admin-features', wplc_plugins_url( '/js/wplc_admin_pro_features.js', __FILE__ ), array( 'wplc-admin-chat-js' ), WPLC_PLUGIN_VERSION, true );
|
4998 |
+
wp_enqueue_script( 'wplc-admin-features' );
|
4999 |
}
|
5000 |
|
5001 |
// add_action('admin_notices', 'wplc_encryption_deprecated_notice');
|
5002 |
/**
|
5003 |
* Notice of doom
|
5004 |
+
*/
|
5005 |
+
function wplc_encryption_deprecated_notice() {
|
5006 |
+
if ( isset( $_GET['wplc_encryption_dismiss_notice'] ) ) {
|
5007 |
+
if ( wp_verify_nonce( $_GET['wplc_dismiss_nonce'], 'wplc_encrypt_note_nonce' ) ) {
|
5008 |
+
update_option( 'WPLC_ENCRYPT_DEPREC_NOTICE_DISMISSED', 'true' );
|
5009 |
+
}
|
5010 |
+
}
|
5011 |
+
|
5012 |
+
if ( isset( $_GET['page'] ) ) {
|
5013 |
+
if ( $_GET['page'] === 'wplivechat-menu-settings' ) {
|
5014 |
+
$encrypt_deprec_notice_dismissed = get_option( 'WPLC_ENCRYPT_DEPREC_NOTICE_DISMISSED', false );
|
5015 |
+
|
5016 |
+
if ( $encrypt_deprec_notice_dismissed === false || $encrypt_deprec_notice_dismissed === 'false' ) {
|
5017 |
+
$dismiss_nonce = wp_create_nonce( 'wplc_encrypt_note_nonce' );
|
5018 |
+
$encrypt_note = __( 'Please note, local message encryption and local server options will be deprecated in the next major release. All encryption and message delivery will handled by our external servers in future.', 'wp-live-chat-support' );
|
5019 |
+
|
5020 |
+
$output = "<div class='update-nag' style='margin-bottom: 5px;'>";
|
5021 |
+
$output .= "<strong>" . __( "Deprecation Notice - Message Encryption & Local Server", 'wp-live-chat-support' ) . "</strong><br>";
|
5022 |
+
$output .= "<p>" . $encrypt_note . "</p>";
|
5023 |
+
$output .= "<a class='button' href='?page=" . htmlspecialchars( sanitize_text_field( $_GET['page'] ) ) . "&wplc_encryption_dismiss_notice=true&wplc_dismiss_nonce=$dismiss_nonce'>" . __( "Dismiss", 'wp-live-chat-support' ) . "</a>";
|
5024 |
+
$output .= "</div>";
|
5025 |
+
echo $output;
|
5026 |
+
}
|
5027 |
+
}
|
5028 |
+
}
|
5029 |
}
|