WP Live Chat Support - Version 8.0.25

Version Description

It is highly recommended that you upgrade to WP Live Chat Support version 8.0.25 for stability reasons.

Download this release

Release Info

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

Code changes from version 8.0.24 to 8.0.25

includes/blocks/wplc-chat-box/block.js CHANGED
@@ -1,131 +1,131 @@
1
- /* BLOCK: WP Live Chat Support Chat Box */
2
-
3
- ( function() {
4
-
5
- var __ = wp.i18n.__;
6
- var el = wp.element.createElement;
7
- var children = wp.blocks.children;
8
- var registerBlockType = wp.blocks.registerBlockType;
9
-
10
- String.prototype.stripSlashes = function(){
11
- return this.replace(/\\(.)/mg, "$1");
12
- }
13
-
14
- var wplc_logo = ( wplc_settings.wplc_logo ) ? wplc_settings.wplc_logo : 'https://bleeper.io/app/assets/images/wplc_loading.png';
15
- var wplc_text = ( wplc_settings.wplc_text ) ? wplc_settings.wplc_text : 'Live Chat';
16
- var wplc_icon = ( wplc_settings.wplc_icon ) ? wplc_settings.wplc_icon : 'fa-commenting-o';
17
- var classes = ( wplc_settings.wplc_enabled == 0 ) ? ' disabled' : '';
18
- var icon_classes = ( wplc_settings.wplc_icon_enabled == 0 ) ? ' disabled' : '';
19
- var size_class = ' md';
20
- var default_template = '<!-- Default HTML --><div class="wplc_block"><span class="wplc_block_logo">{wplc_logo}</span><span class="wplc_block_text">{wplc_text}</span><span class="wplc_block_icon">{wplc_icon}</span></div>';
21
- var wplc_template = ( wplc_settings.wplc_custom_html ) ? wplc_settings.wplc_custom_html : default_template;
22
- wplc_template = wplc_template.stripSlashes();
23
-
24
- if ( wplc_settings.wplc_size == 1 ) {
25
- size_class = ' sm';
26
- } else if ( wplc_settings.wplc_size == 2 ) {
27
- size_class = ' md';
28
- } else if ( wplc_settings.wplc_size == 3 ) {
29
- size_class = ' lg';
30
- }
31
-
32
- var wplc_styles = {
33
- backgroundImage: 'url(' + wplc_logo + ')'
34
- }
35
-
36
- var placeholder_codes = ['wplc_logo', 'wplc_text', 'wplc_icon'],
37
- placeholder_values = ['<span class="wplc_block_logo" style="background-image: url(\'' + wplc_logo + '\');"></span>', wplc_text, '<i class="fa ' + wplc_icon + '"></i>'];
38
-
39
- for( var i = 0; i < placeholder_codes.length; i++ ) {
40
- wplc_template = wplc_template.replace(new RegExp('{' + placeholder_codes[i] + '}', 'gi'), placeholder_values[i]);
41
- }
42
-
43
- registerBlockType( 'wp-live-chat-support/wplc-chat-box', {
44
- title: __( 'WP Live Chat Trigger', 'WPLC' ),
45
- icon: 'format-chat',
46
- category: 'common',
47
-
48
- edit: function( props ) {
49
- output_wplc_block_logo = el(
50
- 'span',
51
- { className: 'wplc_block_logo',
52
- style: wplc_styles
53
- }
54
- );
55
- output_wplc_block_text = el(
56
- 'span',
57
- { className: 'wplc_block_text' },
58
- wplc_text
59
- );
60
-
61
- icon = el(
62
- 'i',
63
- { className: 'fa fa-commenting-o' }
64
- );
65
-
66
- output_wplc_block_icon = el(
67
- 'span',
68
- { className: 'wplc_block_icon' + icon_classes },
69
- icon
70
- );
71
-
72
- output = el(
73
- 'span',
74
- { className: 'wplc_block' + classes + size_class },
75
- output_wplc_block_logo,
76
- output_wplc_block_text,
77
- output_wplc_block_icon
78
- );
79
-
80
-
81
- return el(
82
- 'div',
83
- { id: 'wplc-chat-box',
84
- className: classes,
85
- dangerouslySetInnerHTML: { __html: wplc_template }
86
- },
87
- );
88
- },
89
-
90
- save: function( props ) {
91
- output_wplc_block_logo = el(
92
- 'span',
93
- { className: 'wplc_block_logo',
94
- style: wplc_styles
95
- }
96
- );
97
- output_wplc_block_text = el(
98
- 'span',
99
- { className: 'wplc_block_text' },
100
- wplc_text
101
- );
102
-
103
- icon = el(
104
- 'i',
105
- { className: 'fa fa-commenting-o' }
106
- );
107
-
108
- output_wplc_block_icon = el(
109
- 'span',
110
- { className: 'wplc_block_icon' + icon_classes },
111
- icon
112
- );
113
-
114
- output = el(
115
- 'span',
116
- { className: 'wplc_block' + classes + size_class },
117
- output_wplc_block_logo,
118
- output_wplc_block_text,
119
- output_wplc_block_icon
120
- );
121
-
122
- return el(
123
- 'div',
124
- { id: 'wplc-chat-box',
125
- className: classes,
126
- dangerouslySetInnerHTML: { __html: wplc_template }
127
- }
128
- );
129
- },
130
- } );
131
- })();
1
+ /* BLOCK: WP Live Chat Support Chat Box */
2
+
3
+ ( function() {
4
+
5
+ var __ = wp.i18n.__;
6
+ var el = wp.element.createElement;
7
+ var children = wp.blocks.children;
8
+ var registerBlockType = wp.blocks.registerBlockType;
9
+
10
+ String.prototype.stripSlashes = function(){
11
+ return this.replace(/\\(.)/mg, "$1");
12
+ }
13
+
14
+ var wplc_logo = ( wplc_settings.wplc_logo ) ? wplc_settings.wplc_logo : 'https://update.wp-livechat.com/remote_files/assets/images/wplc_loading.png';
15
+ var wplc_text = ( wplc_settings.wplc_text ) ? wplc_settings.wplc_text : 'Live Chat';
16
+ var wplc_icon = ( wplc_settings.wplc_icon ) ? wplc_settings.wplc_icon : 'fa-commenting-o';
17
+ var classes = ( wplc_settings.wplc_enabled == 0 ) ? ' disabled' : '';
18
+ var icon_classes = ( wplc_settings.wplc_icon_enabled == 0 ) ? ' disabled' : '';
19
+ var size_class = ' md';
20
+ var default_template = '<!-- Default HTML --><div class="wplc_block"><span class="wplc_block_logo">{wplc_logo}</span><span class="wplc_block_text">{wplc_text}</span><span class="wplc_block_icon">{wplc_icon}</span></div>';
21
+ var wplc_template = ( wplc_settings.wplc_custom_html ) ? wplc_settings.wplc_custom_html : default_template;
22
+ wplc_template = wplc_template.stripSlashes();
23
+
24
+ if ( wplc_settings.wplc_size == 1 ) {
25
+ size_class = ' sm';
26
+ } else if ( wplc_settings.wplc_size == 2 ) {
27
+ size_class = ' md';
28
+ } else if ( wplc_settings.wplc_size == 3 ) {
29
+ size_class = ' lg';
30
+ }
31
+
32
+ var wplc_styles = {
33
+ backgroundImage: 'url(' + wplc_logo + ')'
34
+ }
35
+
36
+ var placeholder_codes = ['wplc_logo', 'wplc_text', 'wplc_icon'],
37
+ placeholder_values = ['<span class="wplc_block_logo" style="background-image: url(\'' + wplc_logo + '\');"></span>', wplc_text, '<i class="fa ' + wplc_icon + '"></i>'];
38
+
39
+ for( var i = 0; i < placeholder_codes.length; i++ ) {
40
+ wplc_template = wplc_template.replace(new RegExp('{' + placeholder_codes[i] + '}', 'gi'), placeholder_values[i]);
41
+ }
42
+
43
+ registerBlockType( 'wp-live-chat-support/wplc-chat-box', {
44
+ title: __( 'WP Live Chat Trigger', 'WPLC' ),
45
+ icon: 'format-chat',
46
+ category: 'common',
47
+
48
+ edit: function( props ) {
49
+ output_wplc_block_logo = el(
50
+ 'span',
51
+ { className: 'wplc_block_logo',
52
+ style: wplc_styles
53
+ }
54
+ );
55
+ output_wplc_block_text = el(
56
+ 'span',
57
+ { className: 'wplc_block_text' },
58
+ wplc_text
59
+ );
60
+
61
+ icon = el(
62
+ 'i',
63
+ { className: 'fa fa-commenting-o' }
64
+ );
65
+
66
+ output_wplc_block_icon = el(
67
+ 'span',
68
+ { className: 'wplc_block_icon' + icon_classes },
69
+ icon
70
+ );
71
+
72
+ output = el(
73
+ 'span',
74
+ { className: 'wplc_block' + classes + size_class },
75
+ output_wplc_block_logo,
76
+ output_wplc_block_text,
77
+ output_wplc_block_icon
78
+ );
79
+
80
+
81
+ return el(
82
+ 'div',
83
+ { id: 'wplc-chat-box',
84
+ className: classes,
85
+ dangerouslySetInnerHTML: { __html: wplc_template }
86
+ },
87
+ );
88
+ },
89
+
90
+ save: function( props ) {
91
+ output_wplc_block_logo = el(
92
+ 'span',
93
+ { className: 'wplc_block_logo',
94
+ style: wplc_styles
95
+ }
96
+ );
97
+ output_wplc_block_text = el(
98
+ 'span',
99
+ { className: 'wplc_block_text' },
100
+ wplc_text
101
+ );
102
+
103
+ icon = el(
104
+ 'i',
105
+ { className: 'fa fa-commenting-o' }
106
+ );
107
+
108
+ output_wplc_block_icon = el(
109
+ 'span',
110
+ { className: 'wplc_block_icon' + icon_classes },
111
+ icon
112
+ );
113
+
114
+ output = el(
115
+ 'span',
116
+ { className: 'wplc_block' + classes + size_class },
117
+ output_wplc_block_logo,
118
+ output_wplc_block_text,
119
+ output_wplc_block_icon
120
+ );
121
+
122
+ return el(
123
+ 'div',
124
+ { id: 'wplc-chat-box',
125
+ className: classes,
126
+ dangerouslySetInnerHTML: { __html: wplc_template }
127
+ }
128
+ );
129
+ },
130
+ } );
131
+ })();
includes/blocks/wplc-chat-box/index.php CHANGED
@@ -1,242 +1,242 @@
1
- <?php
2
- /**
3
- * BLOCK: WP Live Chat Support Chat box
4
- */
5
-
6
- if ( ! defined( 'ABSPATH' ) ) {
7
- exit;
8
- }
9
-
10
- function wplc_gutenberg_block_settings() {
11
- add_filter('wplc_filter_setting_tabs','wplc_gutenberg_setting_tabs');
12
- add_action("wplc_hook_settings_page_more_tabs","wplc_gutenberg_settings_content");
13
- }
14
-
15
- add_action('admin_init', 'wplc_gutenberg_block_settings');
16
-
17
- function wplc_gutenberg_setting_tabs($tab_array) {
18
- $tab_array['gutenberg'] = array(
19
- 'href' => '#tabs-gutenberg',
20
- 'icon' => 'fa fa-commenting-o',
21
- 'label' => __('Gutenberg Blocks', 'wplivechat')
22
- );
23
- return $tab_array;
24
- }
25
-
26
- function wplc_gutenberg_settings_content() {
27
- $gutenberg_settings = get_option('wplc_gutenberg_settings');
28
-
29
- $gutenberg_enable = ( $gutenberg_settings['wplc_gutenberg_enable'] !== null ) ? $gutenberg_settings['wplc_gutenberg_enable'] : 1;
30
- $checked = ( @$gutenberg_enable == 1 ? 'checked' : '' );
31
- $gutenberg_size = ( $gutenberg_settings['wplc_gutenberg_size'] ) ? $gutenberg_settings['wplc_gutenberg_size'] : 2;
32
- $gutenberg_defail_logo = 'https://bleeper.io/app/assets/images/wplc_loading.png';
33
- $gutenberg_logo = ( $gutenberg_settings['wplc_gutenberg_logo'] == '' ) ? $gutenberg_defail_logo : $gutenberg_settings['wplc_gutenberg_logo'];
34
- $gutenberg_text = ( $gutenberg_settings['wplc_gutenberg_text'] ) ? $gutenberg_settings['wplc_gutenberg_text'] : 'Live Chat';
35
- $gutenberg_icon = ( $gutenberg_settings['wplc_gutenberg_icon'] ) ? $gutenberg_settings['wplc_gutenberg_icon'] : 'fa-commenting-o';
36
- $gutenberg_enable_icon = ( $gutenberg_settings['wplc_gutenberg_enable_icon'] !== null ) ? $gutenberg_settings['wplc_gutenberg_enable_icon'] : 1;
37
- $icon_checked = ( @$gutenberg_enable_icon == 1 ? 'checked' : '' );
38
- $gutenberg_custom_html = ( $gutenberg_settings['wplc_custom_html'] ) ? $gutenberg_settings['wplc_custom_html'] : '';
39
- ?>
40
-
41
- <div id="tabs-gutenberg">
42
- <h3><?php _e('Gutenberg Blocks', 'wplivechat') ?></h3>
43
- <table class='form-table wp-list-table wplc_list_table widefat fixed striped pages'>
44
-
45
- <tr>
46
- <td width='300' valign='top'><?php _e('Enable Gutenberg Blocks', 'wplivechat') ?>:</td>
47
-
48
- <td>
49
- <input type="checkbox" id="activate_block" name="activate_block" <?php echo $checked ?>/>
50
- </td>
51
- </tr>
52
-
53
- <tr>
54
- <td width='300' valign='top'><?php _e('Gutenberg Block Size', 'wplivechat') ?>:</td>
55
- <td>
56
- <select id="wplc_gutenberg_size" name="wplc_gutenberg_size" value="1">
57
- <option <?php echo ($gutenberg_size == 1) ? 'selected' : ''; ?> value="1">Small</option>
58
- <option <?php echo ($gutenberg_size == 2) ? 'selected' : ''; ?> value="2">Medium</option>
59
- <option <?php echo ($gutenberg_size == 3) ? 'selected' : ''; ?> value="3">Large</option>
60
- </select>
61
- </td>
62
- </tr>
63
-
64
- <tr>
65
- <td width='300' valign='top'><?php _e('Block Logo', 'wplivechat') ?>:</td>
66
-
67
- <td>
68
- <input type="button" id="wplc_gutenberg_upload_logo" class="button button-primary" value="Upload Logo"/>
69
- <input type="button" id="wplc_gutenberg_remove_logo" class="button button-default" value="Reset Logo"/>
70
- <input type="hidden" id="wplc_gutenberg_default_logo" value="<?php echo $gutenberg_defail_logo; ?>" />
71
- <input type="hidden" id="wplc_gutenberg_logo" name="wplc_gutenberg_logo" value="<?php echo $gutenberg_logo; ?>"/>
72
- </td>
73
- </tr>
74
-
75
- <tr>
76
- <td width='300' valign='top'><?php _e('Block Text', 'wplivechat') ?>:</td>
77
-
78
- <td>
79
- <input type="text" id="wplc_gutenberg_text" name="wplc_gutenberg_text" placeholder="Block text" value="<?php echo $gutenberg_text ?>"/>
80
- </td>
81
- </tr>
82
-
83
- <tr>
84
- <td width='300' valign='top'><?php _e('Display Icon', 'wplivechat') ?>:<td>
85
- <input type="checkbox" id="wplc_gutenberg_enable_icon" name="wplc_gutenberg_enable_icon" <?php echo $icon_checked; ?>/>
86
- </td>
87
- </tr>
88
-
89
- <tr>
90
- <td width='300' valign='top'><?php _e('Block Icon', 'wplivechat') ?>:</td>
91
-
92
- <td>
93
- <input type="text" id="wplc_gutenberg_icon" name="wplc_gutenberg_icon" placeholder="Block icon" value="<?php echo $gutenberg_icon ?>"/>
94
- </td>
95
- </tr>
96
-
97
- <tr>
98
- <td width='300' valign='top'><?php _e("Block Preview", "wplivechat") ?>:</td>
99
-
100
- <td>
101
- <div id="wplc-chat-box" class="wplc_gutenberg_preview"></div>
102
- </td>
103
- </tr>
104
-
105
- <tr>
106
- <td width='300' valign='top'><?php _e('Custom HTML Template', 'wplivechat') ?>:
107
- <small><p><i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip"></i> You can use the following placeholders to add content dynamically:</p>
108
- <p><code class="wplc_code" title="Click to copy text">{wplc_logo}</code> - <?php _e('Displays the chosen logo', 'wplivechat'); ?></p>
109
- <p><code class="wplc_code" title="Click to copy text">{wplc_text}</code> - <?php _e('Displays the chosen custom text', 'wplivechat'); ?></p>
110
- <p><code class="wplc_code" title="Click to copy text">{wplc_icon}</code> - <?php _e('Displays the chosen icon', 'wplivechat'); ?></p></small>
111
- </td>
112
-
113
- <td>
114
- <div id='wplc_custom_html_editor'></div>
115
- <textarea name='wplc_custom_html' id='wplc_custom_html' style='display: none;' data-editor='css' rows='12'>
116
- <?php echo strip_tags( stripslashes( trim($gutenberg_custom_html))); ?>
117
- </textarea>
118
-
119
-
120
- <input type="button" id="wplc_gutenberg_reset_html" class="button button-default" value="Reset Default"/>
121
- <select id="wplc_custom_templates">
122
- <option selected value="0">Select a Template</option>
123
- <option value="template_default">Default - Dark</option>
124
- <option value="template_default_light">Default - Light</option>
125
- <option value="template_default_tooltip">Default - Tooltip</option>
126
- <option value="template_circle">Circle - Default</option>
127
- <option value="template_tooltip">Circle - Tooltip</option>
128
- <option value="template_circle_rotate">Circle - Rotating</option>
129
- <option value="template_chat_bubble">Chat Bubble</option>
130
-
131
- </select>
132
- </td>
133
- </tr>
134
- </table>
135
- </div>
136
-
137
- <?php
138
- }
139
-
140
- add_action('wplc_hook_admin_settings_save','wplc_gutenberg_save_settings');
141
-
142
- function wplc_gutenberg_save_settings() {
143
-
144
- if (isset($_POST['wplc_save_settings'])) {
145
-
146
- if (isset($_POST['activate_block'])) {
147
- $wplc_gutenberg_data['wplc_gutenberg_enable'] = 1;
148
- } else {
149
- $wplc_gutenberg_data['wplc_gutenberg_enable'] = 0;
150
- }
151
-
152
- if (isset($_POST['wplc_gutenberg_logo']) && $_POST['wplc_gutenberg_logo'] !== '0') {
153
- $wplc_gutenberg_data['wplc_gutenberg_logo'] = esc_attr($_POST['wplc_gutenberg_logo']);
154
- } else {
155
- $wplc_gutenberg_data['wplc_gutenberg_logo'] = 'https://bleeper.io/app/assets/images/wplc_loading.png';
156
- }
157
-
158
- if (isset($_POST['wplc_gutenberg_size']) && $_POST['wplc_gutenberg_size'] !== '0') {
159
- $wplc_gutenberg_data['wplc_gutenberg_size'] = esc_attr($_POST['wplc_gutenberg_size']);
160
- } else {
161
- $wplc_gutenberg_data['wplc_gutenberg_size'] = '2';
162
- }
163
-
164
- if (isset($_POST['wplc_gutenberg_text']) && $_POST['wplc_gutenberg_text'] !== '0') {
165
- $wplc_gutenberg_data['wplc_gutenberg_text'] = esc_attr($_POST['wplc_gutenberg_text']);
166
- } else {
167
- $wplc_gutenberg_data['wplc_gutenberg_text'] = 'Live Chat';
168
- }
169
-
170
- if (isset($_POST['wplc_gutenberg_icon']) && $_POST['wplc_gutenberg_icon'] !== '0') {
171
- $wplc_gutenberg_data['wplc_gutenberg_icon'] = esc_attr($_POST['wplc_gutenberg_icon']);
172
- } else {
173
- $wplc_gutenberg_data['wplc_gutenberg_icon'] = 'fa-commenting-o';
174
- }
175
-
176
- if (isset($_POST['wplc_gutenberg_enable_icon'])) {
177
- $wplc_gutenberg_data['wplc_gutenberg_enable_icon'] = 1;
178
- } else {
179
- $wplc_gutenberg_data['wplc_gutenberg_enable_icon'] = 0;
180
- }
181
-
182
- if (isset($_POST['wplc_custom_html']) && $_POST['wplc_custom_html'] !== '0') {
183
- $wplc_gutenberg_data['wplc_custom_html'] = esc_attr($_POST['wplc_custom_html']);
184
- } else {
185
- $default_html = '\n<div class="wplc_block">\n\t<span class="wplc_block_logo">{wplc_logo}</span>\n\t<span class="wplc_block_text">{wplc_text}</span>\n\t<span class="wplc_block_icon">{wplc_icon}</span>\n</div>';
186
-
187
- $wplc_gutenberg_data['wplc_custom_html'] = $default_html;
188
- }
189
-
190
- update_option('wplc_gutenberg_settings', $wplc_gutenberg_data);
191
- }
192
- }
193
-
194
- add_action( 'enqueue_block_editor_assets', 'wplc_chat_box_block_editor_assets' );
195
-
196
- function wplc_chat_box_block_editor_assets() {
197
- // Scripts
198
- wp_enqueue_script(
199
- 'wplc_chat_box',
200
- plugins_url( 'block.js', __FILE__ ),
201
- array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
202
- filemtime( plugin_dir_path( __FILE__ ) . 'block.js' )
203
- );
204
-
205
- $gutenberg_settings = get_option( 'wplc_gutenberg_settings' );
206
- $gutenberg_logo = $gutenberg_settings['wplc_gutenberg_logo'];
207
- $settings['wplc_typing'] = __("Type here","wplivechat");
208
- $settings['wplc_enabled'] = $gutenberg_settings['wplc_gutenberg_enable'];
209
- $settings['wplc_size'] = ( $gutenberg_settings['wplc_gutenberg_size'] ? esc_attr( $gutenberg_settings['wplc_gutenberg_size'] ) : 2 );
210
- $settings['wplc_logo'] = $gutenberg_logo;
211
- $settings['wplc_text'] = ( $gutenberg_settings['wplc_gutenberg_text'] ? esc_attr( $gutenberg_settings['wplc_gutenberg_text'] ) : __( 'Live Chat', 'wplivechat' ) );
212
-
213
- $settings['wplc_icon'] = ( $gutenberg_settings['wplc_gutenberg_icon'] ? esc_attr( $gutenberg_settings['wplc_gutenberg_icon'] ) : 'fa-commenting-o' );
214
- $settings['wplc_icon_enabled'] = $gutenberg_settings['wplc_gutenberg_enable_icon'];
215
- $settings['wplc_custom_html'] = $gutenberg_settings['wplc_custom_html'];
216
-
217
- wp_localize_script( 'wplc_chat_box', 'wplc_settings', $settings );
218
-
219
- // Styles
220
- wp_enqueue_style(
221
- 'wplc_chat_box-editor',
222
- plugins_url( 'editor.css', __FILE__ ),
223
- array( 'wp-edit-blocks' ),
224
- filemtime( plugin_dir_path( __FILE__ ) . 'editor.css' )
225
- );
226
- }
227
-
228
- add_action( 'enqueue_block_assets', 'wplc_chat_box_block_block_assets' );
229
-
230
- function wplc_chat_box_block_block_assets() {
231
- // Styles for front-end
232
- wp_enqueue_style(
233
- 'wplc_chat_box-front-end',
234
- plugins_url( 'style.css', __FILE__ ),
235
- array( 'wp-blocks' ),
236
- filemtime( plugin_dir_path( __FILE__ ) . 'style.css' )
237
- );
238
- wp_enqueue_style(
239
- 'wplc_chat_box-front-end-template', plugins_url( 'wplc_gutenberg_template_styles.css', __FILE__ ), array( 'wp-blocks' ),
240
- filemtime( plugin_dir_path( __FILE__ ) . 'wplc_gutenberg_template_styles.css' )
241
- );
242
- }
1
+ <?php
2
+ /**
3
+ * BLOCK: WP Live Chat Support Chat box
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit;
8
+ }
9
+
10
+ function wplc_gutenberg_block_settings() {
11
+ add_filter('wplc_filter_setting_tabs','wplc_gutenberg_setting_tabs');
12
+ add_action("wplc_hook_settings_page_more_tabs","wplc_gutenberg_settings_content");
13
+ }
14
+
15
+ add_action('admin_init', 'wplc_gutenberg_block_settings');
16
+
17
+ function wplc_gutenberg_setting_tabs($tab_array) {
18
+ $tab_array['gutenberg'] = array(
19
+ 'href' => '#tabs-gutenberg',
20
+ 'icon' => 'fa fa-commenting-o',
21
+ 'label' => __('Gutenberg Blocks', 'wplivechat')
22
+ );
23
+ return $tab_array;
24
+ }
25
+
26
+ function wplc_gutenberg_settings_content() {
27
+ $gutenberg_settings = get_option('wplc_gutenberg_settings');
28
+
29
+ $gutenberg_enable = ( $gutenberg_settings['wplc_gutenberg_enable'] !== null ) ? $gutenberg_settings['wplc_gutenberg_enable'] : 1;
30
+ $checked = ( @$gutenberg_enable == 1 ? 'checked' : '' );
31
+ $gutenberg_size = ( $gutenberg_settings['wplc_gutenberg_size'] ) ? $gutenberg_settings['wplc_gutenberg_size'] : 2;
32
+ $gutenberg_defail_logo = 'https://update.wp-livechat.com/remote_files/assets/images/wplc_loading.png';
33
+ $gutenberg_logo = ( $gutenberg_settings['wplc_gutenberg_logo'] == '' ) ? $gutenberg_defail_logo : $gutenberg_settings['wplc_gutenberg_logo'];
34
+ $gutenberg_text = ( $gutenberg_settings['wplc_gutenberg_text'] ) ? $gutenberg_settings['wplc_gutenberg_text'] : 'Live Chat';
35
+ $gutenberg_icon = ( $gutenberg_settings['wplc_gutenberg_icon'] ) ? $gutenberg_settings['wplc_gutenberg_icon'] : 'fa-commenting-o';
36
+ $gutenberg_enable_icon = ( $gutenberg_settings['wplc_gutenberg_enable_icon'] !== null ) ? $gutenberg_settings['wplc_gutenberg_enable_icon'] : 1;
37
+ $icon_checked = ( @$gutenberg_enable_icon == 1 ? 'checked' : '' );
38
+ $gutenberg_custom_html = ( $gutenberg_settings['wplc_custom_html'] ) ? $gutenberg_settings['wplc_custom_html'] : '';
39
+ ?>
40
+
41
+ <div id="tabs-gutenberg">
42
+ <h3><?php _e('Gutenberg Blocks', 'wplivechat') ?></h3>
43
+ <table class='form-table wp-list-table wplc_list_table widefat fixed striped pages'>
44
+
45
+ <tr>
46
+ <td width='300' valign='top'><?php _e('Enable Gutenberg Blocks', 'wplivechat') ?>:</td>
47
+
48
+ <td>
49
+ <input type="checkbox" id="activate_block" name="activate_block" <?php echo $checked ?>/>
50
+ </td>
51
+ </tr>
52
+
53
+ <tr>
54
+ <td width='300' valign='top'><?php _e('Gutenberg Block Size', 'wplivechat') ?>:</td>
55
+ <td>
56
+ <select id="wplc_gutenberg_size" name="wplc_gutenberg_size" value="1">
57
+ <option <?php echo ($gutenberg_size == 1) ? 'selected' : ''; ?> value="1">Small</option>
58
+ <option <?php echo ($gutenberg_size == 2) ? 'selected' : ''; ?> value="2">Medium</option>
59
+ <option <?php echo ($gutenberg_size == 3) ? 'selected' : ''; ?> value="3">Large</option>
60
+ </select>
61
+ </td>
62
+ </tr>
63
+
64
+ <tr>
65
+ <td width='300' valign='top'><?php _e('Block Logo', 'wplivechat') ?>:</td>
66
+
67
+ <td>
68
+ <input type="button" id="wplc_gutenberg_upload_logo" class="button button-primary" value="Upload Logo"/>
69
+ <input type="button" id="wplc_gutenberg_remove_logo" class="button button-default" value="Reset Logo"/>
70
+ <input type="hidden" id="wplc_gutenberg_default_logo" value="<?php echo $gutenberg_defail_logo; ?>" />
71
+ <input type="hidden" id="wplc_gutenberg_logo" name="wplc_gutenberg_logo" value="<?php echo $gutenberg_logo; ?>"/>
72
+ </td>
73
+ </tr>
74
+
75
+ <tr>
76
+ <td width='300' valign='top'><?php _e('Block Text', 'wplivechat') ?>:</td>
77
+
78
+ <td>
79
+ <input type="text" id="wplc_gutenberg_text" name="wplc_gutenberg_text" placeholder="Block text" value="<?php echo $gutenberg_text ?>"/>
80
+ </td>
81
+ </tr>
82
+
83
+ <tr>
84
+ <td width='300' valign='top'><?php _e('Display Icon', 'wplivechat') ?>:<td>
85
+ <input type="checkbox" id="wplc_gutenberg_enable_icon" name="wplc_gutenberg_enable_icon" <?php echo $icon_checked; ?>/>
86
+ </td>
87
+ </tr>
88
+
89
+ <tr>
90
+ <td width='300' valign='top'><?php _e('Block Icon', 'wplivechat') ?>:</td>
91
+
92
+ <td>
93
+ <input type="text" id="wplc_gutenberg_icon" name="wplc_gutenberg_icon" placeholder="Block icon" value="<?php echo $gutenberg_icon ?>"/>
94
+ </td>
95
+ </tr>
96
+
97
+ <tr>
98
+ <td width='300' valign='top'><?php _e("Block Preview", "wplivechat") ?>:</td>
99
+
100
+ <td>
101
+ <div id="wplc-chat-box" class="wplc_gutenberg_preview"></div>
102
+ </td>
103
+ </tr>
104
+
105
+ <tr>
106
+ <td width='300' valign='top'><?php _e('Custom HTML Template', 'wplivechat') ?>:
107
+ <small><p><i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip"></i> You can use the following placeholders to add content dynamically:</p>
108
+ <p><code class="wplc_code" title="Click to copy text">{wplc_logo}</code> - <?php _e('Displays the chosen logo', 'wplivechat'); ?></p>
109
+ <p><code class="wplc_code" title="Click to copy text">{wplc_text}</code> - <?php _e('Displays the chosen custom text', 'wplivechat'); ?></p>
110
+ <p><code class="wplc_code" title="Click to copy text">{wplc_icon}</code> - <?php _e('Displays the chosen icon', 'wplivechat'); ?></p></small>
111
+ </td>
112
+
113
+ <td>
114
+ <div id='wplc_custom_html_editor'></div>
115
+ <textarea name='wplc_custom_html' id='wplc_custom_html' style='display: none;' data-editor='css' rows='12'>
116
+ <?php echo strip_tags( stripslashes( trim($gutenberg_custom_html))); ?>
117
+ </textarea>
118
+
119
+
120
+ <input type="button" id="wplc_gutenberg_reset_html" class="button button-default" value="Reset Default"/>
121
+ <select id="wplc_custom_templates">
122
+ <option selected value="0">Select a Template</option>
123
+ <option value="template_default">Default - Dark</option>
124
+ <option value="template_default_light">Default - Light</option>
125
+ <option value="template_default_tooltip">Default - Tooltip</option>
126
+ <option value="template_circle">Circle - Default</option>
127
+ <option value="template_tooltip">Circle - Tooltip</option>
128
+ <option value="template_circle_rotate">Circle - Rotating</option>
129
+ <option value="template_chat_bubble">Chat Bubble</option>
130
+
131
+ </select>
132
+ </td>
133
+ </tr>
134
+ </table>
135
+ </div>
136
+
137
+ <?php
138
+ }
139
+
140
+ add_action('wplc_hook_admin_settings_save','wplc_gutenberg_save_settings');
141
+
142
+ function wplc_gutenberg_save_settings() {
143
+
144
+ if (isset($_POST['wplc_save_settings'])) {
145
+
146
+ if (isset($_POST['activate_block'])) {
147
+ $wplc_gutenberg_data['wplc_gutenberg_enable'] = 1;
148
+ } else {
149
+ $wplc_gutenberg_data['wplc_gutenberg_enable'] = 0;
150
+ }
151
+
152
+ if (isset($_POST['wplc_gutenberg_logo']) && $_POST['wplc_gutenberg_logo'] !== '0') {
153
+ $wplc_gutenberg_data['wplc_gutenberg_logo'] = esc_attr($_POST['wplc_gutenberg_logo']);
154
+ } else {
155
+ $wplc_gutenberg_data['wplc_gutenberg_logo'] = 'https://update.wp-livechat.com/remote_files/assets/images/wplc_loading.png';
156
+ }
157
+
158
+ if (isset($_POST['wplc_gutenberg_size']) && $_POST['wplc_gutenberg_size'] !== '0') {
159
+ $wplc_gutenberg_data['wplc_gutenberg_size'] = esc_attr($_POST['wplc_gutenberg_size']);
160
+ } else {
161
+ $wplc_gutenberg_data['wplc_gutenberg_size'] = '2';
162
+ }
163
+
164
+ if (isset($_POST['wplc_gutenberg_text']) && $_POST['wplc_gutenberg_text'] !== '0') {
165
+ $wplc_gutenberg_data['wplc_gutenberg_text'] = esc_attr($_POST['wplc_gutenberg_text']);
166
+ } else {
167
+ $wplc_gutenberg_data['wplc_gutenberg_text'] = 'Live Chat';
168
+ }
169
+
170
+ if (isset($_POST['wplc_gutenberg_icon']) && $_POST['wplc_gutenberg_icon'] !== '0') {
171
+ $wplc_gutenberg_data['wplc_gutenberg_icon'] = esc_attr($_POST['wplc_gutenberg_icon']);
172
+ } else {
173
+ $wplc_gutenberg_data['wplc_gutenberg_icon'] = 'fa-commenting-o';
174
+ }
175
+
176
+ if (isset($_POST['wplc_gutenberg_enable_icon'])) {
177
+ $wplc_gutenberg_data['wplc_gutenberg_enable_icon'] = 1;
178
+ } else {
179
+ $wplc_gutenberg_data['wplc_gutenberg_enable_icon'] = 0;
180
+ }
181
+
182
+ if (isset($_POST['wplc_custom_html']) && $_POST['wplc_custom_html'] !== '0') {
183
+ $wplc_gutenberg_data['wplc_custom_html'] = esc_attr($_POST['wplc_custom_html']);
184
+ } else {
185
+ $default_html = '\n<div class="wplc_block">\n\t<span class="wplc_block_logo">{wplc_logo}</span>\n\t<span class="wplc_block_text">{wplc_text}</span>\n\t<span class="wplc_block_icon">{wplc_icon}</span>\n</div>';
186
+
187
+ $wplc_gutenberg_data['wplc_custom_html'] = $default_html;
188
+ }
189
+
190
+ update_option('wplc_gutenberg_settings', $wplc_gutenberg_data);
191
+ }
192
+ }
193
+
194
+ add_action( 'enqueue_block_editor_assets', 'wplc_chat_box_block_editor_assets' );
195
+
196
+ function wplc_chat_box_block_editor_assets() {
197
+ // Scripts
198
+ wp_enqueue_script(
199
+ 'wplc_chat_box',
200
+ plugins_url( 'block.js', __FILE__ ),
201
+ array( 'wp-blocks', 'wp-i18n', 'wp-element' ),
202
+ filemtime( plugin_dir_path( __FILE__ ) . 'block.js' )
203
+ );
204
+
205
+ $gutenberg_settings = get_option( 'wplc_gutenberg_settings' );
206
+ $gutenberg_logo = $gutenberg_settings['wplc_gutenberg_logo'];
207
+ $settings['wplc_typing'] = __("Type here","wplivechat");
208
+ $settings['wplc_enabled'] = $gutenberg_settings['wplc_gutenberg_enable'];
209
+ $settings['wplc_size'] = ( $gutenberg_settings['wplc_gutenberg_size'] ? esc_attr( $gutenberg_settings['wplc_gutenberg_size'] ) : 2 );
210
+ $settings['wplc_logo'] = $gutenberg_logo;
211
+ $settings['wplc_text'] = ( $gutenberg_settings['wplc_gutenberg_text'] ? esc_attr( $gutenberg_settings['wplc_gutenberg_text'] ) : __( 'Live Chat', 'wplivechat' ) );
212
+
213
+ $settings['wplc_icon'] = ( $gutenberg_settings['wplc_gutenberg_icon'] ? esc_attr( $gutenberg_settings['wplc_gutenberg_icon'] ) : 'fa-commenting-o' );
214
+ $settings['wplc_icon_enabled'] = $gutenberg_settings['wplc_gutenberg_enable_icon'];
215
+ $settings['wplc_custom_html'] = $gutenberg_settings['wplc_custom_html'];
216
+
217
+ wp_localize_script( 'wplc_chat_box', 'wplc_settings', $settings );
218
+
219
+ // Styles
220
+ wp_enqueue_style(
221
+ 'wplc_chat_box-editor',
222
+ plugins_url( 'editor.css', __FILE__ ),
223
+ array( 'wp-edit-blocks' ),
224
+ filemtime( plugin_dir_path( __FILE__ ) . 'editor.css' )
225
+ );
226
+ }
227
+
228
+ add_action( 'enqueue_block_assets', 'wplc_chat_box_block_block_assets' );
229
+
230
+ function wplc_chat_box_block_block_assets() {
231
+ // Styles for front-end
232
+ wp_enqueue_style(
233
+ 'wplc_chat_box-front-end',
234
+ plugins_url( 'style.css', __FILE__ ),
235
+ array( 'wp-blocks' ),
236
+ filemtime( plugin_dir_path( __FILE__ ) . 'style.css' )
237
+ );
238
+ wp_enqueue_style(
239
+ 'wplc_chat_box-front-end-template', plugins_url( 'wplc_gutenberg_template_styles.css', __FILE__ ), array( 'wp-blocks' ),
240
+ filemtime( plugin_dir_path( __FILE__ ) . 'wplc_gutenberg_template_styles.css' )
241
+ );
242
+ }
includes/dashboard_page.php CHANGED
@@ -32,7 +32,7 @@
32
  </div>
33
  <div class="wplc_panel_col wplc_col_6">
34
  <div class="wplc_panel pull-right">
35
- <em style='dispaly:block; float:left; margin-top:0px; margin-right:5px;'>A product of </em><a href='https://bleeper.io/?utm_source=wplc&utm_medium=link&utm_campaign=dash' target='_BLANK' title='Bleeper.io' border='0'><img src='https://bleeper.io/assets/images/bleeper-logo.png' alt='Bleeper - A Customer Communication Tool for Startups and Founders' title='Bleeper - A Customer Communication Tool for Startups and Founders' border='0' style='height:20px;'/></a>
36
  </div>
37
  </div>
38
  </div>
@@ -83,7 +83,7 @@
83
 
84
 
85
  <div class="resp-container">
86
- <iframe onload="resizeIframe(this)" id="idIframe" class="resp-iframe" width="100%" height="1300" src="https://bleeper.io/app/external-dashboard/"></iframe>
87
  </div>
88
 
89
  </div>
32
  </div>
33
  <div class="wplc_panel_col wplc_col_6">
34
  <div class="wplc_panel pull-right">
35
+
36
  </div>
37
  </div>
38
  </div>
83
 
84
 
85
  <div class="resp-container">
86
+ <iframe onload="resizeIframe(this)" id="idIframe" class="resp-iframe" width="100%" height="1300" src="https://update.wp-livechat.com/remote_files/external-dashboard.php"></iframe>
87
  </div>
88
 
89
  </div>
includes/update_control.class.php CHANGED
@@ -48,7 +48,7 @@ final class wplc_update_control {
48
 
49
  public function activate() {
50
  $this->wplc_extension_string = $this->wplc_title;
51
- $this->wplc_api_url = 'https://ccplugins.co/api-control/';
52
 
53
 
54
  add_filter('pre_set_site_transient_update_plugins', array( $this, 'wplc_check_for_plugin_update' ));
@@ -94,7 +94,6 @@ final class wplc_update_control {
94
  // Start checking for an update
95
  $raw_response = wp_remote_post($this->wplc_api_url, $request_string);
96
 
97
-
98
  if (!is_wp_error($raw_response) && ($raw_response['response']['code'] == 200))
99
  $response = unserialize($raw_response['body']);
100
 
@@ -158,10 +157,6 @@ final class wplc_update_control {
158
  ));
159
  $response = wp_remote_post($this->wplc_api_url, $data_array);
160
 
161
-
162
-
163
-
164
-
165
  if (is_array($response)) {
166
  if ( $response['response']['code'] == "200" ) {
167
  $data = $response['body'];
48
 
49
  public function activate() {
50
  $this->wplc_extension_string = $this->wplc_title;
51
+ $this->wplc_api_url = 'https://update.wp-livechat.com/auth_api/api-control/';
52
 
53
 
54
  add_filter('pre_set_site_transient_update_plugins', array( $this, 'wplc_check_for_plugin_update' ));
94
  // Start checking for an update
95
  $raw_response = wp_remote_post($this->wplc_api_url, $request_string);
96
 
 
97
  if (!is_wp_error($raw_response) && ($raw_response['response']['code'] == 200))
98
  $response = unserialize($raw_response['body']);
99
 
157
  ));
158
  $response = wp_remote_post($this->wplc_api_url, $data_array);
159
 
 
 
 
 
160
  if (is_array($response)) {
161
  if ( $response['response']['code'] == "200" ) {
162
  $data = $response['body'];
includes/welcome_page.php CHANGED
@@ -1,160 +1,160 @@
1
- <?php //global $wpgmza_global_array; ?>
2
- <div class="wrap about-wrap">
3
- <p>&nbsp;</p>
4
- <h1 style='margin-right: 0;'><?php _e("Welcome to WP Live Chat Support v8","wplivechat"); ?> <div class="wplc-badge" style=' float: right; display: block; max-width: 20%; margin-left: 15%;'><img src='<?php echo WPLC_BASIC_PLUGIN_URL . "images/wplc-logo.png"; ?>' /></div></h1>
5
-
6
- <div class="about-text"><?php _e("WP Live Chat Support is the most cost effective, feature rich, amazingly supported and most positively reviewed live chat plugin on WordPress!","wplivechat"); ?></div>
7
-
8
- <a class="button-primary" style='padding:5px; padding-right:15px; padding-left:15px; height:inherit;' href="admin.php?page=wplivechat-menu&override=1"><?php echo __("Skip intro and start accepting chats","wplivechat"); ?></a>
9
- <p>&nbsp;</p>
10
-
11
- <?php
12
-
13
- if( !isset( $_GET['action'] ) ){
14
- $welcome_active = 'nav-tab-active';
15
- $credits_active = '';
16
- } else {
17
- if( $_GET['action'] == 'welcome' ){
18
- $welcome_active = 'nav-tab-active';
19
- $credits_active = '';
20
- } else if( $_GET['action'] == 'credits' ){
21
- $credits_active = 'nav-tab-active';
22
- $welcome_active = '';
23
- }
24
- }
25
-
26
- ?>
27
- <h2 class="nav-tab-wrapper wp-clearfix">
28
- <a href="admin.php?page=wplivechat-menu&action=welcome" class="nav-tab <?php echo $welcome_active; ?>"><?php _e("Welcome","wplivechat"); ?></a>
29
- <a href="admin.php?page=wplivechat-menu&action=credits" class="nav-tab <?php echo $credits_active; ?>"><?php _e("Credits","wplivechat"); ?></a>
30
-
31
- </h2>
32
- <?php if( !isset( $_GET['action'] ) || ( isset( $_GET['action'] ) && $_GET['action'] == 'welcome' ) ){ ?>
33
- <h2>What's new in Version 8?</h2>
34
- <center><img src='<?php echo WPLC_BASIC_PLUGIN_URL; ?>/images/performance.png' style='width:300px;' /></center>
35
- <div class="feature-section three-col">
36
- <div class="col">
37
- <div style='text-align: center;' ><i class="fa-4x fa fa-bolt" aria-hidden="true"></i><br/><h4><?php _e("Incredibly fast server","wplivechat"); ?></h4></div>
38
-
39
- <p style='text-align: center;'><?php _e("Use our server to handle the load and save 1000%+ on server resources!","wplivechat"); ?></p>
40
- </div>
41
- <div class="col">
42
- <div style='text-align: center;' ><i class="fa-4x fa fa-dashboard" aria-hidden="true"></i><br/><h4><?php _e("New Dashboard","wplivechat"); ?></h4></div>
43
- <p style='text-align: center;'><?php _e("Handle all your chats in one area, on any admin page.","wplivechat"); ?></p>
44
- </div>
45
- <div class="col">
46
- <div style='text-align: center;' ><i class="fa-4x far fa-smile" aria-hidden="true"></i><br/><h4><?php _e("Emojis!","wplivechat"); ?></h4></div>
47
- <p style='text-align: center;'><?php _e("Add a touch of your own personality with emojis!","wplivechat"); ?></p>
48
- </div>
49
- </div>
50
-
51
- <h2>New Pro features</h2>
52
- <div class="feature-section three-col">
53
- <div class="col">
54
- <div style='text-align: center;' ><i class="fa-4x fa fa-commenting-o" aria-hidden="true"></i><br/><h4><?php _e("Typing Preview","wplivechat"); ?></h4></div>
55
-
56
- <p style='text-align: center;'><?php _e("See what your customers are typing before they even send it!","wplivechat"); ?></p>
57
- </div>
58
- <div class="col">
59
- <div style='text-align: center;' ><i class="fa-4x fa fa-users" aria-hidden="true"></i><br/><h4><?php _e("Multiple Agents Per Chat","wplivechat"); ?></h4></div>
60
-
61
- <p style='text-align: center;'><?php _e("More than one agent can join and be involved in a chat.","wplivechat"); ?></p>
62
- </div>
63
- <div class="col">
64
- <div style='text-align: center;' ><i class="fa-4x fa fa-random" aria-hidden="true"></i><br/><h4><?php _e("Agent to Agent Chat","wplivechat"); ?></h4></div>
65
-
66
- <p style='text-align: center;'><?php _e( "Chat directly to other agents on our new dashboard.","wplivechat"); ?></p>
67
- </div>
68
- </div>
69
- <div class="feature-section three-col">
70
- <div class="col">
71
- <div style='text-align: center;' ><i class="fa-4x fa fa-eraser" aria-hidden="true"></i><br/><h4><?php _e("Edit Messages","wplivechat"); ?></h4></div>
72
-
73
- <p style='text-align: center;'><?php _e("Simply press the UP arrow or use the EDIT link to edit a message that you have already sent.","wplivechat"); ?></p>
74
- </div>
75
- <div class="col">
76
- <div style='text-align: center;' ><i class="fa-4x fa fa-heartbeat" aria-hidden="true"></i><br/><h4><?php _e("Event Monitoring","wplivechat"); ?></h4></div>
77
-
78
- <p style='text-align: center;'><?php _e("Know exactly what the user is doing in real time.","wplivechat"); ?></p>
79
- </div>
80
- <div class="col">
81
- <div style='text-align: center;' ><i class="fa-4x fa fa-apple" aria-hidden="true"></i><br/><h4><?php _e("iOS app","wplivechat"); ?></h4></div>
82
-
83
- <p style='text-align: center;'><?php _e( "The new iOS app is finally here!","wplivechat"); ?></p>
84
- </div>
85
- </div>
86
-
87
- <hr />
88
-
89
- <div class="feature-section normal clear" >
90
- <div class="changelog ">
91
- <!--<h2 style="font-size: 25px; text-align: left;"><?php _e('How did you find us?', 'wplivechat'); ?></h2>
92
- <form method="post" name="wplc_find_us_form" style="font-size: 16px;">
93
- <div style="text-align: left; width:275px;">
94
- <input type="radio" name="wplc_find_us" id="wordpress" value='repository'>
95
- <label for="wordpress">
96
- <?php _e('WordPress.org plugin repository ', 'wplivechat'); ?>
97
- </label>
98
- <br/>
99
- <input type='text' placeholder="<?php _e('Search Term', 'wplivechat'); ?>" name='wplc_nl_search_term' style='margin-top:5px; margin-left: 23px; width: 100% '>
100
- <br/>
101
- <input type="radio" name="wplc_find_us" id="search_engine" value='search_engine'>
102
- <label for="search_engine">
103
- <?php _e('Google or other search Engine', 'wplivechat'); ?>
104
- </label>
105
- <br/>
106
- <input type="radio" name="wplc_find_us" id="friend" value='friend'>
107
-
108
- <label for='friend'>
109
- <?php _e('Friend recommendation', 'wplivechat'); ?>
110
- </label>
111
- <br/>
112
- <input type="radio" name="wplc_find_us" id='other' value='other'>
113
-
114
- <label for='other'>
115
- <?php _e('Other', 'wplivechat'); ?>
116
- </label>
117
- <br/>
118
-
119
- <textarea placeholder="<?php _e('Please Explain', 'wplivechat'); ?>" style='margin-top:5px; margin-left: 23px; width: 100%' name='wplc_nl_findus_other_url'></textarea>
120
- </div>
121
- <div>
122
-
123
- </div>
124
- <div>
125
-
126
- </div>
127
- <div style='margin-top: 20px;'>
128
- <button name='action' value='wplc_submit_find_us' class="button-primary" style=""><?php _e('Submit', 'wplivechat'); ?></button> <a href='<?php echo admin_url("/admin.php?page=wplivechat-menu&override=1"); ?>'class="button"><?php _e('Skip', 'wplivechat'); ?></a>
129
- </div>
130
- </form>
131
- <br/><br/>
132
-
133
- <hr /> -->
134
-
135
- <div class="feature-section three-col">
136
- <div class='col'>
137
- <h4><?php _e("New to WP Live Chat Support?","wplivechat"); ?></h4>
138
- <p><?php _e("You may want to","wp-google-maps"); ?> <a href='https://wp-livechat.com/documentation/' target='_blank' title='Documentation'><?php _e("review our documentation","wplivechat"); ?></a> <?php _e("before you get started. If you're a tech-savvy individual, you may skip this step.","wplivechat"); ?></p>
139
- </div>
140
- <div class='col'>
141
- <h4><?php _e("Help me!","wplivechat"); ?></h4>
142
- <p><?php _e("Visit our","wplivechat"); ?> <a title='Support Desk' target='_blank' href='https://wp-livechat.com/contact-us/'><?php _e("Support Desk","wplivechat"); ?></a> <?php _e("for quick and friendly help. We'll answer your request within 24hours.","wplivechat"); ?></p>
143
- </div>
144
- <div class='col'>
145
- <h4><?php _e("Feedback","wp-google-maps"); ?></h4>
146
- <p><?php _e("We need you to help us make this plugin better.","wplivechat"); ?> <a href='https://wp-livechat.com/contact-us/' title='Feedback' target='_BLANK'><?php _e("Send us your feedback","wplivechat"); ?></a> <?php _e("and we'll act on it as soon as humanly possible.","wplivechat"); ?></p>
147
- </div>
148
- </div>
149
-
150
- <a class="button-primary" style='padding:5px; padding-right:15px; padding-left:15px; height:inherit;' href="admin.php?page=wplivechat-menu&override=1"><?php echo __("OK! Let's start","wplivechat"); ?></a>
151
-
152
- </div>
153
- </div>
154
-
155
- </div>
156
- <?php } else {
157
- $path = plugin_dir_path(__FILE__).'credits.php';
158
- include $path;
159
- }
160
  ?>
1
+ <?php //global $wpgmza_global_array; ?>
2
+ <div class="wrap about-wrap">
3
+ <p>&nbsp;</p>
4
+ <h1 style='margin-right: 0;'><?php _e("Welcome to WP Live Chat Support v8","wplivechat"); ?> <div class="wplc-badge" style=' float: right; display: block; max-width: 20%; margin-left: 15%;'><img src='<?php echo WPLC_BASIC_PLUGIN_URL . "images/wplc-logo.png"; ?>' /></div></h1>
5
+
6
+ <div class="about-text"><?php _e("WP Live Chat Support is the most cost effective, feature rich, amazingly supported and most positively reviewed live chat plugin on WordPress!","wplivechat"); ?></div>
7
+
8
+ <a class="button-primary" style='padding:5px; padding-right:15px; padding-left:15px; height:inherit;' href="admin.php?page=wplivechat-menu&override=1"><?php echo __("Skip intro and start accepting chats","wplivechat"); ?></a>
9
+ <p>&nbsp;</p>
10
+
11
+ <?php
12
+
13
+ if( !isset( $_GET['action'] ) ){
14
+ $welcome_active = 'nav-tab-active';
15
+ $credits_active = '';
16
+ } else {
17
+ if( $_GET['action'] == 'welcome' ){
18
+ $welcome_active = 'nav-tab-active';
19
+ $credits_active = '';
20
+ } else if( $_GET['action'] == 'credits' ){
21
+ $credits_active = 'nav-tab-active';
22
+ $welcome_active = '';
23
+ }
24
+ }
25
+
26
+ ?>
27
+ <h2 class="nav-tab-wrapper wp-clearfix">
28
+ <a href="admin.php?page=wplivechat-menu&action=welcome" class="nav-tab <?php echo $welcome_active; ?>"><?php _e("Welcome","wplivechat"); ?></a>
29
+ <a href="admin.php?page=wplivechat-menu&action=credits" class="nav-tab <?php echo $credits_active; ?>"><?php _e("Credits","wplivechat"); ?></a>
30
+
31
+ </h2>
32
+ <?php if( !isset( $_GET['action'] ) || ( isset( $_GET['action'] ) && $_GET['action'] == 'welcome' ) ){ ?>
33
+ <h2>What's new in Version 8?</h2>
34
+ <center><img src='<?php echo WPLC_BASIC_PLUGIN_URL; ?>/images/performance.png' style='width:300px;' /></center>
35
+ <div class="feature-section three-col">
36
+ <div class="col">
37
+ <div style='text-align: center;' ><i class="fa-4x fa fa-bolt" aria-hidden="true"></i><br/><h4><?php _e("Incredibly fast server","wplivechat"); ?></h4></div>
38
+
39
+ <p style='text-align: center;'><?php _e("Use our server to handle the load and save 1000%+ on server resources!","wplivechat"); ?></p>
40
+ </div>
41
+ <div class="col">
42
+ <div style='text-align: center;' ><i class="fa-4x fa fa-dashboard" aria-hidden="true"></i><br/><h4><?php _e("New Dashboard","wplivechat"); ?></h4></div>
43
+ <p style='text-align: center;'><?php _e("Handle all your chats in one area, on any admin page.","wplivechat"); ?></p>
44
+ </div>
45
+ <div class="col">
46
+ <div style='text-align: center;' ><i class="fa-4x fa fa-smile-o" aria-hidden="true"></i><br/><h4><?php _e("Emojis!","wplivechat"); ?></h4></div>
47
+ <p style='text-align: center;'><?php _e("Add a touch of your own personality with emojis!","wplivechat"); ?></p>
48
+ </div>
49
+ </div>
50
+
51
+ <h2>New Pro features</h2>
52
+ <div class="feature-section three-col">
53
+ <div class="col">
54
+ <div style='text-align: center;' ><i class="fa-4x fa fa-commenting-o" aria-hidden="true"></i><br/><h4><?php _e("Typing Preview","wplivechat"); ?></h4></div>
55
+
56
+ <p style='text-align: center;'><?php _e("See what your customers are typing before they even send it!","wplivechat"); ?></p>
57
+ </div>
58
+ <div class="col">
59
+ <div style='text-align: center;' ><i class="fa-4x fa fa-users" aria-hidden="true"></i><br/><h4><?php _e("Multiple Agents Per Chat","wplivechat"); ?></h4></div>
60
+
61
+ <p style='text-align: center;'><?php _e("More than one agent can join and be involved in a chat.","wplivechat"); ?></p>
62
+ </div>
63
+ <div class="col">
64
+ <div style='text-align: center;' ><i class="fa-4x fa fa-random" aria-hidden="true"></i><br/><h4><?php _e("Agent to Agent Chat","wplivechat"); ?></h4></div>
65
+
66
+ <p style='text-align: center;'><?php _e( "Chat directly to other agents on our new dashboard.","wplivechat"); ?></p>
67
+ </div>
68
+ </div>
69
+ <div class="feature-section three-col">
70
+ <div class="col">
71
+ <div style='text-align: center;' ><i class="fa-4x fa fa-eraser" aria-hidden="true"></i><br/><h4><?php _e("Edit Messages","wplivechat"); ?></h4></div>
72
+
73
+ <p style='text-align: center;'><?php _e("Simply press the UP arrow or use the EDIT link to edit a message that you have already sent.","wplivechat"); ?></p>
74
+ </div>
75
+ <div class="col">
76
+ <div style='text-align: center;' ><i class="fa-4x fa fa-heartbeat" aria-hidden="true"></i><br/><h4><?php _e("Event Monitoring","wplivechat"); ?></h4></div>
77
+
78
+ <p style='text-align: center;'><?php _e("Know exactly what the user is doing in real time.","wplivechat"); ?></p>
79
+ </div>
80
+ <div class="col">
81
+ <div style='text-align: center;' ><i class="fa-4x fa fa-apple" aria-hidden="true"></i><br/><h4><?php _e("iOS app","wplivechat"); ?></h4></div>
82
+
83
+ <p style='text-align: center;'><?php _e( "The new iOS app is finally here!","wplivechat"); ?></p>
84
+ </div>
85
+ </div>
86
+
87
+ <hr />
88
+
89
+ <div class="feature-section normal clear" >
90
+ <div class="changelog ">
91
+ <!--<h2 style="font-size: 25px; text-align: left;"><?php _e('How did you find us?', 'wplivechat'); ?></h2>
92
+ <form method="post" name="wplc_find_us_form" style="font-size: 16px;">
93
+ <div style="text-align: left; width:275px;">
94
+ <input type="radio" name="wplc_find_us" id="wordpress" value='repository'>
95
+ <label for="wordpress">
96
+ <?php _e('WordPress.org plugin repository ', 'wplivechat'); ?>
97
+ </label>
98
+ <br/>
99
+ <input type='text' placeholder="<?php _e('Search Term', 'wplivechat'); ?>" name='wplc_nl_search_term' style='margin-top:5px; margin-left: 23px; width: 100% '>
100
+ <br/>
101
+ <input type="radio" name="wplc_find_us" id="search_engine" value='search_engine'>
102
+ <label for="search_engine">
103
+ <?php _e('Google or other search Engine', 'wplivechat'); ?>
104
+ </label>
105
+ <br/>
106
+ <input type="radio" name="wplc_find_us" id="friend" value='friend'>
107
+
108
+ <label for='friend'>
109
+ <?php _e('Friend recommendation', 'wplivechat'); ?>
110
+ </label>
111
+ <br/>
112
+ <input type="radio" name="wplc_find_us" id='other' value='other'>
113
+
114
+ <label for='other'>
115
+ <?php _e('Other', 'wplivechat'); ?>
116
+ </label>
117
+ <br/>
118
+
119
+ <textarea placeholder="<?php _e('Please Explain', 'wplivechat'); ?>" style='margin-top:5px; margin-left: 23px; width: 100%' name='wplc_nl_findus_other_url'></textarea>
120
+ </div>
121
+ <div>
122
+
123
+ </div>
124
+ <div>
125
+
126
+ </div>
127
+ <div style='margin-top: 20px;'>
128
+ <button name='action' value='wplc_submit_find_us' class="button-primary" style=""><?php _e('Submit', 'wplivechat'); ?></button> <a href='<?php echo admin_url("/admin.php?page=wplivechat-menu&override=1"); ?>'class="button"><?php _e('Skip', 'wplivechat'); ?></a>
129
+ </div>
130
+ </form>
131
+ <br/><br/>
132
+
133
+ <hr /> -->
134
+
135
+ <div class="feature-section three-col">
136
+ <div class='col'>
137
+ <h4><?php _e("New to WP Live Chat Support?","wplivechat"); ?></h4>
138
+ <p><?php _e("You may want to","wp-google-maps"); ?> <a href='https://wp-livechat.com/documentation/' target='_blank' title='Documentation'><?php _e("review our documentation","wplivechat"); ?></a> <?php _e("before you get started. If you're a tech-savvy individual, you may skip this step.","wplivechat"); ?></p>
139
+ </div>
140
+ <div class='col'>
141
+ <h4><?php _e("Help me!","wplivechat"); ?></h4>
142
+ <p><?php _e("Visit our","wplivechat"); ?> <a title='Support Desk' target='_blank' href='https://wp-livechat.com/contact-us/'><?php _e("Support Desk","wplivechat"); ?></a> <?php _e("for quick and friendly help. We'll answer your request within 24hours.","wplivechat"); ?></p>
143
+ </div>
144
+ <div class='col'>
145
+ <h4><?php _e("Feedback","wp-google-maps"); ?></h4>
146
+ <p><?php _e("We need you to help us make this plugin better.","wplivechat"); ?> <a href='https://wp-livechat.com/contact-us/' title='Feedback' target='_BLANK'><?php _e("Send us your feedback","wplivechat"); ?></a> <?php _e("and we'll act on it as soon as humanly possible.","wplivechat"); ?></p>
147
+ </div>
148
+ </div>
149
+
150
+ <a class="button-primary" style='padding:5px; padding-right:15px; padding-left:15px; height:inherit;' href="admin.php?page=wplivechat-menu&override=1"><?php echo __("OK! Let's start","wplivechat"); ?></a>
151
+
152
+ </div>
153
+ </div>
154
+
155
+ </div>
156
+ <?php } else {
157
+ $path = plugin_dir_path(__FILE__).'credits.php';
158
+ include $path;
159
+ }
160
  ?>
js/wplc_dashboard.js CHANGED
@@ -1,5 +1,5 @@
1
  var wplcApiUrls = {
2
- blogFeedUrl: 'https://bleeper.io/blog/wp-json/wp/v2/posts',
3
  statusPageComponentsURL: 'https://bleeper.statuspage.io/api/v2/components.json',
4
  statusPageIncidentsURL: 'https://bleeper.statuspage.io/api/v2/incidents.json',
5
  visitorURL: 'https://bleeper-eu-1.eu-4.evennode.com/api/v1/total-visitors-online?api_key='+nifty_api_key
1
  var wplcApiUrls = {
2
+ blogFeedUrl: 'https://wp-livechat.com/wp-json/wp/v2/posts',
3
  statusPageComponentsURL: 'https://bleeper.statuspage.io/api/v2/components.json',
4
  statusPageIncidentsURL: 'https://bleeper.statuspage.io/api/v2/incidents.json',
5
  visitorURL: 'https://bleeper-eu-1.eu-4.evennode.com/api/v1/total-visitors-online?api_key='+nifty_api_key
js/wplc_server.js CHANGED
@@ -925,11 +925,11 @@ function wplc_push_message_to_chatbox(the_message, aoru, next) {
925
  var original_message = message_content;
926
  if (isAudioPattern) {
927
  message_content = "<a href='" + message_content + "' target='_blank'>" + (typeof wplc_visitor_voice !== 'undefined' && typeof wplc_visitor_voice.play_sound !== 'undefined' ? wplc_visitor_voice.play_sound : 'Open Voice Note') + "</a>";
928
- } else if (typeof niftyFormatParser !== "undefined"){
929
  if(typeof the_message.other !== 'undefined' && typeof the_message.other.ignore_style_tags !== 'undefined' && the_message.other.ignore_style_tags === true){
930
  //Don't nifty parse this
931
  } else {
932
- message_content = niftyFormatParser(message_content);
933
  }
934
  }
935
 
925
  var original_message = message_content;
926
  if (isAudioPattern) {
927
  message_content = "<a href='" + message_content + "' target='_blank'>" + (typeof wplc_visitor_voice !== 'undefined' && typeof wplc_visitor_voice.play_sound !== 'undefined' ? wplc_visitor_voice.play_sound : 'Open Voice Note') + "</a>";
928
+ } else if (typeof wplcFormatParser !== "undefined"){
929
  if(typeof the_message.other !== 'undefined' && typeof the_message.other.ignore_style_tags !== 'undefined' && the_message.other.ignore_style_tags === true){
930
  //Don't nifty parse this
931
  } else {
932
+ message_content = wplcFormatParser(message_content);
933
  }
934
  }
935
 
js/wplc_u.js CHANGED
@@ -1,976 +1,975 @@
1
- /*
2
- * Cookie Status
3
- *
4
- * 1 - complete - user has left site
5
- * 2 - pending - user waiting for chat to be answered by admin
6
- * 3 - active chat - user and admin are chatting
7
- * 4 - deleted
8
- * 5 - browsing - no data has been inputted
9
- * 6 - requesting chat - admin has requested a chat with user
10
- * 7 - timed out - visitor has timed out
11
- * 8 - complete but now browsing again
12
- * 9 - user closed chat before starting chat
13
- * 10 - user minimized active chat
14
- * 11 - user moved on to another page (session variable is different)
15
- * 12 - user has not been answered after sending chat request and is still active
16
- *
17
- */
18
- var wplc_is_chat_open = false;
19
- var wplc_online = false;
20
- var wplc_agent_name = "";
21
- var msg_history = new Array();
22
- var wplc_is_minimized = false; /* global to hold whether or not the chat box is minimized */
23
-
24
- var wplc_retry_interval = null;
25
-
26
- var wplc_run = true;
27
-
28
- var wplc_server = null;
29
- wplc_server = new WPLCServer();
30
-
31
- var wplc_server_last_loop_data = null;
32
-
33
- var wplc_shown_welcome = false;
34
-
35
- var wplc_current_agent = false;
36
-
37
- /* node support */
38
- var ns_obj = {};
39
-
40
-
41
- /* node variable mapping */
42
- var welcome_message = '';
43
-
44
- var wplc_session_variable = new Date().getTime();
45
- var wplc_cid;
46
- var wplc_check_hide_cookie;
47
- var wplc_chat_status = "";
48
- var wplc_cookie_name = "";
49
- var wplc_cookie_email = "";
50
- var wplc_init_chat_box_check = true;
51
- var wplc_cid = null;
52
-
53
- var initial_data = {};
54
- var wplc_fist_run = true;
55
- var wplc_long_poll_delay = 1500;
56
-
57
- jQuery(function() {
58
-
59
- /* Gutenberg functions */
60
- jQuery('.wp-block-wp-live-chat-support-wplc-chat-box').on('click',function(){
61
- jQuery("#wplc_hovercard").fadeOut("fast");
62
- jQuery("#wplc-chat-alert").removeClass('is-active');
63
- wplc_is_chat_open = true;
64
- jQuery.event.trigger({type: "wplc_open_chat"});
65
- });
66
-
67
- wplc_map_node_variables();
68
-
69
- /* preload the images */
70
- wplc_preload();
71
-
72
- wplc_cid = Cookies.get('wplc_cid');
73
-
74
- if(typeof wplc_cid === 'undefined'){
75
- wplc_cid = null;
76
- } else {
77
- wplc_cid = Cookies.get('wplc_cid');
78
- }
79
-
80
- wplc_check_hide_cookie = Cookies.get('wplc_hide');
81
- wplc_check_minimize_cookie = Cookies.get('wplc_minimize');
82
- wplc_chat_status = Cookies.get('wplc_chat_status');
83
- wplc_cookie_name = Cookies.get('wplc_name');
84
- wplc_cookie_email = Cookies.get('wplc_email');
85
- // Always start on 5 - ajax will then return chat status if active
86
-
87
- Cookies.set('wplc_chat_status', 5, { expires: 1, path: '/' });
88
- wplc_chat_status = 5;
89
- //if (typeof wplc_chat_status !== "undefined" && parseInt(wplc_chat_status) === 3) { } else {
90
-
91
- //}
92
-
93
- //Preflight check for WPML integration
94
- var wplc_wpml_body_language = jQuery("html").attr("lang");
95
- if(typeof wplc_wpml_body_language !== "undefined"){
96
- if(wplc_wpml_body_language.indexOf("-") !== -1){
97
- wplc_wpml_body_language = wplc_wpml_body_language.substr(0, wplc_wpml_body_language.indexOf("-"));
98
- }
99
- Cookies.set('_icl_current_language', wplc_wpml_body_language, { expires: 1, path: '/' });
100
- }
101
-
102
- var data = {
103
- action: 'wplc_get_chat_box',
104
- security: wplc_nonce,
105
- cid: wplc_cid
106
- };
107
-
108
- jQuery.ajax({
109
- url: wplc_ajaxurl_site,
110
- data:data,
111
- type:"POST",
112
- success: function(response) {
113
- /* inject html */
114
- if(response){
115
- if (response === "0") { if (window.console) { console.log('WP Live Chat Support Return Error'); } wplc_run = false; return; }
116
- response = JSON.parse(response);
117
-
118
-
119
- jQuery( "body" ).append( response['cbox']);
120
-
121
- wplc_listenForScrollEvent(jQuery("#wplc_chatbox"));
122
-
123
- if( typeof wplc_cookie_name == 'undefined' || typeof wplc_cookie_email == 'undefined' ){
124
-
125
- var wplc_cookie_name = jQuery( jQuery.parseHTML( response['cbox'] ) ).find( "#wplc_name" ).val();
126
- var wplc_cookie_email = jQuery( jQuery.parseHTML( response['cbox'] ) ).find( "#wplc_email" ).val();
127
-
128
- }
129
-
130
-
131
-
132
- /* is an agent online? */
133
- if (response['online'] === false) {
134
- wplc_run = false;
135
- wplc_online = false;
136
- ns_obj.o = '0';
137
-
138
- } else {
139
- wplc_online = true;
140
- ns_obj.o = '1';
141
- }
142
-
143
-
144
-
145
- if (wplc_filter_run_override !== "1" || wplc_online === false) { wplc_run = false; } else { /* we can run */ }
146
-
147
-
148
- /* has this user been assigned an agent? */
149
- if (typeof response['type'] === "undefined") {
150
- wplc_shown_welcome = false;
151
- } else {
152
- if (response['type'] === "returning") {
153
- wplc_shown_welcome = true;
154
- /* set the agent vars so we can access them on the fly */
155
- if (typeof response['agent_data'] !== "undefined") {
156
- wplc_current_agent = response['agent_data'];
157
- }
158
- } else {
159
- wplc_shown_welcome = false;
160
- }
161
-
162
- }
163
-
164
-
165
- /*Support mobile loggin*/
166
- var wplc_mobile_check = false;
167
- if(typeof wplc_is_mobile !== "undefined" && (wplc_is_mobile === "true" || wplc_is_mobile === true)){
168
- wplc_mobile_check = true;
169
- }
170
-
171
- /* start long polling */
172
- var data = {
173
- action: 'wplc_call_to_server_visitor',
174
- security: wplc_nonce,
175
- cid:wplc_cid,
176
- wplc_name: wplc_cookie_name,
177
- wplc_email: wplc_cookie_email,
178
- status:wplc_chat_status,
179
- wplcsession:wplc_session_variable,
180
- wplc_is_mobile: wplc_mobile_check,
181
- wplc_extra_data:wplc_extra_data
182
- };
183
-
184
- if(wplc_server.browserIsSocketReady()){
185
- data.socket = true;
186
-
187
- /* load node relay code */
188
- var nc = document.createElement("script");
189
- nc.type = "text/javascript";
190
- nc.async = true;
191
- nc.src = "https://bleeper.io/app/assets/js/bleeper-dev.js";
192
- //nc.src = "http://127.0.0.1/nick-bleeper-dev.js";
193
-
194
- document.getElementsByTagName("head")[0].appendChild(nc);
195
-
196
- }
197
-
198
- initial_data = data;
199
- // ajax long polling function
200
- if (wplc_filter_run_override !== "1" || wplc_online === false) {
201
-
202
- wplc_call_to_server_chat(data,true,true);
203
- } else {
204
-
205
- wplc_call_to_server_chat(data,true,false);
206
- }
207
-
208
- if(wplc_cid !== null && wplc_init_chat_box_check == true && wplc_init_chat_box !== false){
209
-
210
- wplc_init_chat_box(wplc_cid,wplc_chat_status);
211
- } else {
212
- //Node and offline
213
- if(typeof wplc_use_node_server !== "undefined" && (wplc_use_node_server === "true" || wplc_use_node_server === true)){
214
-
215
- if(wplc_check_hide_cookie != "yes"){
216
- wplc_dc = setTimeout(function (){
217
- wplc_cbox_animation();
218
- }, parseInt(window.wplc_delay));
219
- }
220
- }
221
- }
222
-
223
-
224
- }
225
-
226
- }
227
-
228
- });
229
-
230
- /**
231
- * Preload images from the localized variable
232
- * @return void
233
- */
234
- function wplc_preload() {
235
- var images = [];
236
- if (typeof wplc_preload_images !== "undefined" && typeof wplc_preload_images === "object" ) {
237
- var wplc_i = 0;
238
- for (var key in wplc_preload_images) {
239
- if (wplc_preload_images.hasOwnProperty(key)) {
240
- images[wplc_i] = new Image();
241
- images[wplc_i].src = wplc_preload_images[key];
242
- wplc_i++;
243
- }
244
- }
245
- }
246
- }
247
-
248
-
249
- /**
250
- * Detect if the chatbox is being scrolled.
251
- *
252
- * This had to be created as jQuery does not allow the scroll event to bubble up the DOM tree.
253
- *
254
- * Thank you Bikal Basnet (https://stackoverflow.com/questions/16505182/bind-scroll-event-to-dynamic-div)
255
- *
256
- * @param object el The element in question
257
- */
258
- function wplc_listenForScrollEvent(el) {
259
- el.on("scroll", function(){
260
- el.trigger("wplc-custom-scroll");
261
- })
262
-
263
- }
264
-
265
-
266
-
267
- jQuery("body").on('keyup', '#wplc_email, #wplc_name', function (e) {
268
- if (e.keyCode == 13) {
269
- jQuery("#wplc_start_chat_btn").trigger("click")
270
- }
271
- });
272
-
273
- jQuery("body").on("click", "#wplc_end_chat_button", function(e){
274
- var data = {
275
- security: wplc_nonce,
276
- chat_id: wplc_cid,
277
- agent_id: 0
278
- };
279
-
280
- wplc_rest_api('end_chat', data, 12000, null);
281
-
282
- jQuery.event.trigger({type: "wplc_end_chat_as_user"});
283
- });
284
-
285
- jQuery("body").on("click", "#wplc_gdpr_download_data_button", function(e){
286
- var wplc_init_nonce = jQuery(this).attr('data-wplc-init-nonce');
287
- var wplc_gdpr_last_cid = jQuery(this).attr('data-wplc-last-cid');
288
-
289
- if(typeof wplc_gdpr_last_cid !== 'undefined'){
290
- var reference_href = window.location.href;
291
- reference_href = reference_href.indexOf("?") !== -1 ? reference_href.substr(0, reference_href.indexOf("?")) : reference_href;
292
- var download_url = reference_href + "?wplc_action=wplc_gdpr_download_chat_json&wplc_cid=" + wplc_gdpr_last_cid + "&wplc_init_nonce=" + wplc_init_nonce;
293
- window.open(download_url);
294
- }
295
- });
296
-
297
- jQuery("body").on("click", "#wplc_gdpr_remove_data_button", function(e){
298
- var current_button = jQuery(this);
299
-
300
- var wplc_rest_nonce = current_button.attr('data-wplc-rest-nonce');
301
- var wplc_gdpr_rest_url = current_button.attr('data-wplc-rest-url');
302
- var wplc_gdpr_last_cid = current_button.attr('data-wplc-last-cid');
303
-
304
- current_button.text('Processing...');
305
-
306
- if(typeof wplc_gdpr_last_cid !== 'undefined'){
307
-
308
- jQuery.ajax({
309
- url: wplc_gdpr_rest_url + "/delete_chat",
310
- data: {
311
- wplc_cid: wplc_gdpr_last_cid,
312
- _wpnonce: wplc_rest_nonce
313
- },
314
- type:"POST",
315
- complete: function() {
316
- current_button.text('Complete');
317
- }
318
- });
319
- }
320
-
321
- });
322
-
323
- jQuery(document).on("wplc_update_gdpr_last_chat_id", function(e) {
324
- jQuery('#wplc_gdpr_remove_data_button,#wplc_gdpr_download_data_button').attr('data-wplc-last-cid', wplc_cid);
325
- });
326
-
327
-
328
-
329
- // Fix conflict with Responsive Lighbox plugin
330
- setTimeout(function () {
331
- if (jQuery('html').hasClass('nivo-lightbox-notouch') || jQuery('a[rel*="lightbox"]').length) {
332
- jQuery("body").on("keyup", function (event) {
333
- if (event.keyCode === 13) {
334
- jQuery("#wplc_send_msg").trigger("click");
335
- }
336
- });
337
- }
338
- }, 5000);
339
-
340
- if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
341
- setTimeout(function () {
342
- var liveChat4 = jQuery('#wp-live-chat-4');
343
- var liveChat = jQuery('#wp-live-chat');
344
- if (!liveChat.hasClass('classic')) {
345
- jQuery('body').on('click', function (event) {
346
- if (liveChat.hasClass('mobile-active')) {
347
- if (event.target.id !== 'wplc_chatmsg' && event.target.className !== 'wdt-emoji-picker') {
348
- liveChat4.removeClass('is-full-height');
349
- } else {
350
- liveChat4.addClass('is-full-height');
351
- }
352
- }
353
- });
354
- } else {
355
- jQuery('body').on('click', function (event) {
356
- if (liveChat.hasClass('mobile-active')) {
357
- if (event.target.id !== 'wplc_chatmsg' && event.target.className !== 'wdt-emoji-picker') {
358
- liveChat.removeClass('is-full-height');
359
- } else {
360
- liveChat.addClass('is-full-height');
361
- }
362
- }
363
- });
364
- }
365
- }, 500);
366
- }
367
- });
368
-
369
-
370
- function wplc_map_node_variables() {
371
- if (typeof wplc_welcome_msg !== "undefined") {
372
- welcome_message = wplc_welcome_msg;
373
- }
374
- }
375
-
376
- /**
377
- * This instantly sends the user the welcome message (i.e. to wait for any agent and start typing so long)
378
- *
379
- *
380
- */
381
- function wplc_send_welcome_message() {
382
- if(wplc_welcome_msg !== "" && !wplc_shown_welcome){
383
- message_class = "wplc_system_notification wplc-color-4";
384
- var concatenated_message = "<span class='" + message_class + "'>";
385
- concatenated_message += wplc_welcome_msg;
386
- concatenated_message += "</span>";
387
-
388
- if(typeof niftyFormatParser !== "undefined"){
389
- jQuery("#wplc_chatbox").append(niftyFormatParser(concatenated_message));
390
- } else{
391
- jQuery("#wplc_chatbox").append(concatenated_message);
392
- }
393
- wplc_scroll_to_bottom();
394
-
395
- wplc_shown_welcome = true;
396
- }
397
-
398
- }
399
-
400
- jQuery(function(){
401
- if (wplc_online) {
402
- jQuery(document).on('click', '#wp-live-chat-header', function() {
403
- jQuery('#speeching_button').html(wplc_pro_sst1);
404
- jQuery('#wplc_name').val(wplc_user_default_visitor_name);
405
- })
406
- } else {
407
- jQuery('#wplc_na_msg_btn').val(wplc_pro_offline_btn_send);
408
- }
409
- })
410
-
411
- /**
412
- * Scrolls the chat box to the bottom
413
- *
414
- */
415
- function wplc_scroll_to_bottom() {
416
- var height = jQuery('#wplc_chatbox')[0].scrollHeight;
417
- jQuery('#wplc_chatbox').scrollTop(height);
418
- }
419
-
420
-
421
-
422
- function wplc_user_message_receiver(data){
423
- if(typeof wplc_loop_response_handler !== "undefined" && typeof wplc_loop_response_handler === "function"){
424
- wplc_loop_response_handler(data, wplc_server_last_loop_data);
425
- data = JSON.parse(data);
426
- if(typeof data['status'] !== "undefined"){
427
- delete wplc_server_last_loop_data.status;
428
- }
429
-
430
- if(data.keep_alive === true){
431
-
432
- setTimeout(function(){
433
- wplc_server_last_loop_data.status = wplc_chat_status;
434
- wplc_call_to_server_chat(wplc_server_last_loop_data);
435
- },100);
436
- }
437
- }
438
- }
439
-
440
- function wplc_user_retry_handler(data){
441
- var tstatus = Cookies.get("wplc_chat_status");
442
-
443
- if (tstatus !== "undefined") {
444
- if(tstatus !== 8 || tstatus !== 1){
445
- wplc_retry_interval = setTimeout(function(){
446
-
447
- wplc_server.prepareTransport(function(){
448
- //Transport ready...
449
- wplc_server_last_loop_data.status = parseInt(tstatus); //Set to existing status
450
- wplc_call_to_server_chat(wplc_server_last_loop_data);
451
- }, wplc_user_message_receiver, wplc_user_retry_handler, wplc_log_connection_error);
452
-
453
-
454
- },500);
455
- }
456
-
457
- }
458
- }
459
-
460
- function wplc_call_to_server_chat(data,first_run,short_poll) {
461
-
462
- if (typeof wplc_use_node_server !== "undefined" && wplc_use_node_server === "true") {
463
- //not sending to WP
464
- return;
465
- } else {
466
-
467
-
468
- if (typeof first_run === "undefined") { first_run = false; };
469
- if (typeof short_poll === "undefined") { short_poll = false; };
470
- data.first_run = first_run;
471
- data.short_poll = short_poll;
472
-
473
- if(typeof Cookies.get('wplc_name') !== "undefined"){
474
- data.msg_from_print = Cookies.get('wplc_name');
475
- }
476
-
477
- wplc_server_last_loop_data = data;
478
-
479
- wplc_server.send(wplc_ajaxurl, data, "POST", 120000,
480
- function(response) {
481
- wplc_long_poll_delay = 1500;
482
- wplc_loop_response_handler(response, data);
483
- },
484
- function(jqXHR, exception) {
485
- wplc_long_poll_delay = 5000;
486
-
487
- if (jqXHR.status == 404) {
488
- wplc_log_connection_error('Error: Requested page not found. [404]');
489
- wplc_run = false;
490
- } else if (jqXHR.status == 500) {
491
- wplc_log_connection_error('Error: Internal Server Error [500].');
492
- wplc_log_connection_error('Retrying in 5 seconds...');
493
- wplc_run = true;
494
- } else if (exception === 'parsererror') {
495
- wplc_log_connection_error('Error: Requested JSON parse failed.');
496
- wplc_run = false;
497
- } else if (exception === 'abort') {
498
- wplc_log_connection_error('Error: Ajax request aborted.');
499
- wplc_run = false;
500
- } else {
501
- wplc_log_connection_error('Error: Uncaught Error.\n' + jqXHR.responseText);
502
- wplc_log_connection_error('Retrying in 5 seconds...');
503
- wplc_run = true;
504
- }
505
- },
506
- function(response){
507
- if (wplc_run) {
508
- if(wplc_server.isInSocketMode() === false && wplc_server.isPreparingSocketMode() === false){
509
- setTimeout(function() {
510
- wplc_call_to_server_chat(data,false,false);
511
- }, wplc_long_poll_delay);
512
- } else if ((wplc_server.isInSocketMode() === false && wplc_server.isPreparingSocketMode() === true) && (typeof wplc_transport_prepared !== "undefined" && wplc_transport_prepared === false)) {
513
- /* Allows for initiate chat to work on the node server */
514
- if (typeof wplc_use_node_server !== "undefined" && wplc_use_node_server === "true") {
515
- /* do not run this if using not the node jedi */
516
- setTimeout(function() {
517
- wplc_call_to_server_chat(data,false,true);
518
- }, 7500);
519
- }
520
- } else {
521
- if(typeof response !== "undefined" && typeof response.responseText !== "undefined" && response.responseText !== ""){
522
- var response_data = JSON.parse(response.responseText);
523
- if (typeof wplc_transport_prepared !== "undefined") {
524
- if(wplc_transport_prepared !== true && (parseInt(response_data.status) === 3 || parseInt(response_data.status) === 2)){
525
- //Transport is unprepared and the user has returned to the page with a status 3/2
526
- wplc_server.prepareTransport(function(){
527
- wplc_call_to_server_chat(data,false,false);
528
- }, wplc_user_message_receiver, wplc_user_retry_handler, wplc_log_connection_error);
529
- }
530
- }
531
- }
532
- }
533
- }
534
- }
535
- );
536
- }
537
-
538
- };
539
-
540
- function wplc_loop_response_handler(response, data){
541
- if(response){
542
- if (response === "0") { if (window.console) { console.log('WP Live Chat Support Return Error'); } wplc_run = false; return; }
543
- if (typeof response !== "object") {
544
- response = JSON.parse(response);
545
- }
546
-
547
- data['action_2'] = "";
548
- if(typeof response['wplc_name'] !== "undefined"){ data['wplc_name'] = response['wplc_name']; /* Cookies.set('wplc_name', response['wplc_name'], { expires: 1, path: '/' });*/ }
549
- if(typeof response['wplc_email'] !== "undefined"){ data['wplc_email'] = response['wplc_email']; /* Cookies.set('wplc_email', response['wplc_email'], { expires: 1, path: '/' }); */ }
550
- if(typeof response['cid'] !== "undefined"){ data['cid'] = response['cid']; Cookies.set('wplc_cid', response['cid'], { expires: 1, path: '/' }); }
551
- if(typeof response['aname'] !== "undefined") { wplc_agent_name = response['aname']; }
552
- if(typeof response['cid'] !== "undefined" && wplc_cid !== jQuery.trim(response['cid'])){ wplc_cid = jQuery.trim(response['cid']); jQuery("#wplc_cid").val(wplc_cid); }
553
- if(typeof response['status'] !== "undefined" && parseInt(wplc_chat_status) !== parseInt(response['status'])){
554
- wplc_chat_status = response['status'];
555
- Cookies.set('wplc_chat_status', null, { path: '/' });
556
- Cookies.set('wplc_chat_status', wplc_chat_status, { expires: 1, path: '/' });
557
- }
558
-
559
- /* Trigger for handling responses */
560
- jQuery.event.trigger({type: "wplc_user_chat_loop",response:response});
561
-
562
- /* Process status changes */
563
- if(data['status'] == response['status']){
564
-
565
- if(data['status'] == 5 && wplc_init_chat_box_check === true && wplc_init_chat_box !== false){ // open chat box on load
566
- wplc_init_chat_box(data['cid'], data['status']);
567
- }
568
- if((response['status'] == 3 || response['status'] == 2) && response['data'] != null){ // if active and data is returned
569
- wplc_run = true;
570
- var wplc_new_message_sound = false;
571
- if (typeof response['data'] === "object") {
572
-
573
- for (var index in response['data']) {
574
- if(typeof response['data'][index] !== "object"){
575
- if (typeof msg_history[index] === "undefined") {
576
- //Not from node
577
- /* we dont have this message */
578
- msg_history[index] = true;
579
-
580
- msg_to_parse = response['data'][index].wplcStripSlashes();
581
-
582
- if(typeof niftyFormatParser !== "undefined"){
583
- jQuery("#wplc_chatbox").append(niftyFormatParser(msg_to_parse));
584
- } else{
585
-
586
- jQuery("#wplc_chatbox").append(response['data'][index].wplcStripSlashes());
587
- }
588
-
589
- wplc_new_message_sound = true;
590
-
591
- } else {
592
- /* we already have this message */
593
- }
594
- } else {
595
- var the_message = response['data'][index];
596
- the_message.mid = index;
597
- wplc_push_message_to_chatbox(the_message,'u', function() {
598
- wplc_scroll_to_bottom();
599
- });
600
-
601
- wplc_new_message_sound = true;
602
- }
603
- }
604
- }
605
- else {
606
- /* backwards compatibility - response['data'] is a string */
607
- if(typeof niftyFormatParser !== "undefined"){
608
- jQuery("#wplc_chatbox").append(niftyFormatParser(response['data'].wplcStripSlashes()));
609
- } else{
610
- jQuery("#wplc_chatbox").append(response['data'].wplcStripSlashes());
611
-
612
- }
613
- wplc_new_message_sound = true;
614
- }
615
-
616
- if(wplc_new_message_sound){
617
- wplc_scroll_to_bottom();
618
- if (typeof wplc_enable_ding !== 'undefined' && wplc_enable_ding === "1") {
619
- new Audio(wplc_plugin_url+'ding.mp3').play();
620
- }
621
- }
622
- }
623
-
624
- } else {
625
- data['status'] = wplc_chat_status;
626
- Cookies.set('wplc_chat_status', wplc_chat_status, { expires: 1, path: '/' });
627
- if(response['status'] == 0 || response['status'] == 12){ // no answer from admin
628
- jQuery("#wp-live-chat-3").hide();
629
- if (typeof response['data'] !== "undefined") {
630
- jQuery("#wplc_chatbox").append(response['data'].wplcStripSlashes()+"<hr />");
631
- }
632
-
633
- }
634
- else if(response['status'] == 8){ // chat has been ended by admin
635
- wplc_run = false;
636
-
637
- document.getElementById('wplc_chatmsg').disabled = true;
638
- wplc_shown_welcome = false;
639
-
640
- the_message = wplc_generate_system_notification_object(wplc_error_messages.chat_ended_by_operator, {}, 0);
641
- wplc_push_message_to_chatbox(the_message,'u', function() {
642
- wplc_scroll_to_bottom();
643
- });
644
-
645
-
646
- /*
647
- if(typeof response['data'] === "object") {
648
- for (var index in response['data']) {
649
- if(typeof response['data'][index] === "object"){
650
-
651
- var the_message = response['data'][index];
652
- if(typeof the_message.originates !== "undefined"){
653
- var message_class = "";
654
- var message_content = "";
655
-
656
- if (parseInt(the_message.originates) === 0){
657
- //System Notification
658
- message_class = "wplc_system_notification wplc-color-4";
659
- message_content = the_message.msg;
660
- if(message_content !== ""){
661
- var concatenated_message = "<span class='" + message_class + "'>";
662
- concatenated_message += message_content;
663
- concatenated_message += "</span>";
664
-
665
- if(typeof niftyFormatParser !== "undefined"){
666
- jQuery("#wplc_chatbox").append(niftyFormatParser(concatenated_message));
667
- } else{
668
- jQuery("#wplc_chatbox").append(concatenated_message);
669
- }
670
- }
671
- }
672
- }
673
- }
674
- }
675
- } else {
676
- //Backwards Compat
677
- jQuery("#wplc_chatbox").append("<em>"+response['data']+"</em><br />");
678
- }*/
679
-
680
-
681
-
682
-
683
-
684
- jQuery.event.trigger({type: "wplc_end_chat"});
685
-
686
- }
687
- else if(parseInt(response['status']) == 11){ /* use moved on to another page (perhaps in another tab so close this instance */
688
- jQuery("#wp-live-chat").css({ "display" : "none" });
689
- wplc_run = false;
690
- }
691
- else if(parseInt(response['status']) == 3 || parseInt(response['status']) == 2 || parseInt(response['status']) == 10){ // re-initialize chat
692
- wplc_run = true;
693
- if(parseInt(response['status']) == 3) { // only if not minimized open aswell
694
- /* HERE NODE */
695
-
696
- if (typeof wplc_use_node_server !== "undefined" && wplc_use_node_server === "true") {
697
- /* do not run this if using not the node jedi */
698
-
699
- if (typeof wplc_transport_prepared !== "undefined" && wplc_transport_prepared === false) {
700
- wplc_server.prepareTransport(function(){
701
- wplc_call_to_server_chat(wplc_server_last_loop_data,false,false);
702
- }, wplc_user_message_receiver, wplc_user_retry_handler, wplc_log_connection_error);
703
- }
704
- }
705
- if (!wplc_is_minimized) {
706
- if (!wplc_is_chat_open) {
707
- wplc_cbox_animation();
708
- setTimeout(function() {
709
- open_chat(0);
710
- },1500);
711
- }
712
- }
713
-
714
-
715
- if(jQuery('#wp-live-chat').hasClass('wplc_left') === true || jQuery('#wp-live-chat').hasClass('wplc_right') === true){
716
- //jQuery('#wp-live-chat').height("400px");
717
- }
718
- }
719
- if(parseInt(response['status']) == 10) { // only if not minimized open aswell
720
- wplc_run = true;
721
- open_chat(0);
722
-
723
- }
724
- if(response['data'] != null){ // append messages to chat area
725
- if (typeof response['data'] === "object") {
726
-
727
- for (var index in response['data']) {
728
- wplc_new_message_sound = false;
729
- if(typeof response['data'][index] !== "object"){
730
-
731
- if (typeof msg_history[index] === "undefined") {
732
- /* we dont have this message */
733
- msg_history[index] = true;
734
- if(typeof niftyFormatParser !== "undefined"){
735
- jQuery("#wplc_chatbox").append(niftyFormatParser(response['data'][index].wplcStripSlashes()));
736
- } else{
737
- jQuery("#wplc_chatbox").append(response['data'][index].wplcStripSlashes());
738
- }
739
-
740
- wplc_new_message_sound = true;
741
- } else {
742
- /* we already have this message */
743
- }
744
- } else {
745
- var the_message = response['data'][index];
746
- the_message.mid = index;
747
- wplc_push_message_to_chatbox(the_message,'u', function() {
748
- wplc_scroll_to_bottom();
749
- });
750
-
751
-
752
- }
753
-
754
- if(wplc_new_message_sound){
755
- if (response['alert']) {
756
- jQuery('#wplc-chat-alert').addClass('is-active');
757
- }
758
- wplc_scroll_to_bottom();
759
- if (typeof wplc_enable_ding !== 'undefined' && wplc_enable_ding === "1") {
760
- new Audio(wplc_plugin_url+'ding.mp3').play();
761
- }
762
- }
763
- }
764
- }
765
- else {
766
- /* backwards compatibility - response['data'] is a string */
767
- if(typeof niftyFormatParser !== "undefined"){
768
- jQuery("#wplc_chatbox").append(niftyFormatParser(response['data'].wplcStripSlashes()));
769
- } else{
770
- jQuery("#wplc_chatbox").append(response['data'].wplcStripSlashes());
771
-
772
- }
773
- }
774
-
775
- if(response['data']){
776
- wplc_scroll_to_bottom();
777
-
778
- }
779
- }
780
- }
781
- }
782
- }
783
- }
784
-
785
-
786
-
787
- function wplc_log_connection_error(error){
788
- if (window.console) { console.log(error); }
789
-
790
- jQuery("#wplc_chatbox").append("<small>" + error + "</small><br>");
791
- wplc_scroll_to_bottom();
792
- }
793
-
794
- function wplc_display_error(error) {
795
-
796
- the_message = {};
797
- the_message.originates = 2;
798
- the_message.msg = error;
799
- the_message.other = {};
800
- var wplc_d = new Date();
801
- the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
802
- wplc_push_message_to_chatbox(the_message,'u', function() {
803
- wplc_scroll_to_bottom();
804
- });
805
-
806
-
807
-
808
- }
809
-
810
- var wplc_init_chat_box = function(cid, status){
811
- if(wplc_chat_status == 9 && wplc_check_hide_cookie == "yes"){
812
- } else if (wplc_chat_status === 3) {
813
- wplc_cbox_animation();
814
- } else {
815
-
816
- if(wplc_check_hide_cookie != "yes"){
817
- wplc_dc = setTimeout(function (){
818
- wplc_cbox_animation();
819
- }, parseInt(window.wplc_delay));
820
- }
821
- }
822
- wplc_init_chat_box = false;
823
- jQuery.event.trigger({type: "wplc_init_complete"});
824
- }
825
-
826
- function wplc_cbox_animation() {
827
- /*
828
- * 1- Slide Up
829
- * 2- Slide Across (Left/Right)
830
- * 3- Slide Down
831
- * 4- Fade In
832
- */
833
-
834
-
835
- var wplc_window_id = jQuery("#wp-live-chat");
836
-
837
- var wplc_theme_chosen = jQuery(wplc_window_id).attr('wplc_animation');
838
-
839
- switch(wplc_theme_chosen){
840
- case 'none':
841
- jQuery(wplc_window_id).css('display', 'block');
842
- break;
843
- case 'animation-1':
844
- // Slide Up
845
- jQuery(wplc_window_id).animate({'marginBottom' : '0px'}, 1000);
846
- break;
847
- case 'animation-2-bl':
848
- // Slide Accross from left
849
- jQuery(wplc_window_id).animate({'left' : '20px'}, 1000);
850
- break;
851
- case 'animation-2-br':
852
- // Slide Accross from right
853
- jQuery(wplc_window_id).animate({'right' : '20px'}, 1000);
854
- break;
855
- case 'animation-2-l':
856
- // Slide Accross from left
857
- jQuery(wplc_window_id).animate({"left" : '0px'}, 1000);
858
- break;
859
- case 'animation-2-r':
860
-
861
- // Slide Accross from right
862
- jQuery(wplc_window_id).animate({'right' : '0px'}, 1000);
863
- break;
864
- case 'animation-3':
865
- // Fade In
866
- jQuery(wplc_window_id).fadeIn('slow');
867
- case 'animation-4':
868
- jQuery(wplc_window_id).css('display', 'block');
869
- break;
870
- default:
871
- jQuery(wplc_window_id).css('display', 'block');
872
- break;
873
- }
874
-
875
- //jQuery("#wp-live-chat").css({ "display" : "block" });
876
- if(jQuery("#wp-live-chat").attr('wplc-auto-pop-up') === "1"){
877
-
878
- var wplc_force_must_min = Cookies.get('wplc_minimize');
879
- if(wplc_force_must_min === 'yes'){
880
- /* User has actively chosen to minimize the chat, leave it alone */
881
- } else {
882
- setTimeout(function(){
883
- open_chat(0);
884
- },1000);
885
- /**
886
- * Adding this fixes the bug that stops the chat window from opening when an agent initialises a chat with a user
887
- *
888
- * Reasoning: when running open_chat(), wplc_is_chat_open is set to TRUE at the end of the function, and stops any future request to open_chat();
889
- *
890
- */
891
- wplc_is_chat_open = false;
892
- }
893
- }
894
-
895
- jQuery.event.trigger({type: "wplc_animation_done"});
896
- }
897
-
898
-
899
- function wplc_sound(source,volume,loop) {
900
- this.source=source;
901
- this.volume=volume;
902
- this.loop=loop;
903
- var son;
904
- this.son=son;
905
- this.finish=false;
906
- this.stop=function()
907
- {
908
- document.body.removeChild(this.son);
909
- }
910
- this.start=function()
911
- {
912
- if(this.finish)return false;
913
- this.son=document.createElement("embed");
914
- this.son.setAttribute("src",this.source);
915
- this.son.setAttribute("hidden","true");
916
- this.son.setAttribute("volume",this.volume);
917
- this.son.setAttribute("autostart","true");
918
- this.son.setAttribute("loop",this.loop);
919
- document.body.appendChild(this.son);
920
- }
921
- this.remove=function()
922
- {
923
- document.body.removeChild(this.son);
924
- this.finish=true;
925
- }
926
- this.init=function(volume,loop)
927
- {
928
- this.finish=false;
929
- this.volume=volume;
930
- this.loop=loop;
931
- }
932
- }
933
-
934
-
935
- function wplc_strip(str) {
936
- str=str.replace(/<br>/gi, "\n");
937
- str=str.replace(/<p.*>/gi, "\n");
938
- str=str.replace(/<a.*href="(.*?)".*>(.*?)<\/a>/gi, " $2 ($1) ");
939
- str=str.replace(/<(?:.|\s)*?>/g, "");
940
-
941
- str=str.replace('iframe', "");
942
- str=str.replace('src', "");
943
- str=str.replace('href', "");
944
- str=str.replace('<', "");
945
- str=str.replace('>', "");
946
-
947
- /* remove the last carriage return from the text area output */
948
- str=str.replace(/\n$/, "")
949
-
950
- return str;
951
- }
952
-
953
- (function($) {
954
-
955
- $(function(event) {
956
-
957
- if(!window.wdtEmojiBundle)
958
- return;
959
-
960
- $(document.body).on("click", function(event) {
961
-
962
- // If click event isn't on the emoji window, or the emoji open button, close the emoji window
963
- if($(event.target).closest(".wdt-emoji-picker, .wdt-emoji-popup").length == 0 && !(
964
- event.target.parentNode == null && $(event.target).hasClass("fa-smile-o")
965
- ))
966
- wdtEmojiBundle.close();
967
-
968
- });
969
-
970
- // Close emoji window on scroll
971
- $(window).scroll(function(event) {
972
- wdtEmojiBundle.close();
973
- });
974
- });
975
-
976
- })(jQuery);
1
+ /*
2
+ * Cookie Status
3
+ *
4
+ * 1 - complete - user has left site
5
+ * 2 - pending - user waiting for chat to be answered by admin
6
+ * 3 - active chat - user and admin are chatting
7
+ * 4 - deleted
8
+ * 5 - browsing - no data has been inputted
9
+ * 6 - requesting chat - admin has requested a chat with user
10
+ * 7 - timed out - visitor has timed out
11
+ * 8 - complete but now browsing again
12
+ * 9 - user closed chat before starting chat
13
+ * 10 - user minimized active chat
14
+ * 11 - user moved on to another page (session variable is different)
15
+ * 12 - user has not been answered after sending chat request and is still active
16
+ *
17
+ */
18
+ var wplc_is_chat_open = false;
19
+ var wplc_online = false;
20
+ var wplc_agent_name = "";
21
+ var msg_history = new Array();
22
+ var wplc_is_minimized = false; /* global to hold whether or not the chat box is minimized */
23
+
24
+ var wplc_retry_interval = null;
25
+
26
+ var wplc_run = true;
27
+
28
+ var wplc_server = null;
29
+ wplc_server = new WPLCServer();
30
+
31
+ var wplc_server_last_loop_data = null;
32
+
33
+ var wplc_shown_welcome = false;
34
+
35
+ var wplc_current_agent = false;
36
+
37
+ /* node support */
38
+ var ns_obj = {};
39
+
40
+
41
+ /* node variable mapping */
42
+ var welcome_message = '';
43
+
44
+ var wplc_session_variable = new Date().getTime();
45
+ var wplc_cid;
46
+ var wplc_check_hide_cookie;
47
+ var wplc_chat_status = "";
48
+ var wplc_cookie_name = "";
49
+ var wplc_cookie_email = "";
50
+ var wplc_init_chat_box_check = true;
51
+ var wplc_cid = null;
52
+
53
+ var initial_data = {};
54
+ var wplc_fist_run = true;
55
+ var wplc_long_poll_delay = 1500;
56
+
57
+ jQuery(function() {
58
+
59
+ /* Gutenberg functions */
60
+ jQuery('.wp-block-wp-live-chat-support-wplc-chat-box').on('click',function(){
61
+ jQuery("#wplc_hovercard").fadeOut("fast");
62
+ jQuery("#wplc-chat-alert").removeClass('is-active');
63
+ wplc_is_chat_open = true;
64
+ jQuery.event.trigger({type: "wplc_open_chat"});
65
+ });
66
+
67
+ wplc_map_node_variables();
68
+
69
+ /* preload the images */
70
+ wplc_preload();
71
+
72
+ wplc_cid = Cookies.get('wplc_cid');
73
+
74
+ if(typeof wplc_cid === 'undefined'){
75
+ wplc_cid = null;
76
+ } else {
77
+ wplc_cid = Cookies.get('wplc_cid');
78
+ }
79
+
80
+ wplc_check_hide_cookie = Cookies.get('wplc_hide');
81
+ wplc_check_minimize_cookie = Cookies.get('wplc_minimize');
82
+ wplc_chat_status = Cookies.get('wplc_chat_status');
83
+ wplc_cookie_name = Cookies.get('wplc_name');
84
+ wplc_cookie_email = Cookies.get('wplc_email');
85
+ // Always start on 5 - ajax will then return chat status if active
86
+
87
+ Cookies.set('wplc_chat_status', 5, { expires: 1, path: '/' });
88
+ wplc_chat_status = 5;
89
+ //if (typeof wplc_chat_status !== "undefined" && parseInt(wplc_chat_status) === 3) { } else {
90
+
91
+ //}
92
+
93
+ //Preflight check for WPML integration
94
+ var wplc_wpml_body_language = jQuery("html").attr("lang");
95
+ if(typeof wplc_wpml_body_language !== "undefined"){
96
+ if(wplc_wpml_body_language.indexOf("-") !== -1){
97
+ wplc_wpml_body_language = wplc_wpml_body_language.substr(0, wplc_wpml_body_language.indexOf("-"));
98
+ }
99
+ Cookies.set('_icl_current_language', wplc_wpml_body_language, { expires: 1, path: '/' });
100
+ }
101
+
102
+ var data = {
103
+ action: 'wplc_get_chat_box',
104
+ security: wplc_nonce,
105
+ cid: wplc_cid
106
+ };
107
+
108
+ jQuery.ajax({
109
+ url: wplc_ajaxurl_site,
110
+ data:data,
111
+ type:"POST",
112
+ success: function(response) {
113
+ /* inject html */
114
+ if(response){
115
+ if (response === "0") { if (window.console) { console.log('WP Live Chat Support Return Error'); } wplc_run = false; return; }
116
+ response = JSON.parse(response);
117
+
118
+
119
+ jQuery( "body" ).append( response['cbox']);
120
+
121
+ wplc_listenForScrollEvent(jQuery("#wplc_chatbox"));
122
+
123
+ if( typeof wplc_cookie_name == 'undefined' || typeof wplc_cookie_email == 'undefined' ){
124
+
125
+ var wplc_cookie_name = jQuery( jQuery.parseHTML( response['cbox'] ) ).find( "#wplc_name" ).val();
126
+ var wplc_cookie_email = jQuery( jQuery.parseHTML( response['cbox'] ) ).find( "#wplc_email" ).val();
127
+
128
+ }
129
+
130
+
131
+
132
+ /* is an agent online? */
133
+ if (response['online'] === false) {
134
+ wplc_run = false;
135
+ wplc_online = false;
136
+ ns_obj.o = '0';
137
+
138
+ } else {
139
+ wplc_online = true;
140
+ ns_obj.o = '1';
141
+ }
142
+
143
+
144
+
145
+ if (wplc_filter_run_override !== "1" || wplc_online === false) { wplc_run = false; } else { /* we can run */ }
146
+
147
+
148
+ /* has this user been assigned an agent? */
149
+ if (typeof response['type'] === "undefined") {
150
+ wplc_shown_welcome = false;
151
+ } else {
152
+ if (response['type'] === "returning") {
153
+ wplc_shown_welcome = true;
154
+ /* set the agent vars so we can access them on the fly */
155
+ if (typeof response['agent_data'] !== "undefined") {
156
+ wplc_current_agent = response['agent_data'];
157
+ }
158
+ } else {
159
+ wplc_shown_welcome = false;
160
+ }
161
+
162
+ }
163
+
164
+
165
+ /*Support mobile loggin*/
166
+ var wplc_mobile_check = false;
167
+ if(typeof wplc_is_mobile !== "undefined" && (wplc_is_mobile === "true" || wplc_is_mobile === true)){
168
+ wplc_mobile_check = true;
169
+ }
170
+
171
+ /* start long polling */
172
+ var data = {
173
+ action: 'wplc_call_to_server_visitor',
174
+ security: wplc_nonce,
175
+ cid:wplc_cid,
176
+ wplc_name: wplc_cookie_name,
177
+ wplc_email: wplc_cookie_email,
178
+ status:wplc_chat_status,
179
+ wplcsession:wplc_session_variable,
180
+ wplc_is_mobile: wplc_mobile_check,
181
+ wplc_extra_data:wplc_extra_data
182
+ };
183
+
184
+ if(wplc_server.browserIsSocketReady()){
185
+ data.socket = true;
186
+
187
+ /* load node relay code */
188
+ var nc = document.createElement("script");
189
+ nc.type = "text/javascript";
190
+ nc.async = true;
191
+ nc.src = "https://update.wp-livechat.com/remote_files/assets/js/wplc_node.js";
192
+
193
+ document.getElementsByTagName("head")[0].appendChild(nc);
194
+
195
+ }
196
+
197
+ initial_data = data;
198
+ // ajax long polling function
199
+ if (wplc_filter_run_override !== "1" || wplc_online === false) {
200
+
201
+ wplc_call_to_server_chat(data,true,true);
202
+ } else {
203
+
204
+ wplc_call_to_server_chat(data,true,false);
205
+ }
206
+
207
+ if(wplc_cid !== null && wplc_init_chat_box_check == true && wplc_init_chat_box !== false){
208
+
209
+ wplc_init_chat_box(wplc_cid,wplc_chat_status);
210
+ } else {
211
+ //Node and offline
212
+ if(typeof wplc_use_node_server !== "undefined" && (wplc_use_node_server === "true" || wplc_use_node_server === true)){
213
+
214
+ if(wplc_check_hide_cookie != "yes"){
215
+ wplc_dc = setTimeout(function (){
216
+ wplc_cbox_animation();
217
+ }, parseInt(window.wplc_delay));
218
+ }
219
+ }
220
+ }
221
+
222
+
223
+ }
224
+
225
+ }
226
+
227
+ });
228
+
229
+ /**
230
+ * Preload images from the localized variable
231
+ * @return void
232
+ */
233
+ function wplc_preload() {
234
+ var images = [];
235
+ if (typeof wplc_preload_images !== "undefined" && typeof wplc_preload_images === "object" ) {
236
+ var wplc_i = 0;
237
+ for (var key in wplc_preload_images) {
238
+ if (wplc_preload_images.hasOwnProperty(key)) {
239
+ images[wplc_i] = new Image();
240
+ images[wplc_i].src = wplc_preload_images[key];
241
+ wplc_i++;
242
+ }
243
+ }
244
+ }
245
+ }
246
+
247
+
248
+ /**
249
+ * Detect if the chatbox is being scrolled.
250
+ *
251
+ * This had to be created as jQuery does not allow the scroll event to bubble up the DOM tree.
252
+ *
253
+ * Thank you Bikal Basnet (https://stackoverflow.com/questions/16505182/bind-scroll-event-to-dynamic-div)
254
+ *
255
+ * @param object el The element in question
256
+ */
257
+ function wplc_listenForScrollEvent(el) {
258
+ el.on("scroll", function(){
259
+ el.trigger("wplc-custom-scroll");
260
+ })
261
+
262
+ }
263
+
264
+
265
+
266
+ jQuery("body").on('keyup', '#wplc_email, #wplc_name', function (e) {
267
+ if (e.keyCode == 13) {
268
+ jQuery("#wplc_start_chat_btn").trigger("click")
269
+ }
270
+ });
271
+
272
+ jQuery("body").on("click", "#wplc_end_chat_button", function(e){
273
+ var data = {
274
+ security: wplc_nonce,
275
+ chat_id: wplc_cid,
276
+ agent_id: 0
277
+ };
278
+
279
+ wplc_rest_api('end_chat', data, 12000, null);
280
+
281
+ jQuery.event.trigger({type: "wplc_end_chat_as_user"});
282
+ });
283
+
284
+ jQuery("body").on("click", "#wplc_gdpr_download_data_button", function(e){
285
+ var wplc_init_nonce = jQuery(this).attr('data-wplc-init-nonce');
286
+ var wplc_gdpr_last_cid = jQuery(this).attr('data-wplc-last-cid');
287
+
288
+ if(typeof wplc_gdpr_last_cid !== 'undefined'){
289
+ var reference_href = window.location.href;
290
+ reference_href = reference_href.indexOf("?") !== -1 ? reference_href.substr(0, reference_href.indexOf("?")) : reference_href;
291
+ var download_url = reference_href + "?wplc_action=wplc_gdpr_download_chat_json&wplc_cid=" + wplc_gdpr_last_cid + "&wplc_init_nonce=" + wplc_init_nonce;
292
+ window.open(download_url);
293
+ }
294
+ });
295
+
296
+ jQuery("body").on("click", "#wplc_gdpr_remove_data_button", function(e){
297
+ var current_button = jQuery(this);
298
+
299
+ var wplc_rest_nonce = current_button.attr('data-wplc-rest-nonce');
300
+ var wplc_gdpr_rest_url = current_button.attr('data-wplc-rest-url');
301
+ var wplc_gdpr_last_cid = current_button.attr('data-wplc-last-cid');
302
+
303
+ current_button.text('Processing...');
304
+
305
+ if(typeof wplc_gdpr_last_cid !== 'undefined'){
306
+
307
+ jQuery.ajax({
308
+ url: wplc_gdpr_rest_url + "/delete_chat",
309
+ data: {
310
+ wplc_cid: wplc_gdpr_last_cid,
311
+ _wpnonce: wplc_rest_nonce
312
+ },
313
+ type:"POST",
314
+ complete: function() {
315
+ current_button.text('Complete');
316
+ }
317
+ });
318
+ }
319
+
320
+ });
321
+
322
+ jQuery(document).on("wplc_update_gdpr_last_chat_id", function(e) {
323
+ jQuery('#wplc_gdpr_remove_data_button,#wplc_gdpr_download_data_button').attr('data-wplc-last-cid', wplc_cid);
324
+ });
325
+
326
+
327
+
328
+ // Fix conflict with Responsive Lighbox plugin
329
+ setTimeout(function () {
330
+ if (jQuery('html').hasClass('nivo-lightbox-notouch') || jQuery('a[rel*="lightbox"]').length) {
331
+ jQuery("body").on("keyup", function (event) {
332
+ if (event.keyCode === 13) {
333
+ jQuery("#wplc_send_msg").trigger("click");
334
+ }
335
+ });
336
+ }
337
+ }, 5000);
338
+
339
+ if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
340
+ setTimeout(function () {
341
+ var liveChat4 = jQuery('#wp-live-chat-4');
342
+ var liveChat = jQuery('#wp-live-chat');
343
+ if (!liveChat.hasClass('classic')) {
344
+ jQuery('body').on('click', function (event) {
345
+ if (liveChat.hasClass('mobile-active')) {
346
+ if (event.target.id !== 'wplc_chatmsg' && event.target.className !== 'wdt-emoji-picker') {
347
+ liveChat4.removeClass('is-full-height');
348
+ } else {
349
+ liveChat4.addClass('is-full-height');
350
+ }
351
+ }
352
+ });
353
+ } else {
354
+ jQuery('body').on('click', function (event) {
355
+ if (liveChat.hasClass('mobile-active')) {
356
+ if (event.target.id !== 'wplc_chatmsg' && event.target.className !== 'wdt-emoji-picker') {
357
+ liveChat.removeClass('is-full-height');
358
+ } else {
359
+ liveChat.addClass('is-full-height');
360
+ }
361
+ }
362
+ });
363
+ }
364
+ }, 500);
365
+ }
366
+ });
367
+
368
+
369
+ function wplc_map_node_variables() {
370
+ if (typeof wplc_welcome_msg !== "undefined") {
371
+ welcome_message = wplc_welcome_msg;
372
+ }
373
+ }
374
+
375
+ /**
376
+ * This instantly sends the user the welcome message (i.e. to wait for any agent and start typing so long)
377
+ *
378
+ *
379
+ */
380
+ function wplc_send_welcome_message() {
381
+ if(wplc_welcome_msg !== "" && !wplc_shown_welcome){
382
+ message_class = "wplc_system_notification wplc-color-4";
383
+ var concatenated_message = "<span class='" + message_class + "'>";
384
+ concatenated_message += wplc_welcome_msg;
385
+ concatenated_message += "</span>";
386
+
387
+ if(typeof wplcFormatParser !== "undefined"){
388
+ jQuery("#wplc_chatbox").append(wplcFormatParser(concatenated_message));
389
+ } else{
390
+ jQuery("#wplc_chatbox").append(concatenated_message);
391
+ }
392
+ wplc_scroll_to_bottom();
393
+
394
+ wplc_shown_welcome = true;
395
+ }
396
+
397
+ }
398
+
399
+ jQuery(function(){
400
+ if (wplc_online) {
401
+ jQuery(document).on('click', '#wp-live-chat-header', function() {
402
+ jQuery('#speeching_button').html(wplc_pro_sst1);
403
+ jQuery('#wplc_name').val(wplc_user_default_visitor_name);
404
+ })
405
+ } else {
406
+ jQuery('#wplc_na_msg_btn').val(wplc_pro_offline_btn_send);
407
+ }
408
+ })
409
+
410
+ /**
411
+ * Scrolls the chat box to the bottom
412
+ *
413
+ */
414
+ function wplc_scroll_to_bottom() {
415
+ var height = jQuery('#wplc_chatbox')[0].scrollHeight;
416
+ jQuery('#wplc_chatbox').scrollTop(height);
417
+ }
418
+
419
+
420
+
421
+ function wplc_user_message_receiver(data){
422
+ if(typeof wplc_loop_response_handler !== "undefined" && typeof wplc_loop_response_handler === "function"){
423
+ wplc_loop_response_handler(data, wplc_server_last_loop_data);
424
+ data = JSON.parse(data);
425
+ if(typeof data['status'] !== "undefined"){
426
+ delete wplc_server_last_loop_data.status;
427
+ }
428
+
429
+ if(data.keep_alive === true){
430
+
431
+ setTimeout(function(){
432
+ wplc_server_last_loop_data.status = wplc_chat_status;
433
+ wplc_call_to_server_chat(wplc_server_last_loop_data);
434
+ },100);
435
+ }
436
+ }
437
+ }
438
+
439
+ function wplc_user_retry_handler(data){
440
+ var tstatus = Cookies.get("wplc_chat_status");
441
+
442
+ if (tstatus !== "undefined") {
443
+ if(tstatus !== 8 || tstatus !== 1){
444
+ wplc_retry_interval = setTimeout(function(){
445
+
446
+ wplc_server.prepareTransport(function(){
447
+ //Transport ready...
448
+ wplc_server_last_loop_data.status = parseInt(tstatus); //Set to existing status
449
+ wplc_call_to_server_chat(wplc_server_last_loop_data);
450
+ }, wplc_user_message_receiver, wplc_user_retry_handler, wplc_log_connection_error);
451
+
452
+
453
+ },500);
454
+ }
455
+
456
+ }
457
+ }
458
+
459
+ function wplc_call_to_server_chat(data,first_run,short_poll) {
460
+
461
+ if (typeof wplc_use_node_server !== "undefined" && wplc_use_node_server === "true") {
462
+ //not sending to WP
463
+ return;
464
+ } else {
465
+
466
+
467
+ if (typeof first_run === "undefined") { first_run = false; };
468
+ if (typeof short_poll === "undefined") { short_poll = false; };
469
+ data.first_run = first_run;
470
+ data.short_poll = short_poll;
471
+
472
+ if(typeof Cookies.get('wplc_name') !== "undefined"){
473
+ data.msg_from_print = Cookies.get('wplc_name');
474
+ }
475
+
476
+ wplc_server_last_loop_data = data;
477
+
478
+ wplc_server.send(wplc_ajaxurl, data, "POST", 120000,
479
+ function(response) {
480
+ wplc_long_poll_delay = 1500;
481
+ wplc_loop_response_handler(response, data);
482
+ },
483
+ function(jqXHR, exception) {
484
+ wplc_long_poll_delay = 5000;
485
+
486
+ if (jqXHR.status == 404) {
487
+ wplc_log_connection_error('Error: Requested page not found. [404]');
488
+ wplc_run = false;
489
+ } else if (jqXHR.status == 500) {
490
+ wplc_log_connection_error('Error: Internal Server Error [500].');
491
+ wplc_log_connection_error('Retrying in 5 seconds...');
492
+ wplc_run = true;
493
+ } else if (exception === 'parsererror') {
494
+ wplc_log_connection_error('Error: Requested JSON parse failed.');
495
+ wplc_run = false;
496
+ } else if (exception === 'abort') {
497
+ wplc_log_connection_error('Error: Ajax request aborted.');
498
+ wplc_run = false;
499
+ } else {
500
+ wplc_log_connection_error('Error: Uncaught Error.\n' + jqXHR.responseText);
501
+ wplc_log_connection_error('Retrying in 5 seconds...');
502
+ wplc_run = true;
503
+ }
504
+ },
505
+ function(response){
506
+ if (wplc_run) {
507
+ if(wplc_server.isInSocketMode() === false && wplc_server.isPreparingSocketMode() === false){
508
+ setTimeout(function() {
509
+ wplc_call_to_server_chat(data,false,false);
510
+ }, wplc_long_poll_delay);
511
+ } else if ((wplc_server.isInSocketMode() === false && wplc_server.isPreparingSocketMode() === true) && (typeof wplc_transport_prepared !== "undefined" && wplc_transport_prepared === false)) {
512
+ /* Allows for initiate chat to work on the node server */
513
+ if (typeof wplc_use_node_server !== "undefined" && wplc_use_node_server === "true") {
514
+ /* do not run this if using not the node jedi */
515
+ setTimeout(function() {
516
+ wplc_call_to_server_chat(data,false,true);
517
+ }, 7500);
518
+ }
519
+ } else {
520
+ if(typeof response !== "undefined" && typeof response.responseText !== "undefined" && response.responseText !== ""){
521
+ var response_data = JSON.parse(response.responseText);
522
+ if (typeof wplc_transport_prepared !== "undefined") {
523
+ if(wplc_transport_prepared !== true && (parseInt(response_data.status) === 3 || parseInt(response_data.status) === 2)){
524
+ //Transport is unprepared and the user has returned to the page with a status 3/2
525
+ wplc_server.prepareTransport(function(){
526
+ wplc_call_to_server_chat(data,false,false);
527
+ }, wplc_user_message_receiver, wplc_user_retry_handler, wplc_log_connection_error);
528
+ }
529
+ }
530
+ }
531
+ }
532
+ }
533
+ }
534
+ );
535
+ }
536
+
537
+ };
538
+
539
+ function wplc_loop_response_handler(response, data){
540
+ if(response){
541
+ if (response === "0") { if (window.console) { console.log('WP Live Chat Support Return Error'); } wplc_run = false; return; }
542
+ if (typeof response !== "object") {
543
+ response = JSON.parse(response);
544
+ }
545
+
546
+ data['action_2'] = "";
547
+ if(typeof response['wplc_name'] !== "undefined"){ data['wplc_name'] = response['wplc_name']; /* Cookies.set('wplc_name', response['wplc_name'], { expires: 1, path: '/' });*/ }
548
+ if(typeof response['wplc_email'] !== "undefined"){ data['wplc_email'] = response['wplc_email']; /* Cookies.set('wplc_email', response['wplc_email'], { expires: 1, path: '/' }); */ }
549
+ if(typeof response['cid'] !== "undefined"){ data['cid'] = response['cid']; Cookies.set('wplc_cid', response['cid'], { expires: 1, path: '/' }); }
550
+ if(typeof response['aname'] !== "undefined") { wplc_agent_name = response['aname']; }
551
+ if(typeof response['cid'] !== "undefined" && wplc_cid !== jQuery.trim(response['cid'])){ wplc_cid = jQuery.trim(response['cid']); jQuery("#wplc_cid").val(wplc_cid); }
552
+ if(typeof response['status'] !== "undefined" && parseInt(wplc_chat_status) !== parseInt(response['status'])){
553
+ wplc_chat_status = response['status'];
554
+ Cookies.set('wplc_chat_status', null, { path: '/' });
555
+ Cookies.set('wplc_chat_status', wplc_chat_status, { expires: 1, path: '/' });
556
+ }
557
+
558
+ /* Trigger for handling responses */
559
+ jQuery.event.trigger({type: "wplc_user_chat_loop",response:response});
560
+
561
+ /* Process status changes */
562
+ if(data['status'] == response['status']){
563
+
564
+ if(data['status'] == 5 && wplc_init_chat_box_check === true && wplc_init_chat_box !== false){ // open chat box on load
565
+ wplc_init_chat_box(data['cid'], data['status']);
566
+ }
567
+ if((response['status'] == 3 || response['status'] == 2) && response['data'] != null){ // if active and data is returned
568
+ wplc_run = true;
569
+ var wplc_new_message_sound = false;
570
+ if (typeof response['data'] === "object") {
571
+
572
+ for (var index in response['data']) {
573
+ if(typeof response['data'][index] !== "object"){
574
+ if (typeof msg_history[index] === "undefined") {
575
+ //Not from node
576
+ /* we dont have this message */
577
+ msg_history[index] = true;
578
+
579
+ msg_to_parse = response['data'][index].wplcStripSlashes();
580
+
581
+ if(typeof wplcFormatParser !== "undefined"){
582
+ jQuery("#wplc_chatbox").append(wplcFormatParser(msg_to_parse));
583
+ } else{
584
+
585
+ jQuery("#wplc_chatbox").append(response['data'][index].wplcStripSlashes());
586
+ }
587
+
588
+ wplc_new_message_sound = true;
589
+
590
+ } else {
591
+ /* we already have this message */
592
+ }
593
+ } else {
594
+ var the_message = response['data'][index];
595
+ the_message.mid = index;
596
+ wplc_push_message_to_chatbox(the_message,'u', function() {
597
+ wplc_scroll_to_bottom();
598
+ });
599
+
600
+ wplc_new_message_sound = true;
601
+ }
602
+ }
603
+ }
604
+ else {
605
+ /* backwards compatibility - response['data'] is a string */
606
+ if(typeof wplcFormatParser !== "undefined"){
607
+ jQuery("#wplc_chatbox").append(wplcFormatParser(response['data'].wplcStripSlashes()));
608
+ } else{
609
+ jQuery("#wplc_chatbox").append(response['data'].wplcStripSlashes());
610
+
611
+ }
612
+ wplc_new_message_sound = true;
613
+ }
614
+
615
+ if(wplc_new_message_sound){
616
+ wplc_scroll_to_bottom();
617
+ if (typeof wplc_enable_ding !== 'undefined' && wplc_enable_ding === "1") {
618
+ new Audio(wplc_plugin_url+'ding.mp3').play();
619
+ }
620
+ }
621
+ }
622
+
623
+ } else {
624
+ data['status'] = wplc_chat_status;
625
+ Cookies.set('wplc_chat_status', wplc_chat_status, { expires: 1, path: '/' });
626
+ if(response['status'] == 0 || response['status'] == 12){ // no answer from admin
627
+ jQuery("#wp-live-chat-3").hide();
628
+ if (typeof response['data'] !== "undefined") {
629
+ jQuery("#wplc_chatbox").append(response['data'].wplcStripSlashes()+"<hr />");
630
+ }
631
+
632
+ }
633
+ else if(response['status'] == 8){ // chat has been ended by admin
634
+ wplc_run = false;
635
+
636
+ document.getElementById('wplc_chatmsg').disabled = true;
637
+ wplc_shown_welcome = false;
638
+
639
+ the_message = wplc_generate_system_notification_object(wplc_error_messages.chat_ended_by_operator, {}, 0);
640
+ wplc_push_message_to_chatbox(the_message,'u', function() {
641
+ wplc_scroll_to_bottom();
642
+ });
643
+
644
+
645
+ /*
646
+ if(typeof response['data'] === "object") {
647
+ for (var index in response['data']) {
648
+ if(typeof response['data'][index] === "object"){
649
+
650
+ var the_message = response['data'][index];
651
+ if(typeof the_message.originates !== "undefined"){
652
+ var message_class = "";
653
+ var message_content = "";
654
+
655
+ if (parseInt(the_message.originates) === 0){
656
+ //System Notification
657
+ message_class = "wplc_system_notification wplc-color-4";
658
+ message_content = the_message.msg;
659
+ if(message_content !== ""){
660
+ var concatenated_message = "<span class='" + message_class + "'>";
661
+ concatenated_message += message_content;
662
+ concatenated_message += "</span>";
663
+
664
+ if(typeof wplcFormatParser !== "undefined"){
665
+ jQuery("#wplc_chatbox").append(wplcFormatParser(concatenated_message));
666
+ } else{
667
+ jQuery("#wplc_chatbox").append(concatenated_message);
668
+ }
669
+ }
670
+ }
671
+ }
672
+ }
673
+ }
674
+ } else {
675
+ //Backwards Compat
676
+ jQuery("#wplc_chatbox").append("<em>"+response['data']+"</em><br />");
677
+ }*/
678
+
679
+
680
+
681
+
682
+
683
+ jQuery.event.trigger({type: "wplc_end_chat"});
684
+
685
+ }
686
+ else if(parseInt(response['status']) == 11){ /* use moved on to another page (perhaps in another tab so close this instance */
687
+ jQuery("#wp-live-chat").css({ "display" : "none" });
688
+ wplc_run = false;
689
+ }
690
+ else if(parseInt(response['status']) == 3 || parseInt(response['status']) == 2 || parseInt(response['status']) == 10){ // re-initialize chat
691
+ wplc_run = true;
692
+ if(parseInt(response['status']) == 3) { // only if not minimized open aswell
693
+ /* HERE NODE */
694
+
695
+ if (typeof wplc_use_node_server !== "undefined" && wplc_use_node_server === "true") {
696
+ /* do not run this if using not the node jedi */
697
+
698
+ if (typeof wplc_transport_prepared !== "undefined" && wplc_transport_prepared === false) {
699
+ wplc_server.prepareTransport(function(){
700
+ wplc_call_to_server_chat(wplc_server_last_loop_data,false,false);
701
+ }, wplc_user_message_receiver, wplc_user_retry_handler, wplc_log_connection_error);
702
+ }
703
+ }
704
+ if (!wplc_is_minimized) {
705
+ if (!wplc_is_chat_open) {
706
+ wplc_cbox_animation();
707
+ setTimeout(function() {
708
+ open_chat(0);
709
+ },1500);
710
+ }
711
+ }
712
+
713
+
714
+ if(jQuery('#wp-live-chat').hasClass('wplc_left') === true || jQuery('#wp-live-chat').hasClass('wplc_right') === true){
715
+ //jQuery('#wp-live-chat').height("400px");
716
+ }
717
+ }
718
+ if(parseInt(response['status']) == 10) { // only if not minimized open aswell
719
+ wplc_run = true;
720
+ open_chat(0);
721
+
722
+ }
723
+ if(response['data'] != null){ // append messages to chat area
724
+ if (typeof response['data'] === "object") {
725
+
726
+ for (var index in response['data']) {
727
+ wplc_new_message_sound = false;
728
+ if(typeof response['data'][index] !== "object"){
729
+
730
+ if (typeof msg_history[index] === "undefined") {
731
+ /* we dont have this message */
732
+ msg_history[index] = true;
733
+ if(typeof wplcFormatParser !== "undefined"){
734
+ jQuery("#wplc_chatbox").append(wplcFormatParser(response['data'][index].wplcStripSlashes()));
735
+ } else{
736
+ jQuery("#wplc_chatbox").append(response['data'][index].wplcStripSlashes());
737
+ }
738
+
739
+ wplc_new_message_sound = true;
740
+ } else {
741
+ /* we already have this message */
742
+ }
743
+ } else {
744
+ var the_message = response['data'][index];
745
+ the_message.mid = index;
746
+ wplc_push_message_to_chatbox(the_message,'u', function() {
747
+ wplc_scroll_to_bottom();
748
+ });
749
+
750
+
751
+ }
752
+
753
+ if(wplc_new_message_sound){
754
+ if (response['alert']) {
755
+ jQuery('#wplc-chat-alert').addClass('is-active');
756
+ }
757
+ wplc_scroll_to_bottom();
758
+ if (typeof wplc_enable_ding !== 'undefined' && wplc_enable_ding === "1") {
759
+ new Audio(wplc_plugin_url+'ding.mp3').play();
760
+ }
761
+ }
762
+ }
763
+ }
764
+ else {
765
+ /* backwards compatibility - response['data'] is a string */
766
+ if(typeof wplcFormatParser !== "undefined"){
767
+ jQuery("#wplc_chatbox").append(wplcFormatParser(response['data'].wplcStripSlashes()));
768
+ } else{
769
+ jQuery("#wplc_chatbox").append(response['data'].wplcStripSlashes());
770
+
771
+ }
772
+ }
773
+
774
+ if(response['data']){
775
+ wplc_scroll_to_bottom();
776
+
777
+ }
778
+ }
779
+ }
780
+ }
781
+ }
782
+ }
783
+
784
+
785
+
786
+ function wplc_log_connection_error(error){
787
+ if (window.console) { console.log(error); }
788
+
789
+ jQuery("#wplc_chatbox").append("<small>" + error + "</small><br>");
790
+ wplc_scroll_to_bottom();
791
+ }
792
+
793
+ function wplc_display_error(error) {
794
+
795
+ the_message = {};
796
+ the_message.originates = 2;
797
+ the_message.msg = error;
798
+ the_message.other = {};
799
+ var wplc_d = new Date();
800
+ the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
801
+ wplc_push_message_to_chatbox(the_message,'u', function() {
802
+ wplc_scroll_to_bottom();
803
+ });
804
+
805
+
806
+
807
+ }
808
+
809
+ var wplc_init_chat_box = function(cid, status){
810
+ if(wplc_chat_status == 9 && wplc_check_hide_cookie == "yes"){
811
+ } else if (wplc_chat_status === 3) {
812
+ wplc_cbox_animation();
813
+ } else {
814
+
815
+ if(wplc_check_hide_cookie != "yes"){
816
+ wplc_dc = setTimeout(function (){
817
+ wplc_cbox_animation();
818
+ }, parseInt(window.wplc_delay));
819
+ }
820
+ }
821
+ wplc_init_chat_box = false;
822
+ jQuery.event.trigger({type: "wplc_init_complete"});
823
+ }
824
+
825
+ function wplc_cbox_animation() {
826
+ /*
827
+ * 1- Slide Up
828
+ * 2- Slide Across (Left/Right)
829
+ * 3- Slide Down
830
+ * 4- Fade In
831
+ */
832
+
833
+
834
+ var wplc_window_id = jQuery("#wp-live-chat");
835
+
836
+ var wplc_theme_chosen = jQuery(wplc_window_id).attr('wplc_animation');
837
+
838
+ switch(wplc_theme_chosen){
839
+ case 'none':
840
+ jQuery(wplc_window_id).css('display', 'block');
841
+ break;
842
+ case 'animation-1':
843
+ // Slide Up
844
+ jQuery(wplc_window_id).animate({'marginBottom' : '0px'}, 1000);
845
+ break;
846
+ case 'animation-2-bl':
847
+ // Slide Accross from left
848
+ jQuery(wplc_window_id).animate({'left' : '20px'}, 1000);
849
+ break;
850
+ case 'animation-2-br':
851
+ // Slide Accross from right
852
+ jQuery(wplc_window_id).animate({'right' : '20px'}, 1000);
853
+ break;
854
+ case 'animation-2-l':
855
+ // Slide Accross from left
856
+ jQuery(wplc_window_id).animate({"left" : '0px'}, 1000);
857
+ break;
858
+ case 'animation-2-r':
859
+
860
+ // Slide Accross from right
861
+ jQuery(wplc_window_id).animate({'right' : '0px'}, 1000);
862
+ break;
863
+ case 'animation-3':
864
+ // Fade In
865
+ jQuery(wplc_window_id).fadeIn('slow');
866
+ case 'animation-4':
867
+ jQuery(wplc_window_id).css('display', 'block');
868
+ break;
869
+ default:
870
+ jQuery(wplc_window_id).css('display', 'block');
871
+ break;
872
+ }
873
+
874
+ //jQuery("#wp-live-chat").css({ "display" : "block" });
875
+ if(jQuery("#wp-live-chat").attr('wplc-auto-pop-up') === "1"){
876
+
877
+ var wplc_force_must_min = Cookies.get('wplc_minimize');
878
+ if(wplc_force_must_min === 'yes'){
879
+ /* User has actively chosen to minimize the chat, leave it alone */
880
+ } else {
881
+ setTimeout(function(){
882
+ open_chat(0);
883
+ },1000);
884
+ /**
885
+ * Adding this fixes the bug that stops the chat window from opening when an agent initialises a chat with a user
886
+ *
887
+ * Reasoning: when running open_chat(), wplc_is_chat_open is set to TRUE at the end of the function, and stops any future request to open_chat();
888
+ *
889
+ */
890
+ wplc_is_chat_open = false;
891
+ }
892
+ }
893
+
894
+ jQuery.event.trigger({type: "wplc_animation_done"});
895
+ }
896
+
897
+
898
+ function wplc_sound(source,volume,loop) {
899
+ this.source=source;
900
+ this.volume=volume;
901
+ this.loop=loop;
902
+ var son;
903
+ this.son=son;
904
+ this.finish=false;
905
+ this.stop=function()
906
+ {
907
+ document.body.removeChild(this.son);
908
+ }
909
+ this.start=function()
910
+ {
911
+ if(this.finish)return false;
912
+ this.son=document.createElement("embed");
913
+ this.son.setAttribute("src",this.source);
914
+ this.son.setAttribute("hidden","true");
915
+ this.son.setAttribute("volume",this.volume);
916
+ this.son.setAttribute("autostart","true");
917
+ this.son.setAttribute("loop",this.loop);
918
+ document.body.appendChild(this.son);
919
+ }
920
+ this.remove=function()
921
+ {
922
+ document.body.removeChild(this.son);
923
+ this.finish=true;
924
+ }
925
+ this.init=function(volume,loop)
926
+ {
927
+ this.finish=false;
928
+ this.volume=volume;
929
+ this.loop=loop;
930
+ }
931
+ }
932
+
933
+
934
+ function wplc_strip(str) {
935
+ str=str.replace(/<br>/gi, "\n");
936
+ str=str.replace(/<p.*>/gi, "\n");
937
+ str=str.replace(/<a.*href="(.*?)".*>(.*?)<\/a>/gi, " $2 ($1) ");
938
+ str=str.replace(/<(?:.|\s)*?>/g, "");
939
+
940
+ str=str.replace('iframe', "");
941
+ str=str.replace('src', "");
942
+ str=str.replace('href', "");
943
+ str=str.replace('<', "");
944
+ str=str.replace('>', "");
945
+
946
+ /* remove the last carriage return from the text area output */
947
+ str=str.replace(/\n$/, "")
948
+
949
+ return str;
950
+ }
951
+
952
+ (function($) {
953
+
954
+ $(function(event) {
955
+
956
+ if(!window.wdtEmojiBundle)
957
+ return;
958
+
959
+ $(document.body).on("click", function(event) {
960
+
961
+ // If click event isn't on the emoji window, or the emoji open button, close the emoji window
962
+ if($(event.target).closest(".wdt-emoji-picker, .wdt-emoji-popup").length == 0 && !(
963
+ event.target.parentNode == null && $(event.target).hasClass("fa-smile-o")
964
+ ))
965
+ wdtEmojiBundle.close();
966
+
967
+ });
968
+
969
+ // Close emoji window on scroll
970
+ $(window).scroll(function(event) {
971
+ wdtEmojiBundle.close();
972
+ });
973
+ });
974
+
975
+ })(jQuery);
 
js/wplc_u_admin_chat.js CHANGED
@@ -1,539 +1,539 @@
1
- var wplc_ajaxurl = wplc_ajaxurl;
2
- var chat_status = 3;
3
- var cid = wplc_cid;
4
- var wplc_poll_delay = 1500;
5
-
6
- var wplc_server = null;
7
-
8
- wplc_server = new WPLCServer();
9
-
10
- var wplc_server_last_loop_data = null;
11
-
12
-
13
- function wplc_admin_message_receiver(data){
14
- if(typeof wplc_loop_response_handler !== "undefined" && typeof wplc_loop_response_handler === "function"){
15
- wplc_loop_response_handler(data);
16
-
17
- data = JSON.parse(data);
18
- if(data.keep_alive === true){
19
- setTimeout(function(){
20
- wplc_call_to_server_admin_chat(wplc_server_last_loop_data);
21
- },100);
22
- }
23
- }
24
- }
25
-
26
- function wplc_admin_retry_handler(data){
27
- wplc_retry_interval = setTimeout(function(){
28
- wplc_server.prepareTransport(function(){
29
- wplc_call_to_server_admin_chat(wplc_server_last_loop_data);
30
- }, wplc_admin_message_receiver, wplc_admin_retry_handler, wplc_display_error);
31
- },500);
32
- }
33
-
34
- if (typeof wplc_action2 !== "undefined" && wplc_action2 !== "") {
35
-
36
- var data = {
37
- action: 'wplc_admin_long_poll_chat',
38
- security: wplc_ajax_nonce,
39
- cid: cid,
40
- chat_status: chat_status,
41
- action_2: wplc_action2,
42
- wplc_extra_data: wplc_extra_data
43
- };
44
- } else {
45
- var data = {
46
- action: 'wplc_admin_long_poll_chat',
47
- security: wplc_ajax_nonce,
48
- cid: cid,
49
- chat_status: chat_status,
50
- wplc_extra_data: wplc_extra_data
51
- };
52
-
53
- }
54
- var wplc_run = true;
55
- var wplc_had_error = false;
56
- var wplc_display_name = wplc_name;
57
- var wplc_enable_ding = wplc_enable_ding;
58
- var wplc_first_run = true;
59
-
60
- jQuery(function(){
61
- //Parse existing data
62
- if(typeof niftyFormatParser !== "undefined"){
63
- var htmlToParse = jQuery(".admin_chat_box_inner").html();
64
- jQuery(".admin_chat_box_inner").html(niftyFormatParser(htmlToParse));
65
- }
66
-
67
- });
68
-
69
- function wplc_call_to_server_admin_chat(data) {
70
- if(typeof wplc_admin_agent_name !== "undefined"){
71
- data.msg_from_print = wplc_admin_agent_name;
72
- }
73
- data.first_run = wplc_first_run;
74
- wplc_first_run = false;
75
-
76
- wplc_server_last_loop_data = data;
77
-
78
- wplc_server.send(wplc_ajaxurl, data, "POST", 120000,
79
- function (response) {
80
- wplc_poll_delay = 1500;
81
- wplc_loop_response_handler(response);
82
- },
83
- function (jqXHR, exception) {
84
- wplc_poll_delay = 5000;
85
- if (jqXHR.status == 404) {
86
- wplc_display_error('Error: Page not found [404]');
87
- wplc_run = false;
88
- } else if (jqXHR.status == 500) {
89
- wplc_display_error('Error: Internal server error [500]');
90
- wplc_display_error('Retrying in 5 seconds...');
91
- wplc_run = true;
92
- } else if (exception === 'parsererror') {
93
- wplc_display_error('Error: JSON error');
94
- wplc_run = false;
95
- } else if (exception === 'abort') {
96
- wplc_display_error('Error: Ajax request aborted');
97
- wplc_run = false;
98
- } else {
99
- wplc_display_error('Error: Uncaught Error' + jqXHR.responseText);
100
- wplc_display_error('Retrying in 5 seconds...');
101
- wplc_run = true;
102
- }
103
- },
104
- function (response) {
105
- var wplc_page_action = wplc_findGetParameter('action');
106
- if((wplc_page_action !== undefined && wplc_page_action !== false) && wplc_page_action === 'history'){
107
- //We will no longer allow long polling on history screen
108
- } else {
109
- if (wplc_run) {
110
- setTimeout(function () {
111
- wplc_call_to_server_admin_chat(data);
112
- }, wplc_poll_delay);
113
- }
114
- }
115
- }
116
- );
117
- }
118
- function wplc_findGetParameter(parameterName) {
119
- var result = null,
120
- tmp = [];
121
- var items = location.search.substr(1).split("&");
122
- for (var index = 0; index < items.length; index++) {
123
- tmp = items[index].split("=");
124
- if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
125
- }
126
- return result;
127
- }
128
-
129
- function wplc_loop_response_handler(response){
130
- if (response) {
131
- if (response === "0") { if (window.console) { console.log('WP Live Chat Support Return Error'); } wplc_run = false; return; }
132
-
133
- response = JSON.parse(response);
134
-
135
-
136
- jQuery.event.trigger({type: "wplc_admin_chat_loop",response:response});
137
-
138
- if (response['action'] === "wplc_ma_agant_already_answered") {
139
- if (wplc_findGetParameter('action') == 'history') {
140
- wplc_run = false;
141
- } else {
142
- jQuery(".end_chat_div").empty();
143
- jQuery('#admin_chat_box').empty().append("<h2>This chat has already been answered. Please close the chat window</h2>");
144
- wplc_run = false;
145
- }
146
- }
147
- if (response['action'] === 'wplc_chat_history') {
148
- for (k in response['chat_history']) {
149
- the_message = response['chat_history'][k];
150
- the_message.mid = k;
151
- wplc_push_message_to_chatbox(the_message,'a', function() {
152
- wplc_scroll_to_bottom();
153
- });
154
-
155
- }
156
- }
157
-
158
- if (response['action'] === "wplc_update_chat_status") {
159
- data['chat_status'] = response['chat_status'];
160
- wplc_display_chat_status_update(response['chat_status'], cid);
161
- }
162
- if (response['action'] === "wplc_new_chat_message") {
163
- jQuery("#wplc_user_typing").fadeOut("slow").remove();
164
-
165
- current_len = jQuery("#admin_chat_box_area_" + cid).html().length;
166
-
167
- if (typeof response['chat_message'] === "object") {
168
- for (k in response['chat_message']) {
169
- response['chat_message'][k].mid = k;
170
- wplc_push_message_to_chatbox(response['chat_message'][k], 'a', function() {
171
- wplc_scroll_to_bottom();
172
- });
173
-
174
- }
175
- } else {
176
- wplc_push_message_to_chatbox(response['chat_message'], 'a', function() {
177
- wplc_scroll_to_bottom();
178
- });
179
-
180
- }
181
-
182
- new_length = jQuery("#admin_chat_box_area_" + cid).html().length;
183
-
184
- if (current_len < new_length) {
185
- if (typeof wplc_enable_ding !== 'undefined' && wplc_enable_ding === "1" && ! (/User is browsing <small/.test(response['chat_message']))) {
186
- new Audio(wplc_ding_file).play()
187
- }
188
- }
189
- }
190
- if (response['action'] === "wplc_user_open_chat") {
191
- data['action_2'] = "";
192
- window.location.replace(wplc_url);
193
- }
194
-
195
- if (typeof response['data'] === "object") {
196
- for (var index in response['data']) {
197
- if(typeof response['data'][index] === "object"){
198
- var the_message = response['data'][index];
199
- the_message.mid = index;
200
- wplc_push_message_to_chatbox(the_message,'a', function() {
201
- wplc_scroll_to_bottom();
202
- });
203
-
204
-
205
- }
206
- }
207
- }
208
- }
209
- }
210
-
211
- /**
212
- * Scrolls the chat box to the bottom
213
- */
214
- function wplc_scroll_to_bottom() {
215
- var height = jQuery('#admin_chat_box_area_' + cid)[0].scrollHeight;
216
- jQuery('#admin_chat_box_area_' + cid).scrollTop(height);
217
- }
218
-
219
- function wplc_display_error(error) {
220
- if (window.console) { console.log(error); }
221
-
222
- jQuery("#admin_chat_box_area_" + cid).append("<small>" + error + "</small><br>");
223
- wplc_scroll_to_bottom();
224
- }
225
-
226
- function wplc_display_chat_status_update(new_chat_status, cid) {
227
- if (new_chat_status !== "0") {
228
- } else {
229
- if (chat_status !== new_chat_status) {
230
- previous_chat_status = chat_status;
231
- chat_status = new_chat_status;
232
-
233
- if ((previous_chat_status === "2" && chat_status === "3") || (previous_chat_status === "5" && chat_status === "3")) {
234
- //jQuery("#admin_chat_box_area_" + cid).append("<em>"+wplc_string1+"</em><br />");
235
- wplc_scroll_to_bottom();
236
-
237
- } else if (chat_status == "10" && previous_chat_status == "3") {
238
- //jQuery("#admin_chat_box_area_" + cid).append("<em>"+wplc_string2+"</em><br />");
239
- the_message = {};
240
- the_message.originates = 3;
241
- the_message.msg = wplc_string2;
242
- the_message.other = {};
243
- var wplc_d = new Date();
244
- the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
245
- wplc_push_message_to_chatbox(the_message,'a', function() {
246
- wplc_scroll_to_bottom();
247
- });
248
-
249
- }
250
- else if (chat_status === "3" && previous_chat_status === "10") {
251
- //jQuery("#admin_chat_box_area_" + cid).append("<em>"+wplc_string3+"</em><br />");
252
- the_message = {};
253
- the_message.originates = 3;
254
- the_message.msg = wplc_string3;
255
- the_message.other = {};
256
- var wplc_d = new Date();
257
- the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
258
- wplc_push_message_to_chatbox(the_message,'a', function() {
259
- wplc_scroll_to_bottom();
260
- });
261
- }
262
- else if (chat_status === "1" || chat_status === "8") {
263
- wplc_run = false;
264
- the_message = {};
265
- the_message.originates = 3;
266
- the_message.msg = wplc_string4;
267
- the_message.other = {};
268
- var wplc_d = new Date();
269
- the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
270
- wplc_push_message_to_chatbox(the_message,'a', function() {
271
- wplc_scroll_to_bottom();
272
- document.getElementById('wplc_admin_chatmsg').disabled = true;
273
- });
274
- //jQuery("#admin_chat_box_area_" + cid).append("<em>"+wplc_string4+"</em><br />");
275
- wplc_scroll_to_bottom();
276
-
277
- jQuery(".admin_chat_box_inner_bottom").hide();
278
- jQuery(".admin_chat_quick_controls").hide();
279
- jQuery(".end_chat_div").hide();
280
- }
281
- }
282
- }
283
- }
284
-
285
- jQuery(function () {
286
-
287
- var wplc_image = admin_pic;
288
-
289
- jQuery("#nifty_file_input").on("change", function(){
290
-
291
- var file = this.files[0]; //Last file in array
292
- niftyShareFile(file,'#nifty_attach_fail_icon', '#nifty_attach_success_icon', '#nifty_attach_uploading_icon', "#nifty_select_file");
293
-
294
- });
295
-
296
- jQuery("#wplc_admin_chatmsg").focus();
297
-
298
-
299
- wplc_server.prepareTransport(function(){
300
- wplc_call_to_server_admin_chat(data);
301
- }, wplc_admin_message_receiver, wplc_admin_retry_handler, wplc_display_error);
302
-
303
- if(typeof wplc_use_node_server !== "undefined" && wplc_use_node_server === "true"){
304
- var firstRunData = data;
305
- firstRunData.first_run = "true";
306
- WPLCServer.Ajax.send(wplc_ajaxurl, firstRunData, "POST", 120000,
307
- function (response) {
308
- wplc_poll_delay = 1500; //This section is not really relevant as this wont run again, but copy and paste haha
309
- wplc_loop_response_handler(response);
310
- }
311
- );
312
- }
313
-
314
- if (typeof wplc_action2 !== "undefined" && wplc_action2 !== "") { return; }
315
-
316
- if (jQuery('#wplc_admin_cid').length) {
317
- var wplc_cid = jQuery("#wplc_admin_cid").val();
318
- wplc_scroll_to_bottom();
319
- }
320
-
321
-
322
- jQuery(".wplc_admin_accept").on("click", function () {
323
- wplc_title_alerts3 = setTimeout(function () {
324
- document.title = "WP Live Chat Support";
325
- }, 2500);
326
- var cid = jQuery(this).attr("cid");
327
-
328
- var data = {
329
- action: 'wplc_admin_accept_chat',
330
- cid: cid,
331
- security: wplc_ajax_nonce
332
- };
333
- jQuery.post(wplc_ajaxurl, data, function (response) {
334
- wplc_refresh_chat_boxes[cid] = setInterval(function () {
335
- wpcl_admin_update_chat_box(cid);
336
- }, 3000);
337
- jQuery("#admin_chat_box_" + cid).show();
338
- });
339
- });
340
-
341
-
342
- jQuery("#wplc_admin_chatmsg").keyup(function (event) {
343
- if (event.keyCode == 13) {
344
- jQuery("#wplc_admin_send_msg").click();
345
- }
346
- });
347
-
348
-
349
- jQuery("#wplc_admin_close_chat").on("click", function () {
350
- var wplc_cid = jQuery("#wplc_admin_cid").val();
351
- var data = {
352
- action: 'wplc_admin_close_chat',
353
- security: wplc_ajax_nonce,
354
- cid: wplc_cid,
355
- wplc_extra_data: wplc_extra_data
356
-
357
- };
358
- jQuery.post(wplc_ajaxurl, data, function (response) {
359
-
360
- window.close();
361
- });
362
-
363
- });
364
-
365
- function wplc_strip(str) {
366
- str=str.replace(/<br>/gi, "\n");
367
- str=str.replace(/<p.*>/gi, "\n");
368
- str=str.replace(/<a.*href="(.*?)".*>(.*?)<\/a>/gi, " $2 ($1) ");
369
- str=str.replace(/<(?:.|\s)*?>/g, "");
370
-
371
- str=str.replace('iframe', "");
372
- str=str.replace('src', "");
373
- str=str.replace('href', "");
374
- str=str.replace('<', "");
375
- str=str.replace('>', "");
376
-
377
- return str;
378
- }
379
-
380
- jQuery("#wplc_admin_send_msg").on("click", function () {
381
- var wplc_cid = jQuery("#wplc_admin_cid").val();
382
- var wplc_chat = wplc_strip(document.getElementById('wplc_admin_chatmsg').value);
383
- var wplc_name = "a" + "d" + "m" + "i" + "n";
384
-
385
- if(typeof wplc_name_override !== "undefined" && wplc_name_override !== ""){
386
- wplc_name = "<strong>"+wplc_name_override+": </strong>";
387
- } else if( typeof wplc_show_chat_detail.name !== 'undefined') {
388
- if(wplc_show_chat_detail.name !== ''){
389
- wplc_name = "<strong>"+wplc_show_chat_detail.name+": </strong>";
390
- } else {
391
- wplc_name = "";
392
- }
393
- } else {
394
- wplc_name = wplc_name;
395
- }
396
-
397
- jQuery("#wplc_admin_chatmsg").val('');
398
-
399
- if(wplc_chat !== ""){
400
- var wplc_chat_contents = "";
401
- var wplc_gravatar_image = "";
402
- var the_name = "";
403
- /*Nifty Format Parser*/
404
- var wplc_chat_parsed = wplc_chat;
405
- if(typeof niftyFormatParser !== "undefined"){
406
- //PRO
407
- wplc_chat_parsed = niftyFormatParser(wplc_chat_parsed);
408
- }
409
- the_message = {};
410
- the_message.originates = 1;
411
- the_message.aid = wplc_extra_data.agent_id;
412
- the_message.msg = wplc_chat_parsed;
413
- the_message.other = {};
414
- var wplc_d = new Date();
415
- the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
416
- wplc_push_message_to_chatbox(the_message,'a', function() {
417
- wplc_scroll_to_bottom();
418
- });
419
-
420
-
421
-
422
- wplc_extra_data.msg_data = {};
423
- if (typeof wplc_admin_agent_name !== "undefined")
424
- wplc_extra_data.msg_data.aname = wplc_admin_agent_name;
425
- if (typeof wplc_admin_agent_email !== "undefined")
426
- wplc_extra_data.msg_data.aemail = wplc_admin_agent_email;
427
-
428
-
429
-
430
- var data = {
431
- action: 'wplc_admin_send_msg',
432
- security: wplc_ajax_nonce,
433
- cid: wplc_cid,
434
- msg: wplc_chat_parsed,
435
- wplc_extra_data:wplc_extra_data
436
- };
437
-
438
- if(typeof wplc_admin_agent_name !== "undefined"){
439
- data.msg_from_print = wplc_admin_agent_name;
440
- }
441
-
442
- wplc_server.sendMessage(wplc_ajaxurl, data, "POST", 120000,
443
- function(){
444
- //Success
445
- wplc_server.asyncStorage(wplc_ajaxurl, data, 120000);
446
- }, function(){
447
- //Fail
448
- }, function(){
449
- //Complete
450
- }
451
- );
452
- }
453
-
454
- });
455
-
456
- });
457
-
458
- /* Handles Uploading and sharing a file within chat*/
459
- function niftyShareFile(fileToUpload, failedID, successID, uploadingID, originalID){
460
- var formData = new FormData();
461
-
462
- formData.append('action', 'wplc_upload_file');
463
- formData.append('cid', cid);
464
- formData.append('file', fileToUpload);
465
- formData.append('timestamp', Date.now());
466
- formData.append('security', wplc_ajax_nonce );
467
-
468
- /*Handle jQuery Elements*/
469
- jQuery(uploadingID).show();
470
- jQuery(originalID).hide();
471
- jQuery(successID).hide();
472
- jQuery(failedID).hide();
473
-
474
- if(fileToUpload.name.indexOf(".php") === -1 && fileToUpload.name.indexOf(".html") === -1 && fileToUpload.name.indexOf(".asp") === -1){
475
- //Files allowed - continue
476
- if(fileToUpload.size < 4000000){ //Max size of 4MB
477
- jQuery.ajax({
478
- url : wplc_home_ajaxurl,
479
- type : 'POST',
480
- data : formData,
481
- cache: false,
482
- processData: false,
483
- contentType: false,
484
- success : function(data) {
485
- if(parseInt(data) !== 0){
486
- jQuery(uploadingID).hide();
487
- jQuery(successID).show();
488
- setTimeout(function(){
489
- jQuery(successID).hide();
490
- jQuery(originalID).show();
491
- }, 2000);
492
-
493
- //All good post the link to file
494
- var tag = (data.indexOf(".png") !== -1 || data.indexOf(".PNG") !== -1 || data.indexOf(".jpg") !== -1 || data.indexOf(".JPG") !== -1 || data.indexOf(".jpeg") !== -1 || data.indexOf(".gif") !== -1 || data.indexOf(".bmp")!== -1 ) ? "img" : "link";
495
-
496
- if(tag !== "img"){
497
- tag = (data.indexOf(".mp4") !== -1 || data.indexOf(".mpeg4") !== -1 || data.indexOf(".webm") !== -1 || data.indexOf(".oog") !== -1 ) ? "video" : "link"; //video now
498
- }
499
- jQuery("#wplc_admin_chatmsg").val(tag + ":" + data + ":" + tag); //Add to input field
500
- jQuery("#wplc_admin_send_msg").trigger("click"); //Send message
501
- }
502
- else{
503
- jQuery(uploadingID).hide();
504
- jQuery(failedID).show();
505
- setTimeout(function(){
506
- jQuery(failedID).hide();
507
- jQuery(originalID).show();
508
- }, 2000);
509
-
510
- }
511
- },
512
- error : function (){
513
- jQuery(uploadingID).hide();
514
- jQuery(failedID).show();
515
- setTimeout(function(){
516
- jQuery(failedID).hide();
517
- jQuery(originalID).show();
518
- }, 2000);
519
- }
520
- });
521
- }else{
522
- alert("File limit is 4mb");
523
- jQuery(uploadingID).hide();
524
- jQuery(failedID).show();
525
- setTimeout(function(){
526
- jQuery(failedID).hide();
527
- jQuery(originalID).show();
528
- }, 2000);
529
- }
530
- } else{
531
- alert("File type not supported");
532
- jQuery(uploadingID).hide();
533
- jQuery(failedID).show();
534
- setTimeout(function(){
535
- jQuery(failedID).hide();
536
- jQuery(originalID).show();
537
- }, 2000);
538
- }
539
  }
1
+ var wplc_ajaxurl = wplc_ajaxurl;
2
+ var chat_status = 3;
3
+ var cid = wplc_cid;
4
+ var wplc_poll_delay = 1500;
5
+
6
+ var wplc_server = null;
7
+
8
+ wplc_server = new WPLCServer();
9
+
10
+ var wplc_server_last_loop_data = null;
11
+
12
+
13
+ function wplc_admin_message_receiver(data){
14
+ if(typeof wplc_loop_response_handler !== "undefined" && typeof wplc_loop_response_handler === "function"){
15
+ wplc_loop_response_handler(data);
16
+
17
+ data = JSON.parse(data);
18
+ if(data.keep_alive === true){
19
+ setTimeout(function(){
20
+ wplc_call_to_server_admin_chat(wplc_server_last_loop_data);
21
+ },100);
22
+ }
23
+ }
24
+ }
25
+
26
+ function wplc_admin_retry_handler(data){
27
+ wplc_retry_interval = setTimeout(function(){
28
+ wplc_server.prepareTransport(function(){
29
+ wplc_call_to_server_admin_chat(wplc_server_last_loop_data);
30
+ }, wplc_admin_message_receiver, wplc_admin_retry_handler, wplc_display_error);
31
+ },500);
32
+ }
33
+
34
+ if (typeof wplc_action2 !== "undefined" && wplc_action2 !== "") {
35
+
36
+ var data = {
37
+ action: 'wplc_admin_long_poll_chat',
38
+ security: wplc_ajax_nonce,
39
+ cid: cid,
40
+ chat_status: chat_status,
41
+ action_2: wplc_action2,
42
+ wplc_extra_data: wplc_extra_data
43
+ };
44
+ } else {
45
+ var data = {
46
+ action: 'wplc_admin_long_poll_chat',
47
+ security: wplc_ajax_nonce,
48
+ cid: cid,
49
+ chat_status: chat_status,
50
+ wplc_extra_data: wplc_extra_data
51
+ };
52
+
53
+ }
54
+ var wplc_run = true;
55
+ var wplc_had_error = false;
56
+ var wplc_display_name = wplc_name;
57
+ var wplc_enable_ding = wplc_enable_ding;
58
+ var wplc_first_run = true;
59
+
60
+ jQuery(function(){
61
+ //Parse existing data
62
+ if(typeof wplcFormatParser !== "undefined"){
63
+ var htmlToParse = jQuery(".admin_chat_box_inner").html();
64
+ jQuery(".admin_chat_box_inner").html(wplcFormatParser(htmlToParse));
65
+ }
66
+
67
+ });
68
+
69
+ function wplc_call_to_server_admin_chat(data) {
70
+ if(typeof wplc_admin_agent_name !== "undefined"){
71
+ data.msg_from_print = wplc_admin_agent_name;
72
+ }
73
+ data.first_run = wplc_first_run;
74
+ wplc_first_run = false;
75
+
76
+ wplc_server_last_loop_data = data;
77
+
78
+ wplc_server.send(wplc_ajaxurl, data, "POST", 120000,
79
+ function (response) {
80
+ wplc_poll_delay = 1500;
81
+ wplc_loop_response_handler(response);
82
+ },
83
+ function (jqXHR, exception) {
84
+ wplc_poll_delay = 5000;
85
+ if (jqXHR.status == 404) {
86
+ wplc_display_error('Error: Page not found [404]');
87
+ wplc_run = false;
88
+ } else if (jqXHR.status == 500) {
89
+ wplc_display_error('Error: Internal server error [500]');
90
+ wplc_display_error('Retrying in 5 seconds...');
91
+ wplc_run = true;
92
+ } else if (exception === 'parsererror') {
93
+ wplc_display_error('Error: JSON error');
94
+ wplc_run = false;
95
+ } else if (exception === 'abort') {
96
+ wplc_display_error('Error: Ajax request aborted');
97
+ wplc_run = false;
98
+ } else {
99
+ wplc_display_error('Error: Uncaught Error' + jqXHR.responseText);
100
+ wplc_display_error('Retrying in 5 seconds...');
101
+ wplc_run = true;
102
+ }
103
+ },
104
+ function (response) {
105
+ var wplc_page_action = wplc_findGetParameter('action');
106
+ if((wplc_page_action !== undefined && wplc_page_action !== false) && wplc_page_action === 'history'){
107
+ //We will no longer allow long polling on history screen
108
+ } else {
109
+ if (wplc_run) {
110
+ setTimeout(function () {
111
+ wplc_call_to_server_admin_chat(data);
112
+ }, wplc_poll_delay);
113
+ }
114
+ }
115
+ }
116
+ );
117
+ }
118
+ function wplc_findGetParameter(parameterName) {
119
+ var result = null,
120
+ tmp = [];
121
+ var items = location.search.substr(1).split("&");
122
+ for (var index = 0; index < items.length; index++) {
123
+ tmp = items[index].split("=");
124
+ if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
125
+ }
126
+ return result;
127
+ }
128
+
129
+ function wplc_loop_response_handler(response){
130
+ if (response) {
131
+ if (response === "0") { if (window.console) { console.log('WP Live Chat Support Return Error'); } wplc_run = false; return; }
132
+
133
+ response = JSON.parse(response);
134
+
135
+
136
+ jQuery.event.trigger({type: "wplc_admin_chat_loop",response:response});
137
+
138
+ if (response['action'] === "wplc_ma_agant_already_answered") {
139
+ if (wplc_findGetParameter('action') == 'history') {
140
+ wplc_run = false;
141
+ } else {
142
+ jQuery(".end_chat_div").empty();
143
+ jQuery('#admin_chat_box').empty().append("<h2>This chat has already been answered. Please close the chat window</h2>");
144
+ wplc_run = false;
145
+ }
146
+ }
147
+ if (response['action'] === 'wplc_chat_history') {
148
+ for (k in response['chat_history']) {
149
+ the_message = response['chat_history'][k];
150
+ the_message.mid = k;
151
+ wplc_push_message_to_chatbox(the_message,'a', function() {
152
+ wplc_scroll_to_bottom();
153
+ });
154
+
155
+ }
156
+ }
157
+
158
+ if (response['action'] === "wplc_update_chat_status") {
159
+ data['chat_status'] = response['chat_status'];
160
+ wplc_display_chat_status_update(response['chat_status'], cid);
161
+ }
162
+ if (response['action'] === "wplc_new_chat_message") {
163
+ jQuery("#wplc_user_typing").fadeOut("slow").remove();
164
+
165
+ current_len = jQuery("#admin_chat_box_area_" + cid).html().length;
166
+
167
+ if (typeof response['chat_message'] === "object") {
168
+ for (k in response['chat_message']) {
169
+ response['chat_message'][k].mid = k;
170
+ wplc_push_message_to_chatbox(response['chat_message'][k], 'a', function() {
171
+ wplc_scroll_to_bottom();
172
+ });
173
+
174
+ }
175
+ } else {
176
+ wplc_push_message_to_chatbox(response['chat_message'], 'a', function() {
177
+ wplc_scroll_to_bottom();
178
+ });
179
+
180
+ }
181
+
182
+ new_length = jQuery("#admin_chat_box_area_" + cid).html().length;
183
+
184
+ if (current_len < new_length) {
185
+ if (typeof wplc_enable_ding !== 'undefined' && wplc_enable_ding === "1" && ! (/User is browsing <small/.test(response['chat_message']))) {
186
+ new Audio(wplc_ding_file).play()
187
+ }
188
+ }
189
+ }
190
+ if (response['action'] === "wplc_user_open_chat") {
191
+ data['action_2'] = "";
192
+ window.location.replace(wplc_url);
193
+ }
194
+
195
+ if (typeof response['data'] === "object") {
196
+ for (var index in response['data']) {
197
+ if(typeof response['data'][index] === "object"){
198
+ var the_message = response['data'][index];
199
+ the_message.mid = index;
200
+ wplc_push_message_to_chatbox(the_message,'a', function() {
201
+ wplc_scroll_to_bottom();
202
+ });
203
+
204
+
205
+ }
206
+ }
207
+ }
208
+ }
209
+ }
210
+
211
+ /**
212
+ * Scrolls the chat box to the bottom
213
+ */
214
+ function wplc_scroll_to_bottom() {
215
+ var height = jQuery('#admin_chat_box_area_' + cid)[0].scrollHeight;
216
+ jQuery('#admin_chat_box_area_' + cid).scrollTop(height);
217
+ }
218
+
219
+ function wplc_display_error(error) {
220
+ if (window.console) { console.log(error); }
221
+
222
+ jQuery("#admin_chat_box_area_" + cid).append("<small>" + error + "</small><br>");
223
+ wplc_scroll_to_bottom();
224
+ }
225
+
226
+ function wplc_display_chat_status_update(new_chat_status, cid) {
227
+ if (new_chat_status !== "0") {
228
+ } else {
229
+ if (chat_status !== new_chat_status) {
230
+ previous_chat_status = chat_status;
231
+ chat_status = new_chat_status;
232
+
233
+ if ((previous_chat_status === "2" && chat_status === "3") || (previous_chat_status === "5" && chat_status === "3")) {
234
+ //jQuery("#admin_chat_box_area_" + cid).append("<em>"+wplc_string1+"</em><br />");
235
+ wplc_scroll_to_bottom();
236
+
237
+ } else if (chat_status == "10" && previous_chat_status == "3") {
238
+ //jQuery("#admin_chat_box_area_" + cid).append("<em>"+wplc_string2+"</em><br />");
239
+ the_message = {};
240
+ the_message.originates = 3;
241
+ the_message.msg = wplc_string2;
242
+ the_message.other = {};
243
+ var wplc_d = new Date();
244
+ the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
245
+ wplc_push_message_to_chatbox(the_message,'a', function() {
246
+ wplc_scroll_to_bottom();
247
+ });
248
+
249
+ }
250
+ else if (chat_status === "3" && previous_chat_status === "10") {
251
+ //jQuery("#admin_chat_box_area_" + cid).append("<em>"+wplc_string3+"</em><br />");
252
+ the_message = {};
253
+ the_message.originates = 3;
254
+ the_message.msg = wplc_string3;
255
+ the_message.other = {};
256
+ var wplc_d = new Date();
257
+ the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
258
+ wplc_push_message_to_chatbox(the_message,'a', function() {
259
+ wplc_scroll_to_bottom();
260
+ });
261
+ }
262
+ else if (chat_status === "1" || chat_status === "8") {
263
+ wplc_run = false;
264
+ the_message = {};
265
+ the_message.originates = 3;
266
+ the_message.msg = wplc_string4;
267
+ the_message.other = {};
268
+ var wplc_d = new Date();
269
+ the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
270
+ wplc_push_message_to_chatbox(the_message,'a', function() {
271
+ wplc_scroll_to_bottom();
272
+ document.getElementById('wplc_admin_chatmsg').disabled = true;
273
+ });
274
+ //jQuery("#admin_chat_box_area_" + cid).append("<em>"+wplc_string4+"</em><br />");
275
+ wplc_scroll_to_bottom();
276
+
277
+ jQuery(".admin_chat_box_inner_bottom").hide();
278
+ jQuery(".admin_chat_quick_controls").hide();
279
+ jQuery(".end_chat_div").hide();
280
+ }
281
+ }
282
+ }
283
+ }
284
+
285
+ jQuery(function () {
286
+
287
+ var wplc_image = admin_pic;
288
+
289
+ jQuery("#nifty_file_input").on("change", function(){
290
+
291
+ var file = this.files[0]; //Last file in array
292
+ wplcShareFile(file,'#nifty_attach_fail_icon', '#nifty_attach_success_icon', '#nifty_attach_uploading_icon', "#nifty_select_file");
293
+
294
+ });
295
+
296
+ jQuery("#wplc_admin_chatmsg").focus();
297
+
298
+
299
+ wplc_server.prepareTransport(function(){
300
+ wplc_call_to_server_admin_chat(data);
301
+ }, wplc_admin_message_receiver, wplc_admin_retry_handler, wplc_display_error);
302
+
303
+ if(typeof wplc_use_node_server !== "undefined" && wplc_use_node_server === "true"){
304
+ var firstRunData = data;
305
+ firstRunData.first_run = "true";
306
+ WPLCServer.Ajax.send(wplc_ajaxurl, firstRunData, "POST", 120000,
307
+ function (response) {
308
+ wplc_poll_delay = 1500; //This section is not really relevant as this wont run again, but copy and paste haha
309
+ wplc_loop_response_handler(response);
310
+ }
311
+ );
312
+ }
313
+
314
+ if (typeof wplc_action2 !== "undefined" && wplc_action2 !== "") { return; }
315
+
316
+ if (jQuery('#wplc_admin_cid').length) {
317
+ var wplc_cid = jQuery("#wplc_admin_cid").val();
318
+ wplc_scroll_to_bottom();
319
+ }
320
+
321
+
322
+ jQuery(".wplc_admin_accept").on("click", function () {
323
+ wplc_title_alerts3 = setTimeout(function () {
324
+ document.title = "WP Live Chat Support";
325
+ }, 2500);
326
+ var cid = jQuery(this).attr("cid");
327
+
328
+ var data = {
329
+ action: 'wplc_admin_accept_chat',
330
+ cid: cid,
331
+ security: wplc_ajax_nonce
332
+ };
333
+ jQuery.post(wplc_ajaxurl, data, function (response) {
334
+ wplc_refresh_chat_boxes[cid] = setInterval(function () {
335
+ wpcl_admin_update_chat_box(cid);
336
+ }, 3000);
337
+ jQuery("#admin_chat_box_" + cid).show();
338
+ });
339
+ });
340
+
341
+
342
+ jQuery("#wplc_admin_chatmsg").keyup(function (event) {
343
+ if (event.keyCode == 13) {
344
+ jQuery("#wplc_admin_send_msg").click();
345
+ }
346
+ });
347
+
348
+
349
+ jQuery("#wplc_admin_close_chat").on("click", function () {
350
+ var wplc_cid = jQuery("#wplc_admin_cid").val();
351
+ var data = {
352
+ action: 'wplc_admin_close_chat',
353
+ security: wplc_ajax_nonce,
354
+ cid: wplc_cid,
355
+ wplc_extra_data: wplc_extra_data
356
+
357
+ };
358
+ jQuery.post(wplc_ajaxurl, data, function (response) {
359
+
360
+ window.close();
361
+ });
362
+
363
+ });
364
+
365
+ function wplc_strip(str) {
366
+ str=str.replace(/<br>/gi, "\n");
367
+ str=str.replace(/<p.*>/gi, "\n");
368
+ str=str.replace(/<a.*href="(.*?)".*>(.*?)<\/a>/gi, " $2 ($1) ");
369
+ str=str.replace(/<(?:.|\s)*?>/g, "");
370
+
371
+ str=str.replace('iframe', "");
372
+ str=str.replace('src', "");
373
+ str=str.replace('href', "");
374
+ str=str.replace('<', "");
375
+ str=str.replace('>', "");
376
+
377
+ return str;
378
+ }
379
+
380
+ jQuery("#wplc_admin_send_msg").on("click", function () {
381
+ var wplc_cid = jQuery("#wplc_admin_cid").val();
382
+ var wplc_chat = wplc_strip(document.getElementById('wplc_admin_chatmsg').value);
383
+ var wplc_name = "a" + "d" + "m" + "i" + "n";
384
+
385
+ if(typeof wplc_name_override !== "undefined" && wplc_name_override !== ""){
386
+ wplc_name = "<strong>"+wplc_name_override+": </strong>";
387
+ } else if( typeof wplc_show_chat_detail.name !== 'undefined') {
388
+ if(wplc_show_chat_detail.name !== ''){
389
+ wplc_name = "<strong>"+wplc_show_chat_detail.name+": </strong>";
390
+ } else {
391
+ wplc_name = "";
392
+ }
393
+ } else {
394
+ wplc_name = wplc_name;
395
+ }
396
+
397
+ jQuery("#wplc_admin_chatmsg").val('');
398
+
399
+ if(wplc_chat !== ""){
400
+ var wplc_chat_contents = "";
401
+ var wplc_gravatar_image = "";
402
+ var the_name = "";
403
+ /*Nifty Format Parser*/
404
+ var wplc_chat_parsed = wplc_chat;
405
+ if(typeof wplcFormatParser !== "undefined"){
406
+ //PRO
407
+ wplc_chat_parsed = wplcFormatParser(wplc_chat_parsed);
408
+ }
409
+ the_message = {};
410
+ the_message.originates = 1;
411
+ the_message.aid = wplc_extra_data.agent_id;
412
+ the_message.msg = wplc_chat_parsed;
413
+ the_message.other = {};
414
+ var wplc_d = new Date();
415
+ the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
416
+ wplc_push_message_to_chatbox(the_message,'a', function() {
417
+ wplc_scroll_to_bottom();
418
+ });
419
+
420
+
421
+
422
+ wplc_extra_data.msg_data = {};
423
+ if (typeof wplc_admin_agent_name !== "undefined")
424
+ wplc_extra_data.msg_data.aname = wplc_admin_agent_name;
425
+ if (typeof wplc_admin_agent_email !== "undefined")
426
+ wplc_extra_data.msg_data.aemail = wplc_admin_agent_email;
427
+
428
+
429
+
430
+ var data = {
431
+ action: 'wplc_admin_send_msg',
432
+ security: wplc_ajax_nonce,
433
+ cid: wplc_cid,
434
+ msg: wplc_chat_parsed,
435
+ wplc_extra_data:wplc_extra_data
436
+ };
437
+
438
+ if(typeof wplc_admin_agent_name !== "undefined"){
439
+ data.msg_from_print = wplc_admin_agent_name;
440
+ }
441
+
442
+ wplc_server.sendMessage(wplc_ajaxurl, data, "POST", 120000,
443
+ function(){
444
+ //Success
445
+ wplc_server.asyncStorage(wplc_ajaxurl, data, 120000);
446
+ }, function(){
447
+ //Fail
448
+ }, function(){
449
+ //Complete
450
+ }
451
+ );
452
+ }
453
+
454
+ });
455
+
456
+ });
457
+
458
+ /* Handles Uploading and sharing a file within chat*/
459
+ function wplcShareFile(fileToUpload, failedID, successID, uploadingID, originalID){
460
+ var formData = new FormData();
461
+
462
+ formData.append('action', 'wplc_upload_file');
463
+ formData.append('cid', cid);
464
+ formData.append('file', fileToUpload);
465
+ formData.append('timestamp', Date.now());
466
+ formData.append('security', wplc_ajax_nonce );
467
+
468
+ /*Handle jQuery Elements*/
469
+ jQuery(uploadingID).show();
470
+ jQuery(originalID).hide();
471
+ jQuery(successID).hide();
472
+ jQuery(failedID).hide();
473
+
474
+ if(fileToUpload.name.indexOf(".php") === -1 && fileToUpload.name.indexOf(".html") === -1 && fileToUpload.name.indexOf(".asp") === -1){
475
+ //Files allowed - continue
476
+ if(fileToUpload.size < 4000000){ //Max size of 4MB
477
+ jQuery.ajax({
478
+ url : wplc_home_ajaxurl,
479
+ type : 'POST',
480
+ data : formData,
481
+ cache: false,
482
+ processData: false,
483
+ contentType: false,
484
+ success : function(data) {
485
+ if(parseInt(data) !== 0){
486
+ jQuery(uploadingID).hide();
487
+ jQuery(successID).show();
488
+ setTimeout(function(){
489
+ jQuery(successID).hide();
490
+ jQuery(originalID).show();
491
+ }, 2000);
492
+
493
+ //All good post the link to file
494
+ var tag = (data.indexOf(".png") !== -1 || data.indexOf(".PNG") !== -1 || data.indexOf(".jpg") !== -1 || data.indexOf(".JPG") !== -1 || data.indexOf(".jpeg") !== -1 || data.indexOf(".gif") !== -1 || data.indexOf(".bmp")!== -1 ) ? "img" : "link";
495
+
496
+ if(tag !== "img"){
497
+ tag = (data.indexOf(".mp4") !== -1 || data.indexOf(".mpeg4") !== -1 || data.indexOf(".webm") !== -1 || data.indexOf(".oog") !== -1 ) ? "video" : "link"; //video now
498
+ }
499
+ jQuery("#wplc_admin_chatmsg").val(tag + ":" + data + ":" + tag); //Add to input field
500
+ jQuery("#wplc_admin_send_msg").trigger("click"); //Send message
501
+ }
502
+ else{
503
+ jQuery(uploadingID).hide();
504
+ jQuery(failedID).show();
505
+ setTimeout(function(){
506
+ jQuery(failedID).hide();
507
+ jQuery(originalID).show();
508
+ }, 2000);
509
+
510
+ }
511
+ },
512
+ error : function (){
513
+ jQuery(uploadingID).hide();
514
+ jQuery(failedID).show();
515
+ setTimeout(function(){
516
+ jQuery(failedID).hide();
517
+ jQuery(originalID).show();
518
+ }, 2000);
519
+ }
520
+ });
521
+ }else{
522
+ alert("File limit is 4mb");
523
+ jQuery(uploadingID).hide();
524
+ jQuery(failedID).show();
525
+ setTimeout(function(){
526
+ jQuery(failedID).hide();
527
+ jQuery(originalID).show();
528
+ }, 2000);
529
+ }
530
+ } else{
531
+ alert("File type not supported");
532
+ jQuery(uploadingID).hide();
533
+ jQuery(failedID).show();
534
+ setTimeout(function(){
535
+ jQuery(failedID).hide();
536
+ jQuery(originalID).show();
537
+ }, 2000);
538
+ }
539
  }
js/wplc_u_admin_events.js CHANGED
@@ -37,9 +37,9 @@ jQuery(function(){
37
  /* find closest server */
38
  bleeper_ping_servers(function(lowest_ping_index) {
39
 
40
- if(typeof bleeper_end_point_override !== "undefined"){
41
  /* use the override if we have set it */
42
- node_uri = bleeper_end_point_override; //Override
43
  } else {
44
  if (typeof bleeper_server_location !== "undefined") {
45
  // use this as the user selected the server in the settings
@@ -49,7 +49,7 @@ jQuery(function(){
49
  node_uri = bleeper_server_list[lowest_ping_index];
50
  }
51
  }
52
- if (window.console) { console.log("[Bleeper] Connecting to "+node_uri); }
53
  jQuery.event.trigger({type: "bleeper_dom_ready"});
54
 
55
  });
@@ -457,7 +457,7 @@ jQuery(document).on("bleeper_dom_ready", function(e) {
457
 
458
  jQuery(document).on("bleeper_add_initiate_button_no_col", function(e) {
459
 
460
- if(typeof bleeper_integration_pro_active === "undefined"){
461
  var tmp_chatid = typeof e.cid !== "undefined" ? e.cid : false;
462
 
463
  if(tmp_chatid !== false){
@@ -474,7 +474,7 @@ jQuery(document).on("bleeper_dom_ready", function(e) {
474
  });
475
 
476
  jQuery(document).on("bleeper_remove_initiate_button", function(e) {
477
- if(typeof bleeper_integration_pro_active === "undefined"){
478
  var tmp_chatid = typeof e.cid !== "undefined" ? e.cid : false;
479
  if(tmp_chatid !== false){
480
  jQuery('#vis'+ tmp_chatid + " #wplc_initiate_chat").remove();
37
  /* find closest server */
38
  bleeper_ping_servers(function(lowest_ping_index) {
39
 
40
+ if(typeof wplc_end_point_override !== "undefined"){
41
  /* use the override if we have set it */
42
+ node_uri = wplc_end_point_override; //Override
43
  } else {
44
  if (typeof bleeper_server_location !== "undefined") {
45
  // use this as the user selected the server in the settings
49
  node_uri = bleeper_server_list[lowest_ping_index];
50
  }
51
  }
52
+ if (window.console) { console.log("[WPLC] Connecting to "+node_uri); }
53
  jQuery.event.trigger({type: "bleeper_dom_ready"});
54
 
55
  });
457
 
458
  jQuery(document).on("bleeper_add_initiate_button_no_col", function(e) {
459
 
460
+ if(typeof wplc_integration_pro_active === "undefined"){
461
  var tmp_chatid = typeof e.cid !== "undefined" ? e.cid : false;
462
 
463
  if(tmp_chatid !== false){
474
  });
475
 
476
  jQuery(document).on("bleeper_remove_initiate_button", function(e) {
477
+ if(typeof wplc_integration_pro_active === "undefined"){
478
  var tmp_chatid = typeof e.cid !== "undefined" ? e.cid : false;
479
  if(tmp_chatid !== false){
480
  jQuery('#vis'+ tmp_chatid + " #wplc_initiate_chat").remove();
js/wplc_u_events.js CHANGED
@@ -328,8 +328,8 @@ jQuery(function() {
328
  /*Nifty format Parse*/
329
  var wplc_chat_parsed = wplc_chat;
330
 
331
- //if(typeof niftyFormatParser !== "undefined"){
332
- // wplc_chat_parsed = niftyFormatParser(wplc_chat_parsed);
333
  //}
334
 
335
  if( typeof wplc_display_name !== 'undefined' ){
328
  /*Nifty format Parse*/
329
  var wplc_chat_parsed = wplc_chat;
330
 
331
+ //if(typeof wplcFormatParser !== "undefined"){
332
+ // wplc_chat_parsed = wplcFormatParser(wplc_chat_parsed);
333
  //}
334
 
335
  if( typeof wplc_display_name !== 'undefined' ){
js/wplc_u_node_events.js CHANGED
@@ -1,526 +1,511 @@
1
-
2
- /**
3
- * Create an object so that we can track if we've displayed 'agent has joined' notices
4
- * @type {Object}
5
- */
6
- var agent_joined = {};
7
-
8
-
9
- /**
10
- * This disables the MongoDB storage engine on the Node server
11
- * @type {Boolean}
12
- */
13
- var bleeper_disable_mongo = true;
14
-
15
- jQuery(function() {
16
- bleeper_disable_mongo = true;
17
-
18
- /**
19
- * Set the bleeper override settings
20
- */
21
- bleeper_disable_add_message = true;
22
-
23
-
24
- jQuery(document).on("wplc_open_chat", function(e) {
25
- jQuery("#bleeper_chat_ended").html('').hide();
26
- nc_status = Cookies.get("nc_status");
27
- if (typeof nc_status === "undefined" || nc_status === "browsing") {
28
- /* show the part that requests name, email and department, etc */
29
- jQuery("#wp-live-chat-2").show();
30
- jQuery("#wp-live-chat-2-inner").show();
31
- var wplc_visitor_name = Cookies.get('wplc_name');
32
- if(Cookies.get('wplc_email') !== "no email set" && typeof wplc_visitor_name !== "undefined"){
33
- jQuery("#wplc_name").val(Cookies.get('wplc_name'));
34
- jQuery("#wplc_email").val(Cookies.get('wplc_email'));
35
- }
36
- jQuery("#wp-live-chat-header").addClass("active");
37
- } else if (nc_status === "active") {
38
- /* go straight into chat */
39
- Cookies.set('wplc_minimize', "", { expires: 1, path: '/' });
40
- jQuery.event.trigger({type: "wplc_open_chat_2", wplc_online: wplc_online});
41
-
42
-
43
- }
44
-
45
- });
46
-
47
- //Chat Notification
48
- jQuery(document).on("bleeper_user_chat_notification", function(e){
49
- if(typeof e.ndata !== "undefined"){
50
- if(typeof e.ndata.chatid !== "undefined" && typeof e.ndata.notification_text !== "undefined"){
51
- if(e.ndata.chatid === wplc_cid){
52
- the_message = {};
53
- the_message.msg = e.ndata.notification_text;
54
- the_message.originates = 0;
55
- the_message.other = {};
56
- wplc_push_message_to_chatbox(the_message, "u", function(){
57
- });
58
- }
59
- }
60
- }
61
- });
62
-
63
- jQuery(document).on("bleeper_socket_connected", function(e) {
64
- if (e.status === "active") {
65
- jQuery.event.trigger({type: "wplc_open_chat_2", wplc_online: wplc_online});
66
- }
67
- wplc_clear_system_notification();
68
- });
69
-
70
- /**
71
- * Handle the disconnect notice
72
- *
73
- * @return void
74
- */
75
- jQuery(document).on("bleeper_disconnected", function() {
76
- console.log('disconnected');
77
- if(typeof wplc_error_messages !== "undefined" && typeof wplc_error_messages['disconnected_message'] !== "undefined"){
78
- var the_message = wplc_generate_system_notification_object(wplc_error_messages['disconnected_message'], {}, 0);
79
- wplc_display_system_notification(the_message);
80
- }
81
- });
82
-
83
- jQuery(document).on("nifty_trigger_open_chat_2", function( e ) {
84
-
85
-
86
-
87
-
88
- });
89
-
90
- /**
91
- * Get chat messages from WP storage once the chat box init has been completed.
92
- *
93
- */
94
- jQuery(document).on("wplc_init_complete", function(e) {
95
- if (wplc_online && Cookies.get('bleeper_received_msg') === "true") {
96
- var data = {
97
- relay_action: 'wplc_get_messages',
98
- security: wplc_nonce,
99
- chat_id: wplc_cid,
100
- limit:50,
101
- offset:0,
102
- received_via: 'u',
103
- wplc_extra_data:wplc_extra_data
104
- };
105
- wplc_rest_api('get_messages', data, 12000, function(message_history) {
106
- if (typeof message_history.data !== "undefined" && typeof message_history.data.messages !== "undefined" && typeof message_history.data.messages === "object") {
107
- message_history = message_history.data.messages;
108
- for (var key in message_history) {
109
- var the_message = message_history[key];
110
- the_message.mid = key;
111
- wplc_push_message_to_chatbox(the_message,'u', function() {
112
- wplc_scroll_to_bottom();
113
- });
114
- }
115
- }
116
- });
117
- }
118
-
119
- var wplc_node_status_from_cookie = Cookies.get("nc_status");
120
- if(typeof wplc_node_status_from_cookie !== "undefined" && wplc_node_status_from_cookie === "active"){
121
- if(typeof wplc_cbox_animation !== "undefined"){
122
- wplc_cbox_animation();
123
- }
124
- }
125
-
126
- });
127
-
128
- /**
129
- * New message received from socket, add it to the DOM
130
- * @return void
131
- */
132
- jQuery(document).on("bleeper_new_message", function(e) {
133
-
134
- /**
135
- * set the bleeper_received_msg = true so that we can know when to /get_messages in the future
136
- */
137
- Cookies.set('bleeper_received_msg', true, { expires: 1, path: '/' });
138
-
139
- if (typeof e.ndata === "object") {
140
- if (typeof e.ndata.message === "undefined") { e.ndata.message = ''; }
141
-
142
- the_message = {};
143
- the_message.other = {};
144
-
145
- if (e.ndata.aoru === 'u') {
146
- the_message.originates = 2;
147
- } else {
148
- the_message.originates = 1;
149
- the_message.other.aid = e.ndata.aoru;
150
-
151
- }
152
-
153
- the_message.msg = wplc_strip(e.ndata.message);
154
- the_message.mid = e.ndata.msgID;
155
-
156
- var wplc_d = new Date();
157
- the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
158
- wplc_push_message_to_chatbox(the_message,'u', function() {
159
- wplc_scroll_to_bottom();
160
- });
161
-
162
- if (Cookies.get("wplc_minimize") === 'yes' && jQuery("#bleeper_bell").length > 0) {
163
- jQuery("#bleeper_bell").show();
164
- }
165
- }
166
- });
167
-
168
-
169
-
170
- jQuery(document).on("bleeper_send_message", function(e) {
171
- var wplc_chat = wplc_strip(e.message);
172
-
173
- /*
174
- the_message = {};
175
- the_message.originates = 2;
176
- the_message.msg = wplc_chat;
177
- the_message.other = {};
178
- var wplc_d = new Date();
179
- the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
180
- wplc_push_message_to_chatbox(the_message,'u', function() {
181
- wplc_scroll_to_bottom();
182
- });
183
- */
184
- var data = {
185
- relay_action: 'wplc_user_send_msg',
186
- security: wplc_nonce,
187
- chat_id: wplc_cid,
188
- message: wplc_chat,
189
- msg_id: e.msg_id,
190
- wplc_extra_data:wplc_extra_data
191
- };
192
-
193
- if(typeof wplc_chat === "string" && wplc_chat.trim() !== ""){
194
- /*
195
- * Will only send message if this is not empty string
196
- * This will resolve some issues with rest storage
197
- */
198
- wplc_rest_api('send_message', data, 12000, null);
199
- jQuery("#wplc_chatmsg").val('');
200
-
201
- if (typeof wplc_enable_ga !== "undefined" && wplc_enable_ga === '1') {
202
- if (typeof ga !== "undefined") {
203
- ga('send', {
204
- hitType: 'event',
205
- eventCategory: 'WP_Live_Chat_Support',
206
- eventAction: 'Event',
207
- eventLabel: 'User Send Message'
208
- });
209
- }
210
- }
211
- }
212
-
213
-
214
-
215
- jQuery.event.trigger({type: "wplc_update_gdpr_last_chat_id"});
216
-
217
- });
218
-
219
-
220
- /**
221
- * Handle the chat history object returned from the socket
222
- *
223
- * @return void
224
- */
225
- jQuery(document).on("bleeper_chat_history", function(e) {
226
- if (typeof e.ndata !== "undefined" && e.ndata !== null) {
227
-
228
- }
229
- });
230
-
231
- /**
232
- * Handle the agent joined event
233
- *
234
- * @return void
235
- */
236
- jQuery(document).on("bleeper_agent_joined", function(e) {
237
- if (typeof e.ndata !== "undefined" && typeof e.ndata === "object") {
238
- if (typeof agent_joined[parseInt(e.ndata.agent)] === "undefined") {
239
- the_message = wplc_generate_system_notification_object(e.ndata.agent_name+bleeper_localized_strings[0], {}, 0);
240
- wplc_push_message_to_chatbox(the_message,'u', function() {
241
- wplc_scroll_to_bottom();
242
- });
243
- agent_joined[parseInt(e.ndata.agent)] = true;
244
- }
245
-
246
- }
247
- });
248
-
249
- /**
250
- * Handle the agent left event
251
- *
252
- * @return void
253
- */
254
- jQuery(document).on("bleeper_agent_left", function(e) {
255
- if (typeof e.ndata !== "undefined" && typeof e.ndata === "object") {
256
- the_message = wplc_generate_system_notification_object(e.ndata.agent_name+bleeper_localized_strings[1], {}, 0);
257
- if (typeof agent_joined[parseInt(e.ndata.agent)] !== "undefined" && agent_joined[parseInt(e.ndata.agent)] === true) {
258
- agent_joined[parseInt(e.ndata.agent)] = undefined;
259
- wplc_push_message_to_chatbox(the_message,'u', function() {
260
- wplc_scroll_to_bottom();
261
- });
262
- }
263
-
264
- if (typeof wplc_enable_ga !== "undefined" && wplc_enable_ga === '1') {
265
- if (typeof ga !== "undefined") {
266
- ga('send', {
267
- hitType: 'event',
268
- eventCategory: 'WP_Live_Chat_Support',
269
- eventAction: 'Event',
270
- eventLabel: 'Agent left the chat'
271
- });
272
- }
273
- }
274
-
275
- }
276
- });
277
-
278
-
279
- jQuery(document).on("bleeper_chat_ended_notification", function(e) {
280
- if (typeof e.ndata !== "undefined" && typeof e.ndata === "object") {
281
- the_message = wplc_generate_system_notification_object(e.ndata.agent_name+bleeper_localized_strings[2], {}, 0);
282
- wplc_push_message_to_chatbox(the_message,'u', function() {
283
- wplc_scroll_to_bottom();
284
- });
285
- }
286
-
287
- if(typeof wplc_redirect_thank_you !== "undefined" && wplc_redirect_thank_you !== null && wplc_redirect_thank_you !== ""){
288
- window.location = wplc_redirect_thank_you;
289
- }
290
-
291
- if(jQuery('#wplc_gdpr_end_chat_notice_container').length > 0){
292
- jQuery("#wplc_gdpr_end_chat_notice_container").fadeIn('fast');
293
- }
294
-
295
- if (typeof wplc_enable_ga !== "undefined" && wplc_enable_ga === '1') {
296
- if (typeof ga !== "undefined") {
297
- ga('send', {
298
- hitType: 'event',
299
- eventCategory: 'WP_Live_Chat_Support',
300
- eventAction: 'Event',
301
- eventLabel: 'Chat Ended By Agent'
302
- });
303
- }
304
- }
305
- });
306
-
307
- /**
308
- * Handle the agent disconnected event
309
- *
310
- * @return void
311
- */
312
- jQuery(document).on("bleeper_agent_disconnected", function(e) {
313
- the_message = wplc_generate_system_notification_object(e.ndata.agent_name+bleeper_localized_strings[3], {}, 0);
314
- if (typeof agent_joined[parseInt(e.ndata.aid)] !== "undefined" && agent_joined[parseInt(e.ndata.aid)] === true) {
315
- agent_joined[parseInt(e.ndata.aid)] = undefined;
316
- wplc_push_message_to_chatbox(the_message,'u', function() {
317
- wplc_scroll_to_bottom();
318
- });
319
- }
320
-
321
- });
322
-
323
- /**
324
- * Custom data trigger
325
- *
326
- * If custom data is sent through the socket, this is where you would want to handle it
327
- *
328
- * @return void
329
- */
330
- jQuery(document).on("bleeper_custom_data_received", function(e) {
331
- if (typeof e.ndata !== "undefined") {
332
- if (typeof e.ndata.action !== "undefined") {
333
- if (e.ndata.action === "send_custom_header") {
334
-
335
- var temail = '';
336
- var tname = '';
337
- var taid = '';
338
- var ta_tagline = '';
339
- var ta_bio = '';
340
- var ta_social_links = '';
341
- if (typeof e.ndata.ndata.email !== "undefined") { temail = e.ndata.ndata.email; }
342
- if (typeof e.ndata.ndata.name !== "undefined") { tname = e.ndata.ndata.name; }
343
- if (typeof e.ndata.ndata.aid !== "undefined") { taid = e.ndata.ndata.aid; }
344
- if (typeof e.ndata.ndata.tagline !== "undefined") { ta_tagline = e.ndata.ndata.tagline; }
345
- if (typeof e.ndata.ndata.bio !== "undefined") { ta_bio = e.ndata.ndata.bio; }
346
- if (typeof e.ndata.ndata.social !== "undefined") { ta_social_links = e.ndata.ndata.social; }
347
-
348
-
349
-
350
- var data = {
351
- social_links: ta_social_links,
352
- agent_bio: ta_bio,
353
- agent_tagline: ta_tagline,
354
- aid: taid,
355
- email: temail,
356
- name: tname
357
- }
358
-
359
-
360
- jQuery.event.trigger({type: "wplc_agent_joined", ndata:{other:data}});
361
-
362
- if (typeof wplc_enable_ga !== "undefined" && wplc_enable_ga === '1') {
363
- if (typeof ga !== "undefined") {
364
- ga('send', {
365
- hitType: 'event',
366
- eventCategory: 'WP_Live_Chat_Support',
367
- eventAction: 'Event',
368
- eventLabel: 'Agent joined chat'
369
- });
370
- }
371
- }
372
- } else if(e.ndata.action === "send_user_direct_to_page"){
373
- if(typeof e.ndata.direction !== "undefined"){
374
- if(typeof e.ndata.pretty_name !== "undefined"){
375
- var link_url = e.ndata.pretty_name + " - " + e.ndata.direction;
376
-
377
- var notice = "<span> ";
378
- notice += (typeof e.ndata.agent_name !== "undefined" ? e.ndata.agent_name : "Agent") + " ";
379
- notice += (typeof bleeper_direct_to_page_localized_notice !== "undefined" ? bleeper_direct_to_page_localized_notice : "would like to direct you to the following page: ");
380
- notice += link_url;
381
- notice += " </span>";
382
-
383
- the_message = {};
384
- the_message.msg = notice;
385
- the_message.originates = 0;
386
- the_message.other = {};
387
- wplc_push_message_to_chatbox(the_message, "u", function(){
388
- });
389
- }
390
- }
391
- }
392
- }
393
-
394
- }
395
-
396
- });
397
-
398
-
399
- jQuery(document).on("bleeper_init_chat_box", function() {
400
-
401
- /* find out if we are actively involved in a chat, if yes, then open the chat window, unless the user has minimized it.. */
402
-
403
- nifty_chat_status_temp = Cookies.get("nc_status");
404
- if (typeof nifty_chat_status_temp !== "undefined" && nifty_chat_status_temp === "active" && !nifty_is_minimized) {
405
- open_chat(1);
406
- jQuery.event.trigger({type: "wplc_open_chat_2", wplc_online: wplc_online});
407
- } else {
408
- wplc_init_chat_box(false, false);
409
- }
410
-
411
-
412
- });
413
-
414
- jQuery(document).on("nifty_trigger_start_chat", function(e) {
415
- wplc_cookie_name = Cookies.get('wplc_name');
416
- wplc_cookie_email = Cookies.get('wplc_email');
417
-
418
- if( typeof wplc_cookie_name == 'undefined' ){ var wplc_cookie_name = jQuery( "#wp-live-chat" ).find( "#wplc_name" ).val(); }
419
- if( typeof wplc_cookie_email == 'undefined' ){ var wplc_cookie_email = jQuery( "#wp-live-chat" ).find( "#wplc_email" ).val(); }
420
-
421
-
422
- wplc_send_welcome_message();
423
-
424
- var start_data = {
425
- relay_action: 'wplc_new_chat',
426
- security: wplc_nonce,
427
- cid: wplc_cid,
428
- wplc_name: wplc_cookie_name,
429
- wplc_email: wplc_cookie_email,
430
- wplc_extra_data: {},
431
- url : window.location.href,
432
- session : wplc_session_variable
433
- };
434
-
435
-
436
-
437
- if(typeof wplc_start_chat_pro_custom_fields_filter !== "undefined" && typeof wplc_start_chat_pro_custom_fields_filter === "function"){
438
- wplc_start_chat_pro_custom_fields_filter(wplc_extra_data, start_data, function(passed_extra_data, passed_action_data){
439
- //Callback after processing custom field
440
- wplc_rest_api('start_chat', passed_action_data, 12000, null);
441
-
442
- });
443
- } else {
444
- start_data["wplc_extra_data"] = wplc_extra_data;
445
- wplc_rest_api('start_chat', start_data, 12000, null);
446
- }
447
-
448
- jQuery.event.trigger({type: "wplc_open_chat_2", wplc_online: wplc_online});
449
-
450
- if (typeof wplc_enable_ga !== "undefined" && wplc_enable_ga === '1') {
451
- if (typeof ga !== "undefined") {
452
- ga('send', {
453
- hitType: 'event',
454
- eventCategory: 'WP_Live_Chat_Support',
455
- eventAction: 'Event',
456
- eventLabel: 'Start Chat'
457
- });
458
- }
459
- }
460
-
461
- });
462
-
463
- if(typeof wplc_elem_trigger_id !== "undefined" && wplc_elem_trigger_id !== ""){
464
- var wplc_click_or_hover = 0;
465
- var wplc_class_or_id = 0;
466
-
467
- if(typeof wplc_elem_trigger_action !== "undefined" && wplc_elem_trigger_action !== ""){ wplc_click_or_hover = parseInt(wplc_elem_trigger_action); }
468
- if(typeof wplc_elem_trigger_type !== "undefined" && wplc_elem_trigger_type !== ""){ wplc_class_or_id = parseInt(wplc_elem_trigger_type); }
469
-
470
- try{
471
- jQuery( (wplc_class_or_id === 1 ? "#" : ".") + wplc_elem_trigger_id).on( (wplc_click_or_hover === 1 ? "mouseenter" : "click"), function(){
472
- open_chat(0);
473
- });
474
- } catch (e){
475
- console.log("WPLC Error: \"" + (wplc_class_or_id === 1 ? "#" : ".") + wplc_elem_trigger_id + "\" is not a valid selector");
476
- }
477
- }
478
-
479
-
480
- /** End Chat from User Side */
481
- jQuery(document).on("wplc_end_chat_as_user", function(e){
482
- if(typeof socket !== "undefined"){
483
- socket.emit('end chat', {chatid:chatid,agent:false,agent_name:'User', visitor_socket: socket.id});
484
- }
485
-
486
- data = { 'agent_name' : 'User'};
487
-
488
- jQuery.event.trigger({type: "bleeper_chat_ended_notification", ndata:data});
489
-
490
- jQuery('#bleeper_chat_ended').show();
491
- jQuery('.bleeper_restart_chat').remove();
492
- bleeper_end_chat_div_create();
493
-
494
-
495
- if (typeof user_heartbeat !== "undefined"){
496
- clearInterval(user_heartbeat);
497
- }
498
-
499
- user_heartbeat = undefined;
500
-
501
- socket.disconnect({test:'test'});
502
-
503
- niftyUpdateStatusCookie('browsing');
504
- // restart connection as a visitor
505
- if (typeof io !== "undefined") {
506
- socket = io.connect(NIFTY_SOCKET_URI, { query : query_string, transports: ['websocket'] } );
507
- nifty_chat_delegates();
508
- }
509
-
510
- if(typeof Cookies !== "undefined"){
511
- Cookies.remove("wplc_cid");
512
- }
513
-
514
- if (typeof wplc_enable_ga !== "undefined" && wplc_enable_ga === '1') {
515
- if (typeof ga !== "undefined") {
516
- ga('send', {
517
- hitType: 'event',
518
- eventCategory: 'WP_Live_Chat_Support',
519
- eventAction: 'Event',
520
- eventLabel: 'User End Chat'
521
- });
522
- }
523
- }
524
- });
525
- });
526
-
1
+
2
+ /**
3
+ * Create an object so that we can track if we've displayed 'agent has joined' notices
4
+ * @type {Object}
5
+ */
6
+ var agent_joined = {};
7
+
8
+ jQuery(function() {
9
+ jQuery(document).on("wplc_open_chat", function(e) {
10
+ jQuery("#bleeper_chat_ended").html('').hide();
11
+ nc_status = Cookies.get("nc_status");
12
+ if (typeof nc_status === "undefined" || nc_status === "browsing") {
13
+ /* show the part that requests name, email and department, etc */
14
+ jQuery("#wp-live-chat-2").show();
15
+ jQuery("#wp-live-chat-2-inner").show();
16
+ var wplc_visitor_name = Cookies.get('wplc_name');
17
+ if(Cookies.get('wplc_email') !== "no email set" && typeof wplc_visitor_name !== "undefined"){
18
+ jQuery("#wplc_name").val(Cookies.get('wplc_name'));
19
+ jQuery("#wplc_email").val(Cookies.get('wplc_email'));
20
+ }
21
+ jQuery("#wp-live-chat-header").addClass("active");
22
+ } else if (nc_status === "active") {
23
+ /* go straight into chat */
24
+ Cookies.set('wplc_minimize', "", { expires: 1, path: '/' });
25
+ jQuery.event.trigger({type: "wplc_open_chat_2", wplc_online: wplc_online});
26
+
27
+
28
+ }
29
+
30
+ });
31
+
32
+ //Chat Notification
33
+ jQuery(document).on("bleeper_user_chat_notification", function(e){
34
+ if(typeof e.ndata !== "undefined"){
35
+ if(typeof e.ndata.chatid !== "undefined" && typeof e.ndata.notification_text !== "undefined"){
36
+ if(e.ndata.chatid === wplc_cid){
37
+ the_message = {};
38
+ the_message.msg = e.ndata.notification_text;
39
+ the_message.originates = 0;
40
+ the_message.other = {};
41
+ wplc_push_message_to_chatbox(the_message, "u", function(){
42
+ });
43
+ }
44
+ }
45
+ }
46
+ });
47
+
48
+ jQuery(document).on("bleeper_socket_connected", function(e) {
49
+ if (e.status === "active") {
50
+ jQuery.event.trigger({type: "wplc_open_chat_2", wplc_online: wplc_online});
51
+ }
52
+ wplc_clear_system_notification();
53
+ });
54
+
55
+ /**
56
+ * Handle the disconnect notice
57
+ *
58
+ * @return void
59
+ */
60
+ jQuery(document).on("bleeper_disconnected", function() {
61
+ console.log('disconnected');
62
+ if(typeof wplc_error_messages !== "undefined" && typeof wplc_error_messages['disconnected_message'] !== "undefined"){
63
+ var the_message = wplc_generate_system_notification_object(wplc_error_messages['disconnected_message'], {}, 0);
64
+ wplc_display_system_notification(the_message);
65
+ }
66
+ });
67
+
68
+ jQuery(document).on("nifty_trigger_open_chat_2", function( e ) {
69
+
70
+
71
+
72
+
73
+ });
74
+
75
+ /**
76
+ * Get chat messages from WP storage once the chat box init has been completed.
77
+ *
78
+ */
79
+ jQuery(document).on("wplc_init_complete", function(e) {
80
+ if (wplc_online && Cookies.get('bleeper_received_msg') === "true") {
81
+ var data = {
82
+ relay_action: 'wplc_get_messages',
83
+ security: wplc_nonce,
84
+ chat_id: wplc_cid,
85
+ limit:50,
86
+ offset:0,
87
+ received_via: 'u',
88
+ wplc_extra_data:wplc_extra_data
89
+ };
90
+ wplc_rest_api('get_messages', data, 12000, function(message_history) {
91
+ if (typeof message_history.data !== "undefined" && typeof message_history.data.messages !== "undefined" && typeof message_history.data.messages === "object") {
92
+ message_history = message_history.data.messages;
93
+ for (var key in message_history) {
94
+ var the_message = message_history[key];
95
+ the_message.mid = key;
96
+ wplc_push_message_to_chatbox(the_message,'u', function() {
97
+ wplc_scroll_to_bottom();
98
+ });
99
+ }
100
+ }
101
+ });
102
+ }
103
+
104
+ var wplc_node_status_from_cookie = Cookies.get("nc_status");
105
+ if(typeof wplc_node_status_from_cookie !== "undefined" && wplc_node_status_from_cookie === "active"){
106
+ if(typeof wplc_cbox_animation !== "undefined"){
107
+ wplc_cbox_animation();
108
+ }
109
+ }
110
+
111
+ });
112
+
113
+ /**
114
+ * New message received from socket, add it to the DOM
115
+ * @return void
116
+ */
117
+ jQuery(document).on("bleeper_new_message", function(e) {
118
+
119
+ /**
120
+ * set the bleeper_received_msg = true so that we can know when to /get_messages in the future
121
+ */
122
+ Cookies.set('bleeper_received_msg', true, { expires: 1, path: '/' });
123
+
124
+ if (typeof e.ndata === "object") {
125
+ if (typeof e.ndata.message === "undefined") { e.ndata.message = ''; }
126
+
127
+ the_message = {};
128
+ the_message.other = {};
129
+
130
+ if (e.ndata.aoru === 'u') {
131
+ the_message.originates = 2;
132
+ } else {
133
+ the_message.originates = 1;
134
+ the_message.other.aid = e.ndata.aoru;
135
+
136
+ }
137
+
138
+ the_message.msg = wplc_strip(e.ndata.message);
139
+ the_message.mid = e.ndata.msgID;
140
+
141
+ var wplc_d = new Date();
142
+ the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
143
+ wplc_push_message_to_chatbox(the_message,'u', function() {
144
+ wplc_scroll_to_bottom();
145
+ });
146
+
147
+ if (Cookies.get("wplc_minimize") === 'yes' && jQuery("#bleeper_bell").length > 0) {
148
+ jQuery("#bleeper_bell").show();
149
+ }
150
+ }
151
+ });
152
+
153
+
154
+
155
+ jQuery(document).on("bleeper_send_message", function(e) {
156
+ var wplc_chat = wplc_strip(e.message);
157
+
158
+ /*
159
+ the_message = {};
160
+ the_message.originates = 2;
161
+ the_message.msg = wplc_chat;
162
+ the_message.other = {};
163
+ var wplc_d = new Date();
164
+ the_message.other.datetime = Math.round( wplc_d.getTime() / 1000 );
165
+ wplc_push_message_to_chatbox(the_message,'u', function() {
166
+ wplc_scroll_to_bottom();
167
+ });
168
+ */
169
+ var data = {
170
+ relay_action: 'wplc_user_send_msg',
171
+ security: wplc_nonce,
172
+ chat_id: wplc_cid,
173
+ message: wplc_chat,
174
+ msg_id: e.msg_id,
175
+ wplc_extra_data:wplc_extra_data
176
+ };
177
+
178
+ if(typeof wplc_chat === "string" && wplc_chat.trim() !== ""){
179
+ /*
180
+ * Will only send message if this is not empty string
181
+ * This will resolve some issues with rest storage
182
+ */
183
+ wplc_rest_api('send_message', data, 12000, null);
184
+ jQuery("#wplc_chatmsg").val('');
185
+
186
+ if (typeof wplc_enable_ga !== "undefined" && wplc_enable_ga === '1') {
187
+ if (typeof ga !== "undefined") {
188
+ ga('send', {
189
+ hitType: 'event',
190
+ eventCategory: 'WP_Live_Chat_Support',
191
+ eventAction: 'Event',
192
+ eventLabel: 'User Send Message'
193
+ });
194
+ }
195
+ }
196
+ }
197
+
198
+
199
+
200
+ jQuery.event.trigger({type: "wplc_update_gdpr_last_chat_id"});
201
+
202
+ });
203
+
204
+
205
+ /**
206
+ * Handle the chat history object returned from the socket
207
+ *
208
+ * @return void
209
+ */
210
+ jQuery(document).on("bleeper_chat_history", function(e) {
211
+ if (typeof e.ndata !== "undefined" && e.ndata !== null) {
212
+
213
+ }
214
+ });
215
+
216
+ /**
217
+ * Handle the agent joined event
218
+ *
219
+ * @return void
220
+ */
221
+ jQuery(document).on("bleeper_agent_joined", function(e) {
222
+ if (typeof e.ndata !== "undefined" && typeof e.ndata === "object") {
223
+ if (typeof agent_joined[parseInt(e.ndata.agent)] === "undefined") {
224
+ the_message = wplc_generate_system_notification_object(e.ndata.agent_name+bleeper_localized_strings[0], {}, 0);
225
+ wplc_push_message_to_chatbox(the_message,'u', function() {
226
+ wplc_scroll_to_bottom();
227
+ });
228
+ agent_joined[parseInt(e.ndata.agent)] = true;
229
+ }
230
+
231
+ }
232
+ });
233
+
234
+ /**
235
+ * Handle the agent left event
236
+ *
237
+ * @return void
238
+ */
239
+ jQuery(document).on("bleeper_agent_left", function(e) {
240
+ if (typeof e.ndata !== "undefined" && typeof e.ndata === "object") {
241
+ the_message = wplc_generate_system_notification_object(e.ndata.agent_name+bleeper_localized_strings[1], {}, 0);
242
+ if (typeof agent_joined[parseInt(e.ndata.agent)] !== "undefined" && agent_joined[parseInt(e.ndata.agent)] === true) {
243
+ agent_joined[parseInt(e.ndata.agent)] = undefined;
244
+ wplc_push_message_to_chatbox(the_message,'u', function() {
245
+ wplc_scroll_to_bottom();
246
+ });
247
+ }
248
+
249
+ if (typeof wplc_enable_ga !== "undefined" && wplc_enable_ga === '1') {
250
+ if (typeof ga !== "undefined") {
251
+ ga('send', {
252
+ hitType: 'event',
253
+ eventCategory: 'WP_Live_Chat_Support',
254
+ eventAction: 'Event',
255
+ eventLabel: 'Agent left the chat'
256
+ });
257
+ }
258
+ }
259
+
260
+ }
261
+ });
262
+
263
+
264
+ jQuery(document).on("bleeper_chat_ended_notification", function(e) {
265
+ if (typeof e.ndata !== "undefined" && typeof e.ndata === "object") {
266
+ the_message = wplc_generate_system_notification_object(e.ndata.agent_name+bleeper_localized_strings[2], {}, 0);
267
+ wplc_push_message_to_chatbox(the_message,'u', function() {
268
+ wplc_scroll_to_bottom();
269
+ });
270
+ }
271
+
272
+ if(typeof wplc_redirect_thank_you !== "undefined" && wplc_redirect_thank_you !== null && wplc_redirect_thank_you !== ""){
273
+ window.location = wplc_redirect_thank_you;
274
+ }
275
+
276
+ if(jQuery('#wplc_gdpr_end_chat_notice_container').length > 0){
277
+ jQuery("#wplc_gdpr_end_chat_notice_container").fadeIn('fast');
278
+ }
279
+
280
+ if (typeof wplc_enable_ga !== "undefined" && wplc_enable_ga === '1') {
281
+ if (typeof ga !== "undefined") {
282
+ ga('send', {
283
+ hitType: 'event',
284
+ eventCategory: 'WP_Live_Chat_Support',
285
+ eventAction: 'Event',
286
+ eventLabel: 'Chat Ended By Agent'
287
+ });
288
+ }
289
+ }
290
+ });
291
+
292
+ /**
293
+ * Handle the agent disconnected event
294
+ *
295
+ * @return void
296
+ */
297
+ jQuery(document).on("bleeper_agent_disconnected", function(e) {
298
+ the_message = wplc_generate_system_notification_object(e.ndata.agent_name+bleeper_localized_strings[3], {}, 0);
299
+ if (typeof agent_joined[parseInt(e.ndata.aid)] !== "undefined" && agent_joined[parseInt(e.ndata.aid)] === true) {
300
+ agent_joined[parseInt(e.ndata.aid)] = undefined;
301
+ wplc_push_message_to_chatbox(the_message,'u', function() {
302
+ wplc_scroll_to_bottom();
303
+ });
304
+ }
305
+
306
+ });
307
+
308
+ /**
309
+ * Custom data trigger
310
+ *
311
+ * If custom data is sent through the socket, this is where you would want to handle it
312
+ *
313
+ * @return void
314
+ */
315
+ jQuery(document).on("bleeper_custom_data_received", function(e) {
316
+ if (typeof e.ndata !== "undefined") {
317
+ if (typeof e.ndata.action !== "undefined") {
318
+ if (e.ndata.action === "send_custom_header") {
319
+
320
+ var temail = '';
321
+ var tname = '';
322
+ var taid = '';
323
+ var ta_tagline = '';
324
+ var ta_bio = '';
325
+ var ta_social_links = '';
326
+ if (typeof e.ndata.ndata.email !== "undefined") { temail = e.ndata.ndata.email; }
327
+ if (typeof e.ndata.ndata.name !== "undefined") { tname = e.ndata.ndata.name; }
328
+ if (typeof e.ndata.ndata.aid !== "undefined") { taid = e.ndata.ndata.aid; }
329
+ if (typeof e.ndata.ndata.tagline !== "undefined") { ta_tagline = e.ndata.ndata.tagline; }
330
+ if (typeof e.ndata.ndata.bio !== "undefined") { ta_bio = e.ndata.ndata.bio; }
331
+ if (typeof e.ndata.ndata.social !== "undefined") { ta_social_links = e.ndata.ndata.social; }
332
+
333
+
334
+
335
+ var data = {
336
+ social_links: ta_social_links,
337
+ agent_bio: ta_bio,
338
+ agent_tagline: ta_tagline,
339
+ aid: taid,
340
+ email: temail,
341
+ name: tname
342
+ }
343
+
344
+
345
+ jQuery.event.trigger({type: "wplc_agent_joined", ndata:{other:data}});
346
+
347
+ if (typeof wplc_enable_ga !== "undefined" && wplc_enable_ga === '1') {
348
+ if (typeof ga !== "undefined") {
349
+ ga('send', {
350
+ hitType: 'event',
351
+ eventCategory: 'WP_Live_Chat_Support',
352
+ eventAction: 'Event',
353
+ eventLabel: 'Agent joined chat'
354
+ });
355
+ }
356
+ }
357
+ } else if(e.ndata.action === "send_user_direct_to_page"){
358
+ if(typeof e.ndata.direction !== "undefined"){
359
+ if(typeof e.ndata.pretty_name !== "undefined"){
360
+ var link_url = e.ndata.pretty_name + " - " + e.ndata.direction;
361
+
362
+ var notice = "<span> ";
363
+ notice += (typeof e.ndata.agent_name !== "undefined" ? e.ndata.agent_name : "Agent") + " ";
364
+ notice += (typeof bleeper_direct_to_page_localized_notice !== "undefined" ? bleeper_direct_to_page_localized_notice : "would like to direct you to the following page: ");
365
+ notice += link_url;
366
+ notice += " </span>";
367
+
368
+ the_message = {};
369
+ the_message.msg = notice;
370
+ the_message.originates = 0;
371
+ the_message.other = {};
372
+ wplc_push_message_to_chatbox(the_message, "u", function(){
373
+ });
374
+ }
375
+ }
376
+ }
377
+ }
378
+
379
+ }
380
+
381
+ });
382
+
383
+
384
+ jQuery(document).on("bleeper_init_chat_box", function() {
385
+
386
+ /* find out if we are actively involved in a chat, if yes, then open the chat window, unless the user has minimized it.. */
387
+
388
+ nifty_chat_status_temp = Cookies.get("nc_status");
389
+ if (typeof nifty_chat_status_temp !== "undefined" && nifty_chat_status_temp === "active" && !nifty_is_minimized) {
390
+ open_chat(1);
391
+ jQuery.event.trigger({type: "wplc_open_chat_2", wplc_online: wplc_online});
392
+ } else {
393
+ wplc_init_chat_box(false, false);
394
+ }
395
+
396
+
397
+ });
398
+
399
+ jQuery(document).on("nifty_trigger_start_chat", function(e) {
400
+ wplc_cookie_name = Cookies.get('wplc_name');
401
+ wplc_cookie_email = Cookies.get('wplc_email');
402
+
403
+ if( typeof wplc_cookie_name == 'undefined' ){ var wplc_cookie_name = jQuery( "#wp-live-chat" ).find( "#wplc_name" ).val(); }
404
+ if( typeof wplc_cookie_email == 'undefined' ){ var wplc_cookie_email = jQuery( "#wp-live-chat" ).find( "#wplc_email" ).val(); }
405
+
406
+
407
+ wplc_send_welcome_message();
408
+
409
+ var start_data = {
410
+ relay_action: 'wplc_new_chat',
411
+ security: wplc_nonce,
412
+ cid: wplc_cid,
413
+ wplc_name: wplc_cookie_name,
414
+ wplc_email: wplc_cookie_email,
415
+ wplc_extra_data: {},
416
+ url : window.location.href,
417
+ session : wplc_session_variable
418
+ };
419
+
420
+
421
+
422
+ if(typeof wplc_start_chat_pro_custom_fields_filter !== "undefined" && typeof wplc_start_chat_pro_custom_fields_filter === "function"){
423
+ wplc_start_chat_pro_custom_fields_filter(wplc_extra_data, start_data, function(passed_extra_data, passed_action_data){
424
+ //Callback after processing custom field
425
+ wplc_rest_api('start_chat', passed_action_data, 12000, null);
426
+
427
+ });
428
+ } else {
429
+ start_data["wplc_extra_data"] = wplc_extra_data;
430
+ wplc_rest_api('start_chat', start_data, 12000, null);
431
+ }
432
+
433
+ jQuery.event.trigger({type: "wplc_open_chat_2", wplc_online: wplc_online});
434
+
435
+ if (typeof wplc_enable_ga !== "undefined" && wplc_enable_ga === '1') {
436
+ if (typeof ga !== "undefined") {
437
+ ga('send', {
438
+ hitType: 'event',
439
+ eventCategory: 'WP_Live_Chat_Support',
440
+ eventAction: 'Event',
441
+ eventLabel: 'Start Chat'
442
+ });
443
+ }
444
+ }
445
+
446
+ });
447
+
448
+ if(typeof wplc_elem_trigger_id !== "undefined" && wplc_elem_trigger_id !== ""){
449
+ var wplc_click_or_hover = 0;
450
+ var wplc_class_or_id = 0;
451
+
452
+ if(typeof wplc_elem_trigger_action !== "undefined" && wplc_elem_trigger_action !== ""){ wplc_click_or_hover = parseInt(wplc_elem_trigger_action); }
453
+ if(typeof wplc_elem_trigger_type !== "undefined" && wplc_elem_trigger_type !== ""){ wplc_class_or_id = parseInt(wplc_elem_trigger_type); }
454
+
455
+ try{
456
+ jQuery( (wplc_class_or_id === 1 ? "#" : ".") + wplc_elem_trigger_id).on( (wplc_click_or_hover === 1 ? "mouseenter" : "click"), function(){
457
+ open_chat(0);
458
+ });
459
+ } catch (e){
460
+ console.log("WPLC Error: \"" + (wplc_class_or_id === 1 ? "#" : ".") + wplc_elem_trigger_id + "\" is not a valid selector");
461
+ }
462
+ }
463
+
464
+
465
+ /** End Chat from User Side */
466
+ jQuery(document).on("wplc_end_chat_as_user", function(e){
467
+ if(typeof socket !== "undefined"){
468
+ socket.emit('end chat', {chatid:chatid,agent:false,agent_name:'User', visitor_socket: socket.id});
469
+ }
470
+
471
+ data = { 'agent_name' : 'User'};
472
+
473
+ jQuery.event.trigger({type: "bleeper_chat_ended_notification", ndata:data});
474
+
475
+ jQuery('#bleeper_chat_ended').show();
476
+ jQuery('.bleeper_restart_chat').remove();
477
+ bleeper_end_chat_div_create();
478
+
479
+
480
+ if (typeof user_heartbeat !== "undefined"){
481
+ clearInterval(user_heartbeat);
482
+ }
483
+
484
+ user_heartbeat = undefined;
485
+
486
+ socket.disconnect({test:'test'});
487
+
488
+ niftyUpdateStatusCookie('browsing');
489
+ // restart connection as a visitor
490
+ if (typeof io !== "undefined") {
491
+ socket = io.connect(WPLC_SOCKET_URI, { query : query_string, transports: ['websocket'] } );
492
+ wplc_chat_delegates();
493
+ }
494
+
495
+ if(typeof Cookies !== "undefined"){
496
+ Cookies.remove("wplc_cid");
497
+ }
498
+
499
+ if (typeof wplc_enable_ga !== "undefined" && wplc_enable_ga === '1') {
500
+ if (typeof ga !== "undefined") {
501
+ ga('send', {
502
+ hitType: 'event',
503
+ eventCategory: 'WP_Live_Chat_Support',
504
+ eventAction: 'Event',
505
+ eventLabel: 'User End Chat'
506
+ });
507
+ }
508
+ }
509
+ });
510
+ });
511
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/gdpr.php CHANGED
@@ -693,7 +693,7 @@ function wplc_gdpr_footer_mod( $footer_text ) {
693
  if(isset($_GET['page'])){
694
  if(strpos($_GET['page'], 'wplivechat') !== FALSE){
695
  $footer_text_addition = __( 'Please refer to our %%PRIVACY_LINK%% for information on Data Processing', 'wplivechat' );
696
- $footer_text_addition = str_replace("%%PRIVACY_LINK%%", "<a href='' target='_blank'>" . __(
697
  "Privacy Policy", "wplivechat") . "</a>", $footer_text_addition);
698
 
699
  return str_replace( '</span>', '', $footer_text ) . ' | ' . $footer_text_addition . '</span>';
693
  if(isset($_GET['page'])){
694
  if(strpos($_GET['page'], 'wplivechat') !== FALSE){
695
  $footer_text_addition = __( 'Please refer to our %%PRIVACY_LINK%% for information on Data Processing', 'wplivechat' );
696
+ $footer_text_addition = str_replace("%%PRIVACY_LINK%%", "<a href='https://wp-livechat.com/privacy-policy/' target='_blank'>" . __(
697
  "Privacy Policy", "wplivechat") . "</a>", $footer_text_addition);
698
 
699
  return str_replace( '</span>', '', $footer_text ) . ' | ' . $footer_text_addition . '</span>';
modules/node_server.php CHANGED
@@ -3,7 +3,7 @@
3
  * Node Code -> Insert pun here
4
  */
5
 
6
- define("BLEEPER_API_URL", "https://api.bleeper.io/app/api/v1.2/");
7
  define("BLEEPER_REMOTE_DASH_ROUTE", "remote_dashboard.php");
8
 
9
  define("BLEEPER_NODE_SERVER_URL", "https://bleeper.us-3.evennode.com");
@@ -370,7 +370,7 @@ add_action("wplc_hook_chat_dashboard_bottom","wplc_hook_control_dashboard_bottom
370
  function wplc_hook_control_dashboard_bottom_loading_logo() {
371
  $wplc_settings = get_option("WPLC_SETTINGS");
372
  if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
373
- echo "<div id='wplc_footer_loading_icon'><img src='https://bleeper.io/app/assets/images/wplc_loading.png' width='50' /><br />Connecting...</div>";
374
  }
375
  }
376
 
@@ -484,21 +484,21 @@ function wplc_admin_remote_dashboard_scripts($wplc_settings){
484
 
485
 
486
 
487
- wp_register_script('wplc-admin-js-sockets', "https://bleeper.io/app/assets/js/vendor/socket.io/socket.io.slim.js", false, $wplc_version, false);
488
  //wp_register_script('wplc-admin-js-sockets', trailingslashit( $bleeper_url ) . "socket.io/socket.io.js", false, $wplc_version, false);
489
  //wp_register_script('wplc-admin-js-sockets', "http://localhost:3000/socket.io/socket.io.js", false, $wplc_version, false);
490
  wp_enqueue_script('wplc-admin-js-sockets');
491
 
492
- wp_register_script('wplc-admin-js-bootstrap', "https://bleeper.io/app/assets/js/bootstrap.js", array("wplc-admin-js-sockets"), $wplc_version, false);
493
  wp_enqueue_script('wplc-admin-js-bootstrap');
494
 
495
  // NB: This causes Failed to initVars ReferenceError: wplc_show_date is not defined when uncommented and enabled
496
  if(empty($wplc_settings['wplc_disable_emojis']))
497
  {
498
- wp_register_script('wplc-admin-js-emoji', "https://bleeper.io/app/assets/wdt-emoji/emoji.min.js", array("wplc-admin-js-sockets"), $wplc_version, false);
499
  wp_enqueue_script('wplc-admin-js-emoji');
500
 
501
- wp_register_script('wplc-admin-js-emoji-bundle', "https://bleeper.io/app/assets/wdt-emoji/wdt-emoji-bundle.min.js", array("wplc-admin-js-emoji"), $wplc_version, false);
502
  wp_enqueue_script('wplc-admin-js-emoji-bundle');
503
  }
504
 
@@ -508,7 +508,7 @@ function wplc_admin_remote_dashboard_scripts($wplc_settings){
508
  $dependencies = array();
509
  if(empty($wplc_settings['wplc_disable_emojis']))
510
  $dependencies[] = "wplc-admin-js-emoji-bundle";
511
- wp_register_script('wplc-admin-js-agent', "https://bleeper.io/app/assets/js/bleeper-agent-dev.js", $dependencies, $wplc_version, false);
512
 
513
  wp_localize_script('wplc-admin-js-agent', 'bleeper_remote_enabled', "true");
514
 
@@ -599,9 +599,9 @@ function wplc_admin_remote_dashboard_scripts($wplc_settings){
599
 
600
  //For node verification
601
  if(function_exists("wplc_pro_activate")){
602
- wp_localize_script('wplc-admin-js-agent', 'bleeper_pro_auth', get_option('wp-live-chat-support-pro_key', "false"));
603
  } else {
604
- wp_localize_script('wplc-admin-js-agent', 'bleeper_pro_auth', 'false');
605
  }
606
  wp_localize_script('wplc-admin-js-agent', 'bleeper_agent_verification_end_point', rest_url('wp_live_chat_support/v1/validate_agent'));
607
  wp_localize_script('wplc-admin-js-agent', 'bleeper_disable_mongo', "true");
@@ -675,7 +675,7 @@ function wplc_admin_remote_dashboard_scripts($wplc_settings){
675
  /* use the end point override as the final decision for identifying the actual end point override variable */
676
  $wplc_end_point_override = get_option("wplc_end_point_override");
677
  if($wplc_end_point_override !== false && $wplc_end_point_override !== ""){
678
- wp_localize_script( 'wplc-admin-js-agent', 'bleeper_end_point_override', $wplc_end_point_override );
679
  }
680
 
681
  wp_localize_script( 'wplc-admin-js-agent', 'bleeper_new_chat_notification_title', __('New chat received', 'wplivechat') );
@@ -782,7 +782,7 @@ function wplc_admin_remote_dashboard_styles(){
782
 
783
  $wplc_settings = get_option("WPLC_SETTINGS");
784
 
785
- wp_register_style( 'wplc-admin-style', "https://bleeper.io/app/assets/css/chat_dashboard/admin_style.css", false, $wplc_version );
786
  wp_enqueue_style( 'wplc-admin-style' );
787
 
788
  if (!isset($wplc_settings['wplc_show_avatar']) || (isset($wplc_settings['wplc_show_avatar']) && intval($wplc_settings['wplc_show_avatar']) == 0) ) {
@@ -849,12 +849,12 @@ function wplc_admin_remote_dashboard_styles(){
849
  wp_add_inline_style( 'wplc-admin-style', $inline_identity_css );
850
  }
851
 
852
- wp_register_style( 'wplc-admin-style-bootstrap', "https://bleeper.io/app/assets/css/bootstrap.css", false, $wplc_version );
853
  wp_enqueue_style( 'wplc-admin-style-bootstrap' );
854
 
855
  if(empty($wplc_settings['wplc_disable_emojis']))
856
  {
857
- wp_register_style( 'wplc-admin-style-emoji', "https://bleeper.io/app/assets/wdt-emoji/wdt-emoji-bundle.css", false, $wplc_version );
858
  wp_enqueue_style( 'wplc-admin-style-emoji' );
859
  }
860
 
@@ -915,7 +915,7 @@ function wplc_node_compat_version_check(){
915
  ?>
916
  <div class="<?php echo ($is_dashboard ? "" : "update-nag"); ?>" id="wplc_offline_mode_prompt_container" style='margin-top:5px;margin-bottom:5px;<?php echo ($is_dashboard ? "display:none; " : ""); ?>'>
917
  <div style="display: inline-block; width: 80px; position: absolute; padding-top: 1em;">
918
- <img src="https://bleeper.io/app/assets/images/wplc_loading.png" />
919
  </div>
920
  <div style="display: inline-block; margin-left: 80px;">
921
  <p style="display: none;"><strong id="wplc_offline_mode_prompt"><?php _e("WP Live Chat Support - Offline Mode", "wplivechat") ?></strong></p>
@@ -969,7 +969,7 @@ function wplc_node_compat_pro_update_nag_content(){
969
  * Returns true or false
970
  */
971
  function wplc_node_compat_pro_api_key_is_valid_post(){
972
- $wplc_pro_validation_url = "http://ccplugins.co/api-control/";
973
  $wplc_pro_option_key = "wp-live-chat-support-pro_key";
974
  $wplc_pro_slug = "wp-live-chat-support-pro";
975
  $is_valid = false; //By default it is false
3
  * Node Code -> Insert pun here
4
  */
5
 
6
+ define("BLEEPER_API_URL", "https://update.wp-livechat.com/remote_files/");
7
  define("BLEEPER_REMOTE_DASH_ROUTE", "remote_dashboard.php");
8
 
9
  define("BLEEPER_NODE_SERVER_URL", "https://bleeper.us-3.evennode.com");
370
  function wplc_hook_control_dashboard_bottom_loading_logo() {
371
  $wplc_settings = get_option("WPLC_SETTINGS");
372
  if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
373
+ echo "<div id='wplc_footer_loading_icon'><img src='https://update.wp-livechat.com/remote_files/assets/images/wplc_loading.png' width='50' /><br />Connecting...</div>";
374
  }
375
  }
376
 
484
 
485
 
486
 
487
+ wp_register_script('wplc-admin-js-sockets', "https://update.wp-livechat.com/remote_files/assets/js/vendor/socket.io/socket.io.slim.js", false, $wplc_version, false);
488
  //wp_register_script('wplc-admin-js-sockets', trailingslashit( $bleeper_url ) . "socket.io/socket.io.js", false, $wplc_version, false);
489
  //wp_register_script('wplc-admin-js-sockets', "http://localhost:3000/socket.io/socket.io.js", false, $wplc_version, false);
490
  wp_enqueue_script('wplc-admin-js-sockets');
491
 
492
+ wp_register_script('wplc-admin-js-bootstrap', "https://update.wp-livechat.com/remote_files/assets/js/vendor/bootstrap/dist/js/bootstrap.js", array("wplc-admin-js-sockets"), $wplc_version, false);
493
  wp_enqueue_script('wplc-admin-js-bootstrap');
494
 
495
  // NB: This causes Failed to initVars ReferenceError: wplc_show_date is not defined when uncommented and enabled
496
  if(empty($wplc_settings['wplc_disable_emojis']))
497
  {
498
+ wp_register_script('wplc-admin-js-emoji', "https://update.wp-livechat.com/remote_files/assets/wdt-emoji/emoji.min.js", array("wplc-admin-js-sockets"), $wplc_version, false);
499
  wp_enqueue_script('wplc-admin-js-emoji');
500
 
501
+ wp_register_script('wplc-admin-js-emoji-bundle', "https://update.wp-livechat.com/remote_files/assets/wdt-emoji/wdt-emoji-bundle.min.js", array("wplc-admin-js-emoji"), $wplc_version, false);
502
  wp_enqueue_script('wplc-admin-js-emoji-bundle');
503
  }
504
 
508
  $dependencies = array();
509
  if(empty($wplc_settings['wplc_disable_emojis']))
510
  $dependencies[] = "wplc-admin-js-emoji-bundle";
511
+ wp_register_script('wplc-admin-js-agent', "https://update.wp-livechat.com/remote_files/assets/js/wplc_agent_node.js", $dependencies, $wplc_version, false);
512
 
513
  wp_localize_script('wplc-admin-js-agent', 'bleeper_remote_enabled', "true");
514
 
599
 
600
  //For node verification
601
  if(function_exists("wplc_pro_activate")){
602
+ wp_localize_script('wplc-admin-js-agent', 'wplc_pro_auth', get_option('wp-live-chat-support-pro_key', "false"));
603
  } else {
604
+ wp_localize_script('wplc-admin-js-agent', 'wplc_pro_auth', 'false');
605
  }
606
  wp_localize_script('wplc-admin-js-agent', 'bleeper_agent_verification_end_point', rest_url('wp_live_chat_support/v1/validate_agent'));
607
  wp_localize_script('wplc-admin-js-agent', 'bleeper_disable_mongo', "true");
675
  /* use the end point override as the final decision for identifying the actual end point override variable */
676
  $wplc_end_point_override = get_option("wplc_end_point_override");
677
  if($wplc_end_point_override !== false && $wplc_end_point_override !== ""){
678
+ wp_localize_script( 'wplc-admin-js-agent', 'wplc_end_point_override', $wplc_end_point_override );
679
  }
680
 
681
  wp_localize_script( 'wplc-admin-js-agent', 'bleeper_new_chat_notification_title', __('New chat received', 'wplivechat') );
782
 
783
  $wplc_settings = get_option("WPLC_SETTINGS");
784
 
785
+ wp_register_style( 'wplc-admin-style', "https://update.wp-livechat.com/remote_files/assets/css/chat_dashboard/admin_style.css", false, $wplc_version );
786
  wp_enqueue_style( 'wplc-admin-style' );
787
 
788
  if (!isset($wplc_settings['wplc_show_avatar']) || (isset($wplc_settings['wplc_show_avatar']) && intval($wplc_settings['wplc_show_avatar']) == 0) ) {
849
  wp_add_inline_style( 'wplc-admin-style', $inline_identity_css );
850
  }
851
 
852
+ wp_register_style( 'wplc-admin-style-bootstrap', "https://update.wp-livechat.com/remote_files/assets/css/bootstrap.css", false, $wplc_version );
853
  wp_enqueue_style( 'wplc-admin-style-bootstrap' );
854
 
855
  if(empty($wplc_settings['wplc_disable_emojis']))
856
  {
857
+ wp_register_style( 'wplc-admin-style-emoji', "https://update.wp-livechat.com/remote_files/assets/wdt-emoji/wdt-emoji-bundle.css", false, $wplc_version );
858
  wp_enqueue_style( 'wplc-admin-style-emoji' );
859
  }
860
 
915
  ?>
916
  <div class="<?php echo ($is_dashboard ? "" : "update-nag"); ?>" id="wplc_offline_mode_prompt_container" style='margin-top:5px;margin-bottom:5px;<?php echo ($is_dashboard ? "display:none; " : ""); ?>'>
917
  <div style="display: inline-block; width: 80px; position: absolute; padding-top: 1em;">
918
+ <img src="https://update.wp-livechat.com/remote_files/assets/images/wplc_loading.png" />
919
  </div>
920
  <div style="display: inline-block; margin-left: 80px;">
921
  <p style="display: none;"><strong id="wplc_offline_mode_prompt"><?php _e("WP Live Chat Support - Offline Mode", "wplivechat") ?></strong></p>
969
  * Returns true or false
970
  */
971
  function wplc_node_compat_pro_api_key_is_valid_post(){
972
+ $wplc_pro_validation_url = "https://update.wp-livechat.com/auth_api/api-control/";
973
  $wplc_pro_option_key = "wp-live-chat-support-pro_key";
974
  $wplc_pro_slug = "wp-live-chat-support-pro";
975
  $is_valid = false; //By default it is false
readme.txt CHANGED
@@ -220,6 +220,9 @@ If the live chat box still does not appear on your website, please go through th
220
 
221
  == Upgrade Notice ==
222
 
 
 
 
223
  = 8.0.20 =
224
  It is highly recommended that you upgrade to WP Live Chat Support version 8.0.20 for performance reasons.
225
 
@@ -258,6 +261,11 @@ We have patched the PHPMailer vulnerability. Please update to version 7.0.02.
258
 
259
 
260
  == Changelog ==
 
 
 
 
 
261
  = 8.0.24 - 2019-03-04 - Medium priority =
262
  * Added styling settings hook.
263
  * Added Slovenian translation files. Thanks to Zarko Germek
220
 
221
  == Upgrade Notice ==
222
 
223
+ = 8.0.25 =
224
+ It is highly recommended that you upgrade to WP Live Chat Support version 8.0.25 for stability reasons.
225
+
226
  = 8.0.20 =
227
  It is highly recommended that you upgrade to WP Live Chat Support version 8.0.20 for performance reasons.
228
 
261
 
262
 
263
  == Changelog ==
264
+ = 8.0.25 - 2019-03-19 - Medium priority =
265
+ * Modified server integration code
266
+ * Modified remote file sources
267
+ * Added update notice to ensure stability
268
+
269
  = 8.0.24 - 2019-03-04 - Medium priority =
270
  * Added styling settings hook.
271
  * Added Slovenian translation files. Thanks to Zarko Germek
wp-live-chat-support.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Live Chat Support
4
  Plugin URI: http://www.wp-livechat.com
5
  Description: The easiest to use website live chat plugin. Let your visitors chat with you and increase sales conversion rates with WP Live Chat Support.
6
- Version: 8.0.24
7
  Author: WP-LiveChat
8
  Author URI: http://www.wp-livechat.com
9
  Text Domain: wplivechat
@@ -11,6 +11,11 @@
11
  */
12
 
13
  /**
 
 
 
 
 
14
  * 8.0.24 - 2019-03-04 - Medium priority
15
  * Added styling settings hook.
16
  * Added Slovenian translation files. Thanks to Zarko Germek
@@ -137,7 +142,7 @@ global $debug_start;
137
  $wplc_tblname_offline_msgs = $wpdb->prefix . "wplc_offline_messages";
138
  $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
139
  $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
140
- $wplc_version = "8.0.24";
141
 
142
  define('WPLC_BASIC_PLUGIN_DIR', dirname(__FILE__));
143
  define('WPLC_BASIC_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
@@ -735,7 +740,7 @@ function wplc_push_js_to_front_basic() {
735
  $bleeper_url = BLEEPER_NODE_SERVER_URL;
736
  }
737
  //wp_register_script('wplc-node-server-script', trailingslashit( $bleeper_url ) . "socket.io/socket.io.js", array('jquery'), $wplc_version);
738
- wp_register_script('wplc-node-server-script', "https://bleeper.io/app/assets/js/vendor/socket.io/socket.io.slim.js", array('jquery'), $wplc_version);
739
 
740
 
741
  //wp_register_script('wplc-node-server-script', 'http://localhost:3000/socket.io/socket.io.js', array('jquery'), $wplc_version);
@@ -769,28 +774,28 @@ function wplc_push_js_to_front_basic() {
769
 
770
  $wplc_end_point_override = get_option("wplc_end_point_override");
771
  if($wplc_end_point_override !== false && $wplc_end_point_override !== ""){
772
- wp_localize_script( 'wplc-server-script', 'bleeper_end_point_override', $wplc_end_point_override );
773
  }
774
  //For node verification
775
  if(function_exists("wplc_pro_activate")){
776
- wp_localize_script('wplc-server-script', 'bleeper_pro_auth', get_option('wp-live-chat-support-pro_key', "false"));
777
  } else {
778
- wp_localize_script('wplc-server-script', 'bleeper_pro_auth', 'false');
779
  }
780
 
781
 
782
 
783
  //Emoji Libs
784
  if(empty($wplc_settings['wplc_disable_emojis'])) {
785
- //wp_register_script('wplc-user-js-emoji', "https://bleeper.io/app/assets/wdt-emoji/emoji.min.js", array("wplc-server-script", "wplc-server-script"), $wplc_version, false);
786
  //wp_enqueue_script('wplc-user-js-emoji');
787
- //wp_register_script('wplc-user-js-emoji-bundle', "https://bleeper.io/app/assets/wdt-emoji/wdt-emoji-bundle.min.js", array("wplc-server-script", "wplc-server-script", "wplc-user-js-emoji"), $wplc_version, false);
788
  //wp_enqueue_script('wplc-user-js-emoji-bundle');
789
 
790
- wp_register_script('wplc-user-js-emoji-concat', "https://bleeper.io/app/assets/wdt-emoji/wdt-emoji-concat.min.js", array("wplc-server-script", "wplc-server-script"), $wplc_version, false);
791
  wp_enqueue_script('wplc-user-js-emoji-concat');
792
 
793
- wp_register_style( 'wplc-admin-style-emoji', "https://bleeper.io/app/assets/wdt-emoji/wdt-emoji-bundle.css", false, $wplc_version );
794
  wp_enqueue_style( 'wplc-admin-style-emoji' );
795
  }
796
 
@@ -2563,9 +2568,6 @@ function wplc_admin_output_js() {
2563
  }
2564
 
2565
  function wplc_admin_menu_layout() {
2566
-
2567
-
2568
-
2569
 
2570
  do_action("wplc_hook_admin_menu_layout");
2571
  if (function_exists("wplc_register_pro_version")) {
@@ -2582,7 +2584,8 @@ function wplc_admin_menu_layout() {
2582
 
2583
  </div>
2584
  <?php
2585
- }
 
2586
  $wplc_ver = str_replace('.', '', $wplc_pro_version);
2587
  $wplc_ver = intval($wplc_ver);
2588
  if ($wplc_ver < 501) {
@@ -2603,7 +2606,32 @@ function wplc_admin_menu_layout() {
2603
  </div>
2604
  <?php
2605
  }
2606
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2607
  if ( ( get_option("WPLC_V8_FIRST_TIME") == true && !class_exists("APC_Object_Cache") ) || ( isset( $_GET['action'] ) && ( $_GET['action'] == 'welcome' || $_GET['action'] == 'credits' ) ) ){
2608
  include 'includes/welcome_page.php';
2609
  update_option('WPLC_V8_FIRST_TIME', false);
@@ -4536,7 +4564,7 @@ function wplc_extensions_menu() {
4536
  ?>
4537
  <h2 class="nav-tab-wrapper">
4538
  <a href="admin.php?page=wplivechat-menu-extensions-page" title="<?php _e("Add-ons","wplivechat"); ?>" class="nav-tab <?php echo $normal; ?>"><?php _e("Add-ons","wplivechat"); ?></a><a href="admin.php?page=wplivechat-menu-extensions-page&type=additional" title="<?php _e("Suggested Plugins","wplivechat"); ?>" class="nav-tab <?php echo $additional; ?>"><?php _e("Suggested Plugins","wplivechat"); ?></a>
4539
- <span style='float: right; bottom:-5px; position: relative;'><img src='<?php echo plugins_url('/images/codecabin.png', __FILE__); ?>' style="height:15px;" /></span>
4540
  </h2>
4541
  <div id="tab_container">
4542
 
@@ -4609,7 +4637,7 @@ function wplc_extensions_menu() {
4609
  echo "</div></p>";
4610
 
4611
 
4612
- $response = wp_remote_post( "https://ccplugins.co/api-wplc-extensions", array(
4613
  'method' => 'POST',
4614
  'body' => array(
4615
  'action' => 'extensions',
@@ -4769,7 +4797,7 @@ function wplc_footer_mod( $footer_text ) {
4769
  'https://wordpress.org/support/view/plugin-reviews/wp-live-chat-support?filter=5#postform'
4770
  );
4771
 
4772
- return str_replace( '</span>', '', $footer_text ) . ' | ' . $footer_text_mod . ' | ' . __('WP Live Chat Support is a product of','wplivechat') . ' <a target="_BLANK" href="http://codecabin.co.za/?utm_source=livechat&utm_medium=link&utm_campaign=footer" border="0"><img src="'.plugins_url('/images/codecabin.png', __FILE__).'" style="height:10px;"/></span></a>';
4773
  } else {
4774
  return $footer_text;
4775
  }
@@ -5005,44 +5033,44 @@ function wplc_get_chat_messages($cid, $only_read_messages = false, $wplc_setting
5005
  */
5006
  function wplc_build_api_check($page_content, $data) {
5007
  $link = "#";
5008
- $image = "https://ccplugins.co/api-wplc-extensions/images/add-on0.jpg";
5009
  if ($data['string'] == "Multiple Agents") {
5010
  $link = "";
5011
- $image = "https://ccplugins.co/api-wplc-extensions/images/Agents-Small.jpg";
5012
  }
5013
  if ($data['string'] == "Cloud Server") {
5014
  $link = "";
5015
- $image = "https://ccplugins.co/api-wplc-extensions/images/Cloud-Small.jpg";
5016
  }
5017
  if ($data['string'] == "Advanced Chat Box Control") {
5018
  $link = "https://wp-livechat.com/extensions/advanced-chat-control/";
5019
- $image = "https://ccplugins.co/api-wplc-extensions/images/AdvancedChatBox-Small.jpg";
5020
  }
5021
  if ($data['string'] == "Choose When Online") {
5022
  $link = "";
5023
- $image = "https://ccplugins.co/api-wplc-extensions/images/ChooseOnline-Small.jpg";
5024
  }
5025
  if ($data['string'] == "Encryption") {
5026
  $link = "";
5027
- $image = "https://ccplugins.co/api-wplc-extensions/images/Encryption-Small.jpg";
5028
  }
5029
  if ($data['string'] == "Mobile and Desktop App") {
5030
  $link = "";
5031
- $image = "https://ccplugins.co/api-wplc-extensions/images/MobileDesktop-Small.jpg";
5032
  }
5033
  if ($data['string'] == "Initiate Chats") {
5034
  $link = "";
5035
- $image = "https://ccplugins.co/api-wplc-extensions/images/InitiateChat-Small.jpg";
5036
  }
5037
  if ($data['string'] == "Include Exclude Pages") {
5038
  $link = "";
5039
- $image = "https://ccplugins.co/api-wplc-extensions/images/IncludeAndExclude-Small.jpg";
5040
  }
5041
 
5042
 
5043
  if ($data['string'] == "WP Live Chat Support Pro") {
5044
  $link = "";
5045
- $image = "https://ccplugins.co/api-wplc-extensions/images/add-on0.jpg";
5046
  }
5047
 
5048
 
@@ -5099,7 +5127,7 @@ function wplc_filter_control_relevant_extensions_main_proe($text) {
5099
  if (function_exists("wplc_hook_control_intiate_check")) { return $text; }
5100
 
5101
  $rel_name = __("Pro Add-on","wplivechat");
5102
- $rel_image = "https://ccplugins.co/api-wplc-extensions/images/add-on0.jpg";
5103
  $rel_link = "http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=relevant_pro";
5104
  $text .= '<div class="wplc-extension relevant_extension">';
5105
  $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" target="_BLANK" style="float:left;">';
@@ -5126,7 +5154,7 @@ function wplc_filter_control_relevant_extensions_main_mobile($text) {
5126
  if (function_exists("wplc_mobile_check_if_logged_in")) { return $text; }
5127
 
5128
  $rel_name = __("Mobile & Desktop App","wplivechat");
5129
- $rel_image = "https://ccplugins.co/api-wplc-extensions/images/MobileDesktop-Icon.jpg";
5130
  $rel_link = "https://wp-livechat.com/extensions/mobile-desktop-app-extension/?utm_source=plugin&amp;utm_medium=link&amp;utm_campaign=relevant_mobile";
5131
  $text .= '<div class="wplc-extension relevant_extension">';
5132
  $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" target="_BLANK" style="float:left;">';
@@ -5153,7 +5181,7 @@ function wplc_filter_control_relevant_extensions_chatbox_proe($text) {
5153
  if (function_exists("wplc_hook_control_intiate_check")) { return $text; }
5154
 
5155
  $rel_name = __("Pro Add-on","wplivechat");
5156
- $rel_image = "https://ccplugins.co/api-wplc-extensions/images/add-on0.jpg";
5157
  $rel_link = "http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=relevant_pro_chatbox";
5158
  $text .= '<div class="wplc-extension relevant_extension">';
5159
  $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" target="_BLANK" style="float:left;">';
@@ -5559,7 +5587,7 @@ function wplc_hook_control_admin_settings_chat_box_settings_after() {
5559
  </tr>
5560
  <tr>
5561
  <td valign='top'>
5562
- <?php _e("Long poll setup","wplivechat"); ?>: <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e("Only change these if you are an experienced developer or if you have received these figures from the Code Cabin Support team.", "wplivechat") ?>"></i>
5563
  </td>
5564
  <td valign='top'>
5565
  <?php
3
  Plugin Name: WP Live Chat Support
4
  Plugin URI: http://www.wp-livechat.com
5
  Description: The easiest to use website live chat plugin. Let your visitors chat with you and increase sales conversion rates with WP Live Chat Support.
6
+ Version: 8.0.25
7
  Author: WP-LiveChat
8
  Author URI: http://www.wp-livechat.com
9
  Text Domain: wplivechat
11
  */
12
 
13
  /**
14
+ * 8.0.25 - 2019-03-19 - Medium priority
15
+ * Modified server integration code
16
+ * Modified remote file sources
17
+ * Added update notice to ensure stability
18
+ *
19
  * 8.0.24 - 2019-03-04 - Medium priority
20
  * Added styling settings hook.
21
  * Added Slovenian translation files. Thanks to Zarko Germek
142
  $wplc_tblname_offline_msgs = $wpdb->prefix . "wplc_offline_messages";
143
  $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
144
  $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
145
+ $wplc_version = "8.0.25";
146
 
147
  define('WPLC_BASIC_PLUGIN_DIR', dirname(__FILE__));
148
  define('WPLC_BASIC_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
740
  $bleeper_url = BLEEPER_NODE_SERVER_URL;
741
  }
742
  //wp_register_script('wplc-node-server-script', trailingslashit( $bleeper_url ) . "socket.io/socket.io.js", array('jquery'), $wplc_version);
743
+ wp_register_script('wplc-node-server-script', "https://update.wp-livechat.com/remote_files/assets/js/vendor/socket.io/socket.io.slim.js", array('jquery'), $wplc_version);
744
 
745
 
746
  //wp_register_script('wplc-node-server-script', 'http://localhost:3000/socket.io/socket.io.js', array('jquery'), $wplc_version);
774
 
775
  $wplc_end_point_override = get_option("wplc_end_point_override");
776
  if($wplc_end_point_override !== false && $wplc_end_point_override !== ""){
777
+ wp_localize_script( 'wplc-server-script', 'wplc_end_point_override', $wplc_end_point_override );
778
  }
779
  //For node verification
780
  if(function_exists("wplc_pro_activate")){
781
+ wp_localize_script('wplc-server-script', 'wplc_pro_auth', get_option('wp-live-chat-support-pro_key', "false"));
782
  } else {
783
+ wp_localize_script('wplc-server-script', 'wplc_pro_auth', 'false');
784
  }
785
 
786
 
787
 
788
  //Emoji Libs
789
  if(empty($wplc_settings['wplc_disable_emojis'])) {
790
+ //wp_register_script('wplc-user-js-emoji', "https://update.wp-livechat.com/remote_files/assets/wdt-emoji/emoji.min.js", array("wplc-server-script", "wplc-server-script"), $wplc_version, false);
791
  //wp_enqueue_script('wplc-user-js-emoji');
792
+ //wp_register_script('wplc-user-js-emoji-bundle', "https://update.wp-livechat.com/remote_files/assets/wdt-emoji/wdt-emoji-bundle.min.js", array("wplc-server-script", "wplc-server-script", "wplc-user-js-emoji"), $wplc_version, false);
793
  //wp_enqueue_script('wplc-user-js-emoji-bundle');
794
 
795
+ wp_register_script('wplc-user-js-emoji-concat', "https://update.wp-livechat.com/remote_files/assets/wdt-emoji/wdt-emoji-concat.min.js", array("wplc-server-script", "wplc-server-script"), $wplc_version, false);
796
  wp_enqueue_script('wplc-user-js-emoji-concat');
797
 
798
+ wp_register_style( 'wplc-admin-style-emoji', "https://update.wp-livechat.com/remote_files/assets/wdt-emoji/wdt-emoji-bundle.css", false, $wplc_version );
799
  wp_enqueue_style( 'wplc-admin-style-emoji' );
800
  }
801
 
2568
  }
2569
 
2570
  function wplc_admin_menu_layout() {
 
 
 
2571
 
2572
  do_action("wplc_hook_admin_menu_layout");
2573
  if (function_exists("wplc_register_pro_version")) {
2584
 
2585
  </div>
2586
  <?php
2587
+ }
2588
+
2589
  $wplc_ver = str_replace('.', '', $wplc_pro_version);
2590
  $wplc_ver = intval($wplc_ver);
2591
  if ($wplc_ver < 501) {
2606
  </div>
2607
  <?php
2608
  }
2609
+ }
2610
+
2611
+ if(function_exists('wplc_pro_activate')){
2612
+ global $wplc_pro_version;
2613
+
2614
+ $wplc_pro_version_number = str_replace('.', '', $wplc_pro_version);
2615
+ $wplc_pro_version_number = intval($wplc_pro_version_number);
2616
+
2617
+ if($wplc_pro_version_number < 8011){
2618
+ ?>
2619
+ <div class='error below-h1'>
2620
+ <p><?php _e("Dear Pro User", "wplivechat") ?><br /></p>
2621
+ <p><?php _e("You are using an outdated version of <strong>WP Live Chat Support Pro</strong>.", "wplivechat") ?></p>
2622
+ <p>
2623
+ <strong><?php _e("Please update to the latest version of WP Live Chat Support Pro", 'wplivechat'); ?>
2624
+ <a href="https://wp-livechat.com/get-updated-version/" target=\"_BLANK\"> <?php _e("Version 8.0.11", "wplivechat"); ?></a>
2625
+ <?php _e("to ensure everything is working correctly.", "wplivechat"); ?>
2626
+ </strong>
2627
+ </p>
2628
+ <p><?php _e("You can update your plugin <a href='./update-core.php'>here</a>, <a href='./plugins.php'>here</a> or <a href='https://wp-livechat.com/get-updated-version/' target='_BLANK'>here</a>.", "wplivechat") ?></strong></p>
2629
+ <p><?php _e("If you are having difficulty updating the plugin, please contact", "wplivechat") ?> nick@wp-livechat.com</p>
2630
+ </div>
2631
+ <?php
2632
+ }
2633
+ }
2634
+
2635
  if ( ( get_option("WPLC_V8_FIRST_TIME") == true && !class_exists("APC_Object_Cache") ) || ( isset( $_GET['action'] ) && ( $_GET['action'] == 'welcome' || $_GET['action'] == 'credits' ) ) ){
2636
  include 'includes/welcome_page.php';
2637
  update_option('WPLC_V8_FIRST_TIME', false);
4564
  ?>
4565
  <h2 class="nav-tab-wrapper">
4566
  <a href="admin.php?page=wplivechat-menu-extensions-page" title="<?php _e("Add-ons","wplivechat"); ?>" class="nav-tab <?php echo $normal; ?>"><?php _e("Add-ons","wplivechat"); ?></a><a href="admin.php?page=wplivechat-menu-extensions-page&type=additional" title="<?php _e("Suggested Plugins","wplivechat"); ?>" class="nav-tab <?php echo $additional; ?>"><?php _e("Suggested Plugins","wplivechat"); ?></a>
4567
+ <span style='float: right; bottom:-5px; position: relative;'></span>
4568
  </h2>
4569
  <div id="tab_container">
4570
 
4637
  echo "</div></p>";
4638
 
4639
 
4640
+ $response = wp_remote_post( "https://update.wp-livechat.com/auth_api/api-wplc-extensions", array(
4641
  'method' => 'POST',
4642
  'body' => array(
4643
  'action' => 'extensions',
4797
  'https://wordpress.org/support/view/plugin-reviews/wp-live-chat-support?filter=5#postform'
4798
  );
4799
 
4800
+ return str_replace( '</span>', '', $footer_text ) . ' | ' . $footer_text_mod;
4801
  } else {
4802
  return $footer_text;
4803
  }
5033
  */
5034
  function wplc_build_api_check($page_content, $data) {
5035
  $link = "#";
5036
+ $image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/add-on0.jpg";
5037
  if ($data['string'] == "Multiple Agents") {
5038
  $link = "";
5039
+ $image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/Agents-Small.jpg";
5040
  }
5041
  if ($data['string'] == "Cloud Server") {
5042
  $link = "";
5043
+ $image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/Cloud-Small.jpg";
5044
  }
5045
  if ($data['string'] == "Advanced Chat Box Control") {
5046
  $link = "https://wp-livechat.com/extensions/advanced-chat-control/";
5047
+ $image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/AdvancedChatBox-Small.jpg";
5048
  }
5049
  if ($data['string'] == "Choose When Online") {
5050
  $link = "";
5051
+ $image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/ChooseOnline-Small.jpg";
5052
  }
5053
  if ($data['string'] == "Encryption") {
5054
  $link = "";
5055
+ $image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/Encryption-Small.jpg";
5056
  }
5057
  if ($data['string'] == "Mobile and Desktop App") {
5058
  $link = "";
5059
+ $image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/MobileDesktop-Small.jpg";
5060
  }
5061
  if ($data['string'] == "Initiate Chats") {
5062
  $link = "";
5063
+ $image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/InitiateChat-Small.jpg";
5064
  }
5065
  if ($data['string'] == "Include Exclude Pages") {
5066
  $link = "";
5067
+ $image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/IncludeAndExclude-Small.jpg";
5068
  }
5069
 
5070
 
5071
  if ($data['string'] == "WP Live Chat Support Pro") {
5072
  $link = "";
5073
+ $image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/add-on0.jpg";
5074
  }
5075
 
5076
 
5127
  if (function_exists("wplc_hook_control_intiate_check")) { return $text; }
5128
 
5129
  $rel_name = __("Pro Add-on","wplivechat");
5130
+ $rel_image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/add-on0.jpg";
5131
  $rel_link = "http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=relevant_pro";
5132
  $text .= '<div class="wplc-extension relevant_extension">';
5133
  $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" target="_BLANK" style="float:left;">';
5154
  if (function_exists("wplc_mobile_check_if_logged_in")) { return $text; }
5155
 
5156
  $rel_name = __("Mobile & Desktop App","wplivechat");
5157
+ $rel_image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/MobileDesktop-Icon.jpg";
5158
  $rel_link = "https://wp-livechat.com/extensions/mobile-desktop-app-extension/?utm_source=plugin&amp;utm_medium=link&amp;utm_campaign=relevant_mobile";
5159
  $text .= '<div class="wplc-extension relevant_extension">';
5160
  $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" target="_BLANK" style="float:left;">';
5181
  if (function_exists("wplc_hook_control_intiate_check")) { return $text; }
5182
 
5183
  $rel_name = __("Pro Add-on","wplivechat");
5184
+ $rel_image = "https://update.wp-livechat.com/auth_api/api-wplc-extensions/images/add-on0.jpg";
5185
  $rel_link = "http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=relevant_pro_chatbox";
5186
  $text .= '<div class="wplc-extension relevant_extension">';
5187
  $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" target="_BLANK" style="float:left;">';
5587
  </tr>
5588
  <tr>
5589
  <td valign='top'>
5590
+ <?php _e("Long poll setup","wplivechat"); ?>: <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e("Only change these if you are an experienced developer or if you have received these figures from the WP Live Chat Support team.", "wplivechat") ?>"></i>
5591
  </td>
5592
  <td valign='top'>
5593
  <?php