WP Live Chat Support - Version 8.0.23

Version Description

  • 2019-02-05 - Low priority =

  • Fixed access to new dashboard for non admin agents

  • Fixed documentation suggestions not working (Pro)

Download this release

Release Info

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

Code changes from version 8.0.22 to 8.0.23

css/admin_styles.css CHANGED
@@ -1,449 +1,449 @@
1
-
2
- /**
3
- * Settings
4
- */
5
-
6
- #wplc_settings .tooltip {
7
- background-color: #333;
8
- color: #eee;
9
- padding: 15px;
10
- border-radius: 15px;
11
- opacity: 0.8;
12
- }
13
-
14
- #wplc_settings .form-table td {
15
- font-size: 13px !important;
16
- line-height: 1.5em !important;
17
- }
18
-
19
-
20
- .wplc-extension-label-box {
21
- display:block;
22
- overflow:auto;
23
- clear:both;
24
- }
25
- .wplc-extension-label {
26
- display:block;
27
- float:left;
28
- padding:5px;
29
- margin-right:5px;
30
- font-size:0.8em;
31
- background-color:#bbb;
32
- color:#FFF;
33
- webkit-border-radius: 5px;
34
- -moz-border-radius: 5px;
35
- border-radius: 5px;
36
- }
37
-
38
-
39
- #wplc_tabs {
40
- box-shadow: 0 0 40px 1px rgba(0,0,0,.07);
41
- -webkit-box-shadow: 0 0 40px 1px rgba(0,0,0,.07);
42
- -moz-box-shadow: 0 0 40px 1px rgba(0,0,0,.07);
43
- -o-box-shadow: 0 0 40px 1px rgba(0,0,0,.07);
44
- }
45
-
46
-
47
- .wplc-extension {
48
-
49
- float: left;
50
- margin: 0 1% 1% 0;
51
- background: #fff;
52
- border: 1px solid #ccc;
53
- width: 320px;
54
- padding: 14px;
55
- height: 370px;
56
- position: relative;
57
-
58
- }
59
- .wplc-extension h3 {
60
- margin: 0 0 8px;
61
- font-size: 13px;
62
-
63
- }
64
-
65
- .wplc-extension .button-secondary {
66
- position: absolute;
67
- bottom: 14px;
68
- left: 14px;
69
- }
70
- .wplc-plugin {
71
- height: 250px;
72
- }
73
-
74
-
75
- .wplc_header_vh {
76
- font: bold 14px/26px Arial;
77
- padding: 0 0 0 0px;
78
- color: #C2BBBE;
79
- display: block;
80
- text-transform: uppercase;
81
- display:block;
82
- }
83
- .wplc_headerspan_v { min-width:120px; width:20%; display:block; }
84
- .wplc_headerspan_nr { min-width:60px; width:10%; display:block; }
85
- .wplc_headerspan_dev { min-width:60px; width:10%; display:block; }
86
- .wplc_headerspan_d { min-width:200px; width:30%; display:block; }
87
- .wplc_headerspan_d a { font-style: italic; }
88
- .wplc_headerspan_t { min-width:60px; width:9%; display:block; }
89
- .wplc_headerspan_s { min-width:80px; width:12%; display:block; }
90
- .wplc_headerspan_a { min-width:100px; width:15%; display:block; }
91
- .wplc_chat_ul_header {
92
- clear: both;
93
- overflow:auto;
94
- display:block;
95
- padding:10px;
96
- }
97
-
98
-
99
- .relevant_extension p {
100
- margin-top:2px;
101
- }
102
- .relevant_extension h3 {
103
- margin-bottom:2px;
104
- }
105
- .relevant_extension {
106
- width: 49% !important;
107
- height: 125px !important;
108
- opacity:0.5;
109
- }
110
- .relevant_extension:hover {
111
- opacity:1.0;
112
- }
113
-
114
-
115
- .relevant_extension .button-secondary {
116
- right:10px !important;
117
- left: initial !important;
118
-
119
- }
120
-
121
-
122
- .relevant_extension img {
123
- margin-right:10px;
124
- }
125
-
126
-
127
-
128
- @media (min-width:320px) {
129
- /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */
130
- .relevant_extension {
131
- width: 85% !important;
132
- height: 145px !important;
133
- opacity:0.5;
134
- }
135
- .relevant_extension img {
136
- width:105px;
137
- }
138
- .wplc-extension .wp-post-image {
139
- height: auto;
140
- }
141
- }
142
- @media (min-width:480px) {
143
- /* smartphones, Android phones, landscape iPhone */
144
- .relevant_extension {
145
- width: 94% !important;
146
- height: 125px !important;
147
- opacity:0.5;
148
- }
149
- .relevant_extension img {
150
- width:105px;
151
- }
152
- .wplc-extension .wp-post-image {
153
- height: auto;
154
- }
155
- }
156
- @media (min-width:600px) {
157
- /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */
158
- .relevant_extension {
159
- width: 94% !important;
160
- height: 125px !important;
161
- opacity:0.5;
162
- }
163
- .relevant_extension img {
164
- width:105px;
165
- }
166
- .wplc-extension .wp-post-image {
167
- height: auto;
168
- }
169
- }
170
- @media (min-width:801px) {
171
- /* tablet, landscape iPad, lo-res laptops ands desktops */
172
- .relevant_extension {
173
- width: 43% !important;
174
- height: 145px !important;
175
- opacity:0.5;
176
- }
177
- .relevant_extension img {
178
- width:95px;
179
- }
180
- .wplc-extension .wp-post-image {
181
- height: auto;
182
- }
183
- }
184
- @media (min-width:1025px) {
185
- /* big landscape tablets, laptops, and desktops */
186
- .relevant_extension {
187
- width: 44% !important;
188
- height: 125px !important;
189
- opacity:0.5;
190
- }
191
- .relevant_extension img {
192
- width:125px;
193
- }
194
- .wplc-extension .wp-post-image {
195
- height: auto;
196
- }
197
- }
198
- @media (min-width:1281px) {
199
- /* hi-res laptops and desktops */
200
- .relevant_extension {
201
- width: 32% !important;
202
- height: 125px !important;
203
- opacity:0.5;
204
- }
205
- .relevant_extension img {
206
- width:110px;
207
- }
208
- .wplc-extension .wp-post-image {
209
- height: auto;
210
- }
211
- }
212
-
213
-
214
- .wplc-palette-selection {
215
- border: 1px solid #CCC;
216
- border-radius: 5px;
217
- padding: 5px;
218
- margin: 5px;
219
- height:100%;
220
-
221
- }
222
-
223
- .wplc_palette_single {
224
- margin: 5px;
225
- margin-top: 15px;
226
- width: 162px;
227
- height: 122px;
228
- text-align: center;
229
- display: inline-block;
230
- vertical-align: top;
231
- cursor: pointer;
232
-
233
- }
234
- .wplc-palette-top { display:block; width:100%; height:25%; }
235
-
236
-
237
-
238
- #wplc_tabs .ui-tabs-anchor {
239
- width: 100%;
240
- }
241
-
242
-
243
-
244
- /* Gutenberg styles */
245
- #tabs-gutenberg input[type='button'] {
246
- cursor: pointer;
247
- }
248
-
249
- #wplc_custom_js_editor, #wplc_custom_css_editor, #wplc_custom_html_editor {
250
- width: 560px;
251
- height: 285px;
252
- margin: 10px 0 10px 0;
253
- }
254
-
255
- #wplc_gutenberg_icon {
256
- cursor: pointer;
257
- }
258
-
259
- .wplc_code {
260
- cursor: pointer;
261
- transition: all .2s ease-in-out;
262
- border-radius: 3px;
263
- color: #696969;
264
- }
265
-
266
- .wplc_code:hover {
267
- background: #d7d7d7;
268
- }
269
-
270
- .wplc_code:focus, .wplc_code:active {
271
- background: #018add;
272
- color: #fff;
273
- }
274
-
275
-
276
- .wplc_agent_container ul {
277
- display:block;
278
- overflow:auto;
279
- }
280
- .wplc_agent_container li{
281
- display: block;
282
- float: left;
283
- text-align: center;
284
- border: 1px solid #CCC;
285
- width:150px;
286
- height:310px;
287
- padding: 10px;
288
- border-radius: 5px;
289
- margin: 10px;
290
- box-shadow: 2px 2px 2px #CCC;
291
- overflow: auto;
292
-
293
- }
294
- .wplc_agent_container img{
295
- border-radius: 100px;
296
- }
297
- .wplc_agent_container h3 {
298
- font: bold 12px/16px Arial;
299
- padding: 0 0 0 0px;
300
- color: #C2BBBE;
301
- display: block;
302
- height:40px;
303
- text-transform: uppercase;
304
- }
305
- .wplc_agent_container small { word-wrap: break-word; display:block; height:50px; }
306
- .wplc_agent_container select { width: 120px; }
307
-
308
- .initiate_upsell {
309
- position: absolute;
310
- bottom: 0;
311
- padding: 10px;
312
- border-top: 1px solid #ccc;
313
- width: 100%;
314
- background-color: #fff;
315
- }
316
-
317
- /* Dashboard Page Styles */
318
- #wplc_dashboard_container {
319
- box-sizing: border-box;
320
- }
321
- .wplc_panel_col {
322
- display: inline-block !important;
323
- box-sizing: border-box;
324
- vertical-align: top;
325
- padding: 15px;
326
- margin: 0 !important;
327
- }
328
-
329
- .wplc_col_12 {
330
- width: 100%;
331
- }
332
-
333
- .wplc_col_6 {
334
- width: 50%;
335
- }
336
-
337
- .wplc_col_4 {
338
- width: 32%;
339
- }
340
-
341
- .wplc_dashboard_row {
342
- white-space: nowrap;
343
-
344
- }
345
- .wplc-center {
346
- text-align: center;
347
- }
348
- span.smaller {
349
- font-size: 0.7em;
350
- }
351
- span.wplc-stat {
352
- font-size: 4em;
353
- }
354
-
355
- .wplc_material_panel {
356
- background: #fff;
357
- box-sizing: border-box;
358
- padding: 10px;
359
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.00), 0 1px 15px rgba(0, 0, 0, 0.04);
360
- border-radius: 2px;
361
- overflow: auto;
362
- max-width: 100%;
363
- width: 100%;
364
- white-space: normal;
365
- }
366
-
367
- .wplc_panel_title {
368
- margin-top: 0;
369
- }
370
-
371
- .wplc_panel_row {
372
- display: block !important;
373
- width: 100% !important;
374
- }
375
-
376
- .wplc_panel_row iframe {
377
- display: block !important;
378
- }
379
-
380
- .wplc_post,
381
- .wplc_post_excerpt{
382
- width: 100%;
383
- max-width: 100%;
384
- }
385
- .wplc_post_readmore a,
386
- .wplc_readmore{
387
- color: orange !important;
388
- text-decoration: none;
389
- }
390
-
391
- .wplc_post_readmore a:hover,
392
- .wplc_readmore:hover {
393
- text-decoration: underline;
394
- }
395
-
396
- .wplc_readmore {
397
- padding: 10px;
398
- padding-top: 0;
399
- display: block;
400
- }
401
-
402
- .wplc_post {
403
- border-bottom: 1px solid #eee;
404
- padding: 10px 0;
405
- box-sizing: border-box;
406
- }
407
-
408
-
409
- .wplc_post:last-of-type {
410
- border: none !important;
411
- }
412
-
413
- .wplc_post_title {
414
- font-weight: 800;
415
- color: #656565;
416
- font-size: 14px;
417
- }
418
-
419
- .wplc_panel_row {
420
- padding: 10px;
421
- box-sizing: border-box;
422
- }
423
-
424
- .wplc_panel_inner_title {
425
- font-weight: 800;
426
- font-size: 15px;
427
- margin-bottom: 10px;
428
- display: block;
429
- }
430
- .wplc_incident {
431
- border-bottom: 1px solid #eee;
432
- padding: 10px 0;
433
- }
434
-
435
- .wplc_incident_info {
436
- margin-top: 10px !important;
437
- }
438
-
439
-
440
- .wplc_incident_value,
441
- .wplc_module_value{
442
-
443
- text-transform: capitalize;
444
- }
445
-
446
- #wplc_dashboard_page_title {
447
- padding: 15px;
448
- padding-bottom: 0;
449
- }
1
+
2
+ /**
3
+ * Settings
4
+ */
5
+
6
+ #wplc_settings .tooltip {
7
+ background-color: #333;
8
+ color: #eee;
9
+ padding: 15px;
10
+ border-radius: 15px;
11
+ opacity: 0.8;
12
+ }
13
+
14
+ #wplc_settings .form-table td {
15
+ font-size: 13px !important;
16
+ line-height: 1.5em !important;
17
+ }
18
+
19
+
20
+ .wplc-extension-label-box {
21
+ display:block;
22
+ overflow:auto;
23
+ clear:both;
24
+ }
25
+ .wplc-extension-label {
26
+ display:block;
27
+ float:left;
28
+ padding:5px;
29
+ margin-right:5px;
30
+ font-size:0.8em;
31
+ background-color:#bbb;
32
+ color:#FFF;
33
+ webkit-border-radius: 5px;
34
+ -moz-border-radius: 5px;
35
+ border-radius: 5px;
36
+ }
37
+
38
+
39
+ #wplc_tabs {
40
+ box-shadow: 0 0 40px 1px rgba(0,0,0,.07);
41
+ -webkit-box-shadow: 0 0 40px 1px rgba(0,0,0,.07);
42
+ -moz-box-shadow: 0 0 40px 1px rgba(0,0,0,.07);
43
+ -o-box-shadow: 0 0 40px 1px rgba(0,0,0,.07);
44
+ }
45
+
46
+
47
+ .wplc-extension {
48
+
49
+ float: left;
50
+ margin: 0 1% 1% 0;
51
+ background: #fff;
52
+ border: 1px solid #ccc;
53
+ width: 320px;
54
+ padding: 14px;
55
+ height: 370px;
56
+ position: relative;
57
+
58
+ }
59
+ .wplc-extension h3 {
60
+ margin: 0 0 8px;
61
+ font-size: 13px;
62
+
63
+ }
64
+
65
+ .wplc-extension .button-secondary {
66
+ position: absolute;
67
+ bottom: 14px;
68
+ left: 14px;
69
+ }
70
+ .wplc-plugin {
71
+ height: 250px;
72
+ }
73
+
74
+
75
+ .wplc_header_vh {
76
+ font: bold 14px/26px Arial;
77
+ padding: 0 0 0 0px;
78
+ color: #C2BBBE;
79
+ display: block;
80
+ text-transform: uppercase;
81
+ display:block;
82
+ }
83
+ .wplc_headerspan_v { min-width:120px; width:20%; display:block; }
84
+ .wplc_headerspan_nr { min-width:60px; width:10%; display:block; }
85
+ .wplc_headerspan_dev { min-width:60px; width:10%; display:block; }
86
+ .wplc_headerspan_d { min-width:200px; width:30%; display:block; }
87
+ .wplc_headerspan_d a { font-style: italic; }
88
+ .wplc_headerspan_t { min-width:60px; width:9%; display:block; }
89
+ .wplc_headerspan_s { min-width:80px; width:12%; display:block; }
90
+ .wplc_headerspan_a { min-width:100px; width:15%; display:block; }
91
+ .wplc_chat_ul_header {
92
+ clear: both;
93
+ overflow:auto;
94
+ display:block;
95
+ padding:10px;
96
+ }
97
+
98
+
99
+ .relevant_extension p {
100
+ margin-top:2px;
101
+ }
102
+ .relevant_extension h3 {
103
+ margin-bottom:2px;
104
+ }
105
+ .relevant_extension {
106
+ width: 49% !important;
107
+ height: 125px !important;
108
+ opacity:0.5;
109
+ }
110
+ .relevant_extension:hover {
111
+ opacity:1.0;
112
+ }
113
+
114
+
115
+ .relevant_extension .button-secondary {
116
+ right:10px !important;
117
+ left: initial !important;
118
+
119
+ }
120
+
121
+
122
+ .relevant_extension img {
123
+ margin-right:10px;
124
+ }
125
+
126
+
127
+
128
+ @media (min-width:320px) {
129
+ /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */
130
+ .relevant_extension {
131
+ width: 85% !important;
132
+ height: 145px !important;
133
+ opacity:0.5;
134
+ }
135
+ .relevant_extension img {
136
+ width:105px;
137
+ }
138
+ .wplc-extension .wp-post-image {
139
+ height: auto;
140
+ }
141
+ }
142
+ @media (min-width:480px) {
143
+ /* smartphones, Android phones, landscape iPhone */
144
+ .relevant_extension {
145
+ width: 94% !important;
146
+ height: 125px !important;
147
+ opacity:0.5;
148
+ }
149
+ .relevant_extension img {
150
+ width:105px;
151
+ }
152
+ .wplc-extension .wp-post-image {
153
+ height: auto;
154
+ }
155
+ }
156
+ @media (min-width:600px) {
157
+ /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */
158
+ .relevant_extension {
159
+ width: 94% !important;
160
+ height: 125px !important;
161
+ opacity:0.5;
162
+ }
163
+ .relevant_extension img {
164
+ width:105px;
165
+ }
166
+ .wplc-extension .wp-post-image {
167
+ height: auto;
168
+ }
169
+ }
170
+ @media (min-width:801px) {
171
+ /* tablet, landscape iPad, lo-res laptops ands desktops */
172
+ .relevant_extension {
173
+ width: 43% !important;
174
+ height: 145px !important;
175
+ opacity:0.5;
176
+ }
177
+ .relevant_extension img {
178
+ width:95px;
179
+ }
180
+ .wplc-extension .wp-post-image {
181
+ height: auto;
182
+ }
183
+ }
184
+ @media (min-width:1025px) {
185
+ /* big landscape tablets, laptops, and desktops */
186
+ .relevant_extension {
187
+ width: 44% !important;
188
+ height: 125px !important;
189
+ opacity:0.5;
190
+ }
191
+ .relevant_extension img {
192
+ width:125px;
193
+ }
194
+ .wplc-extension .wp-post-image {
195
+ height: auto;
196
+ }
197
+ }
198
+ @media (min-width:1281px) {
199
+ /* hi-res laptops and desktops */
200
+ .relevant_extension {
201
+ width: 32% !important;
202
+ height: 125px !important;
203
+ opacity:0.5;
204
+ }
205
+ .relevant_extension img {
206
+ width:110px;
207
+ }
208
+ .wplc-extension .wp-post-image {
209
+ height: auto;
210
+ }
211
+ }
212
+
213
+
214
+ .wplc-palette-selection {
215
+ border: 1px solid #CCC;
216
+ border-radius: 5px;
217
+ padding: 5px;
218
+ margin: 5px;
219
+ height:100%;
220
+
221
+ }
222
+
223
+ .wplc_palette_single {
224
+ margin: 5px;
225
+ margin-top: 15px;
226
+ width: 162px;
227
+ height: 122px;
228
+ text-align: center;
229
+ display: inline-block;
230
+ vertical-align: top;
231
+ cursor: pointer;
232
+
233
+ }
234
+ .wplc-palette-top { display:block; width:100%; height:25%; }
235
+
236
+
237
+
238
+ #wplc_tabs .ui-tabs-anchor {
239
+ width: 100%;
240
+ }
241
+
242
+
243
+
244
+ /* Gutenberg styles */
245
+ #tabs-gutenberg input[type='button'] {
246
+ cursor: pointer;
247
+ }
248
+
249
+ #wplc_custom_js_editor, #wplc_custom_css_editor, #wplc_custom_html_editor {
250
+ width: 560px;
251
+ height: 285px;
252
+ margin: 10px 0 10px 0;
253
+ }
254
+
255
+ #wplc_gutenberg_icon {
256
+ cursor: pointer;
257
+ }
258
+
259
+ .wplc_code {
260
+ cursor: pointer;
261
+ transition: all .2s ease-in-out;
262
+ border-radius: 3px;
263
+ color: #696969;
264
+ }
265
+
266
+ .wplc_code:hover {
267
+ background: #d7d7d7;
268
+ }
269
+
270
+ .wplc_code:focus, .wplc_code:active {
271
+ background: #018add;
272
+ color: #fff;
273
+ }
274
+
275
+
276
+ .wplc_agent_container ul {
277
+ display:block;
278
+ overflow:auto;
279
+ }
280
+ .wplc_agent_container li{
281
+ display: block;
282
+ float: left;
283
+ text-align: center;
284
+ border: 1px solid #CCC;
285
+ width:150px;
286
+ height:310px;
287
+ padding: 10px;
288
+ border-radius: 5px;
289
+ margin: 10px;
290
+ box-shadow: 2px 2px 2px #CCC;
291
+ overflow: auto;
292
+
293
+ }
294
+ .wplc_agent_container img{
295
+ border-radius: 100px;
296
+ }
297
+ .wplc_agent_container h3 {
298
+ font: bold 12px/16px Arial;
299
+ padding: 0 0 0 0px;
300
+ color: #C2BBBE;
301
+ display: block;
302
+ height:40px;
303
+ text-transform: uppercase;
304
+ }
305
+ .wplc_agent_container small { word-wrap: break-word; display:block; height:50px; }
306
+ .wplc_agent_container select { width: 120px; }
307
+
308
+ .initiate_upsell {
309
+ position: absolute;
310
+ bottom: 0;
311
+ padding: 10px;
312
+ border-top: 1px solid #ccc;
313
+ width: 100%;
314
+ background-color: #fff;
315
+ }
316
+
317
+ /* Dashboard Page Styles */
318
+ #wplc_dashboard_container {
319
+ box-sizing: border-box;
320
+ }
321
+ .wplc_panel_col {
322
+ display: inline-block !important;
323
+ box-sizing: border-box;
324
+ vertical-align: top;
325
+ padding: 15px;
326
+ margin: 0 !important;
327
+ }
328
+
329
+ .wplc_col_12 {
330
+ width: 100%;
331
+ }
332
+
333
+ .wplc_col_6 {
334
+ width: 50%;
335
+ }
336
+
337
+ .wplc_col_4 {
338
+ width: 32%;
339
+ }
340
+
341
+ .wplc_dashboard_row {
342
+ white-space: nowrap;
343
+
344
+ }
345
+ .wplc-center {
346
+ text-align: center;
347
+ }
348
+ span.smaller {
349
+ font-size: 0.7em;
350
+ }
351
+ span.wplc-stat {
352
+ font-size: 4em;
353
+ }
354
+
355
+ .wplc_material_panel {
356
+ background: #fff;
357
+ box-sizing: border-box;
358
+ padding: 10px;
359
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.00), 0 1px 15px rgba(0, 0, 0, 0.04);
360
+ border-radius: 2px;
361
+ overflow: auto;
362
+ max-width: 100%;
363
+ width: 100%;
364
+ white-space: normal;
365
+ }
366
+
367
+ .wplc_panel_title {
368
+ margin-top: 0;
369
+ }
370
+
371
+ .wplc_panel_row {
372
+ display: block !important;
373
+ width: 100% !important;
374
+ }
375
+
376
+ .wplc_panel_row iframe {
377
+ display: block !important;
378
+ }
379
+
380
+ .wplc_post,
381
+ .wplc_post_excerpt{
382
+ width: 100%;
383
+ max-width: 100%;
384
+ }
385
+ .wplc_post_readmore a,
386
+ .wplc_readmore{
387
+ color: orange !important;
388
+ text-decoration: none;
389
+ }
390
+
391
+ .wplc_post_readmore a:hover,
392
+ .wplc_readmore:hover {
393
+ text-decoration: underline;
394
+ }
395
+
396
+ .wplc_readmore {
397
+ padding: 10px;
398
+ padding-top: 0;
399
+ display: block;
400
+ }
401
+
402
+ .wplc_post {
403
+ border-bottom: 1px solid #eee;
404
+ padding: 10px 0;
405
+ box-sizing: border-box;
406
+ }
407
+
408
+
409
+ .wplc_post:last-of-type {
410
+ border: none !important;
411
+ }
412
+
413
+ .wplc_post_title {
414
+ font-weight: 800;
415
+ color: #656565;
416
+ font-size: 14px;
417
+ }
418
+
419
+ .wplc_panel_row {
420
+ padding: 10px;
421
+ box-sizing: border-box;
422
+ }
423
+
424
+ .wplc_panel_inner_title {
425
+ font-weight: 800;
426
+ font-size: 15px;
427
+ margin-bottom: 10px;
428
+ display: block;
429
+ }
430
+ .wplc_incident {
431
+ border-bottom: 1px solid #eee;
432
+ padding: 10px 0;
433
+ }
434
+
435
+ .wplc_incident_info {
436
+ margin-top: 10px !important;
437
+ }
438
+
439
+
440
+ .wplc_incident_value,
441
+ .wplc_module_value{
442
+
443
+ text-transform: capitalize;
444
+ }
445
+
446
+ #wplc_dashboard_page_title {
447
+ padding: 15px;
448
+ padding-bottom: 0;
449
+ }
includes/dashboard_page.php CHANGED
@@ -1,94 +1,94 @@
1
- <script>
2
- var nifty_api_key = '<?php echo get_option("wplc_node_server_secret_token"); ?>';
3
-
4
-
5
-
6
- </script>
7
-
8
- <?php
9
- $user = wp_get_current_user();
10
-
11
- global $wpdb;
12
- global $wplc_tblname_chats;
13
- $sql = "SELECT COUNT(id) as total_chats FROM `$wplc_tblname_chats` WHERE `agent_id` <> 0";
14
- $results = $wpdb->get_row( $sql );
15
- if ($results) {
16
- $total_count = $results->total_chats;
17
- } else {
18
- $total_count = 0;
19
- }
20
- ?>
21
-
22
- <div class="wrap wplc_wrap">
23
- <h2 id="wplc_dashboard_page_title"><?php _e( 'WP Live Chat Support Dashboard', 'wplivechat' ) ?></h2>
24
- <div class="wplc_dashboard_container">
25
-
26
-
27
- <div class="wplc_dashboard_row">
28
- <div class="wplc_panel_col wplc_col_6">
29
- <div class="wplc_panel">
30
- <h3 class="wplc_panel_title"><?php printf( __( 'Welcome, %s', 'wplivechat' ), $user->display_name ); ?></h3>
31
- </div>
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>
39
-
40
-
41
-
42
- <div class="wplc_dashboard_row">
43
- <div class="wplc_panel_col wplc_col_12">
44
- <div class="wplc_panel">
45
- <div class="wplc_material_panel">
46
-
47
-
48
- <div class="wplc_panel_col wplc_col_4 wplc-center">
49
- <h4><?php _e("Actions","wplivechat"); ?></h4>
50
- <p><a href='admin.php?page=wplivechat-menu&subaction=override' class='button-primary'><?php echo __("Chat with Visitors","wplivechat"); ?></a></p>
51
- <p><a href='admin.php?page=wplivechat-menu-settings' class='button-secondary'><?php echo __("Settings","wplivechat"); ?></a></p>
52
- </div>
53
-
54
- <div class="wplc_panel_col wplc_col_4 wplc-center">
55
- <h4><?php _e("Active Visitors","wplivechat"); ?><br />&nbsp;</h4>
56
- <span class='wplc-stat' id='totalVisitors'>...</span>
57
- <p><a href='admin.php?page=wplivechat-menu&subaction=override' class='button-secondary'><?php echo __("Chat now","wplivechat"); ?></a></p>
58
- </div>
59
-
60
- <div class="wplc_panel_col wplc_col_4 wplc-center">
61
- <h4><?php _e("Conversations","wplivechat"); ?><br /><span class='smaller'><?php _e("Last 90 days","wplivechat"); ?></span></h4>
62
- <span class='wplc-stat'><?php echo $total_count; ?></span>
63
- </div>
64
-
65
-
66
- </div>
67
- </div>
68
- </div>
69
- </div>
70
-
71
- <script type="text/javascript">
72
- function resizeIframe(iframe) {
73
- setTimeout(function() {
74
- iframe.height = iframe.contentWindow.document.body.scrollHeight + "px";
75
- },3000);
76
-
77
- }
78
- </script>
79
-
80
- <div class="wplc_dashboard_row">
81
- <div class="wplc_panel_col wplc_col_12">
82
- <div class="wplc_panel">
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>
90
- </div>
91
- </div>
92
-
93
- </div>
94
  </div>
1
+ <script>
2
+ var nifty_api_key = '<?php echo get_option("wplc_node_server_secret_token"); ?>';
3
+
4
+
5
+
6
+ </script>
7
+
8
+ <?php
9
+ $user = wp_get_current_user();
10
+
11
+ global $wpdb;
12
+ global $wplc_tblname_chats;
13
+ $sql = "SELECT COUNT(id) as total_chats FROM `$wplc_tblname_chats` WHERE `agent_id` <> 0";
14
+ $results = $wpdb->get_row( $sql );
15
+ if ($results) {
16
+ $total_count = $results->total_chats;
17
+ } else {
18
+ $total_count = 0;
19
+ }
20
+ ?>
21
+
22
+ <div class="wrap wplc_wrap">
23
+ <h2 id="wplc_dashboard_page_title"><?php _e( 'WP Live Chat Support Dashboard', 'wplivechat' ) ?></h2>
24
+ <div class="wplc_dashboard_container">
25
+
26
+
27
+ <div class="wplc_dashboard_row">
28
+ <div class="wplc_panel_col wplc_col_6">
29
+ <div class="wplc_panel">
30
+ <h3 class="wplc_panel_title"><?php printf( __( 'Welcome, %s', 'wplivechat' ), $user->display_name ); ?></h3>
31
+ </div>
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>
39
+
40
+
41
+
42
+ <div class="wplc_dashboard_row">
43
+ <div class="wplc_panel_col wplc_col_12">
44
+ <div class="wplc_panel">
45
+ <div class="wplc_material_panel">
46
+
47
+
48
+ <div class="wplc_panel_col wplc_col_4 wplc-center">
49
+ <h4><?php _e("Actions","wplivechat"); ?></h4>
50
+ <p><a href='admin.php?page=wplivechat-menu&subaction=override' class='button-primary'><?php echo __("Chat with Visitors","wplivechat"); ?></a></p>
51
+ <p><a href='admin.php?page=wplivechat-menu-settings' class='button-secondary'><?php echo __("Settings","wplivechat"); ?></a></p>
52
+ </div>
53
+
54
+ <div class="wplc_panel_col wplc_col_4 wplc-center">
55
+ <h4><?php _e("Active Visitors","wplivechat"); ?><br />&nbsp;</h4>
56
+ <span class='wplc-stat' id='totalVisitors'>...</span>
57
+ <p><a href='admin.php?page=wplivechat-menu&subaction=override' class='button-secondary'><?php echo __("Chat now","wplivechat"); ?></a></p>
58
+ </div>
59
+
60
+ <div class="wplc_panel_col wplc_col_4 wplc-center">
61
+ <h4><?php _e("Conversations","wplivechat"); ?><br /><span class='smaller'><?php _e("Last 90 days","wplivechat"); ?></span></h4>
62
+ <span class='wplc-stat'><?php echo $total_count; ?></span>
63
+ </div>
64
+
65
+
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </div>
70
+
71
+ <script type="text/javascript">
72
+ function resizeIframe(iframe) {
73
+ setTimeout(function() {
74
+ iframe.height = iframe.contentWindow.document.body.scrollHeight + "px";
75
+ },3000);
76
+
77
+ }
78
+ </script>
79
+
80
+ <div class="wplc_dashboard_row">
81
+ <div class="wplc_panel_col wplc_col_12">
82
+ <div class="wplc_panel">
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>
90
+ </div>
91
+ </div>
92
+
93
+ </div>
94
  </div>
js/wplc_dashboard.js CHANGED
@@ -1,91 +1,91 @@
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
6
- }
7
-
8
- function getTotalVisitors() {
9
- jQuery.getJSON( wplcApiUrls.visitorURL, function( data ) {
10
-
11
-
12
-
13
- jQuery('#totalVisitors').html( data );
14
- });
15
-
16
- }
17
-
18
- function getBlogPosts() {
19
- jQuery.getJSON( wplcApiUrls.blogFeedUrl, function( data ) {
20
-
21
- const limit = 5;
22
- let output = '';
23
-
24
- for (let i in data){
25
- if(i >= limit){
26
- continue;
27
- }
28
-
29
- const post = data[i];
30
- const html = `<div class='wplc_post'>
31
- <div class='wplc_post_title'>${post.title.rendered}</div>
32
- <p class='wplc_post_excerpt'>${post.excerpt.rendered}</p>
33
- <div class='wplc_post_readmore'>
34
- <a href='${post.link}' target='_BLANK' title='${post.title.rendered}'>Read More</a>
35
- </div>
36
- </div>`;
37
- output += html;
38
- }
39
-
40
- jQuery('#wplc_blog_posts').html( output );
41
-
42
- });
43
- }
44
-
45
- function getStatusComponents() {
46
- jQuery.getJSON( wplcApiUrls.statusPageComponentsURL, function( data ) {
47
-
48
- let output = '';
49
-
50
- if(typeof data.components !== 'undefined'){
51
- for(let i in data.components){
52
- const component = data.components[i];
53
- const html = `<div class='wplc_module'>${component.name}: <strong class='wplc_module_value'>${component.status}</strong></div>`;
54
- output += html;
55
- }
56
- }
57
-
58
- jQuery('#wplc_status_modules').html( output );
59
- });
60
- }
61
-
62
-
63
- function getStatusIncidents() {
64
- jQuery.getJSON( wplcApiUrls.statusPageIncidentsURL, function( data ) {
65
-
66
- let output = '';
67
-
68
- if(typeof data.incidents !== 'undefined'){
69
- for(let i in data.incidents){
70
- const incident = data.incidents[i];
71
-
72
- const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
73
- const date = new Date(incident.created_at);
74
-
75
- const last_report = typeof incident.incident_updates !== 'undefined' && typeof incident.incident_updates[0] !== 'undefined' && incident.incident_updates[0].body !== 'undefined' ? incident.incident_updates[0].body : incident.name;
76
-
77
- const html = `<div class='wplc_incident'>${date.getDate()} ${months[date.getMonth()]} ${date.getFullYear()}: <strong class='wplc_incident_value'>${incident.status}</strong><div class='wplc_incident_info'>${last_report}</div></div>`;
78
- output += html;
79
- }
80
- }
81
-
82
- jQuery('#wplc_status_incidents').html( output );
83
- });
84
- }
85
-
86
- jQuery(document).ready(function($){
87
- getBlogPosts();
88
- getStatusComponents();
89
- getStatusIncidents();
90
- getTotalVisitors();
91
  });
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
6
+ }
7
+
8
+ function getTotalVisitors() {
9
+ jQuery.getJSON( wplcApiUrls.visitorURL, function( data ) {
10
+
11
+
12
+
13
+ jQuery('#totalVisitors').html( data );
14
+ });
15
+
16
+ }
17
+
18
+ function getBlogPosts() {
19
+ jQuery.getJSON( wplcApiUrls.blogFeedUrl, function( data ) {
20
+
21
+ const limit = 5;
22
+ let output = '';
23
+
24
+ for (let i in data){
25
+ if(i >= limit){
26
+ continue;
27
+ }
28
+
29
+ const post = data[i];
30
+ const html = `<div class='wplc_post'>
31
+ <div class='wplc_post_title'>${post.title.rendered}</div>
32
+ <p class='wplc_post_excerpt'>${post.excerpt.rendered}</p>
33
+ <div class='wplc_post_readmore'>
34
+ <a href='${post.link}' target='_BLANK' title='${post.title.rendered}'>Read More</a>
35
+ </div>
36
+ </div>`;
37
+ output += html;
38
+ }
39
+
40
+ jQuery('#wplc_blog_posts').html( output );
41
+
42
+ });
43
+ }
44
+
45
+ function getStatusComponents() {
46
+ jQuery.getJSON( wplcApiUrls.statusPageComponentsURL, function( data ) {
47
+
48
+ let output = '';
49
+
50
+ if(typeof data.components !== 'undefined'){
51
+ for(let i in data.components){
52
+ const component = data.components[i];
53
+ const html = `<div class='wplc_module'>${component.name}: <strong class='wplc_module_value'>${component.status}</strong></div>`;
54
+ output += html;
55
+ }
56
+ }
57
+
58
+ jQuery('#wplc_status_modules').html( output );
59
+ });
60
+ }
61
+
62
+
63
+ function getStatusIncidents() {
64
+ jQuery.getJSON( wplcApiUrls.statusPageIncidentsURL, function( data ) {
65
+
66
+ let output = '';
67
+
68
+ if(typeof data.incidents !== 'undefined'){
69
+ for(let i in data.incidents){
70
+ const incident = data.incidents[i];
71
+
72
+ const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
73
+ const date = new Date(incident.created_at);
74
+
75
+ const last_report = typeof incident.incident_updates !== 'undefined' && typeof incident.incident_updates[0] !== 'undefined' && incident.incident_updates[0].body !== 'undefined' ? incident.incident_updates[0].body : incident.name;
76
+
77
+ const html = `<div class='wplc_incident'>${date.getDate()} ${months[date.getMonth()]} ${date.getFullYear()}: <strong class='wplc_incident_value'>${incident.status}</strong><div class='wplc_incident_info'>${last_report}</div></div>`;
78
+ output += html;
79
+ }
80
+ }
81
+
82
+ jQuery('#wplc_status_incidents').html( output );
83
+ });
84
+ }
85
+
86
+ jQuery(document).ready(function($){
87
+ getBlogPosts();
88
+ getStatusComponents();
89
+ getStatusIncidents();
90
+ getTotalVisitors();
91
  });
modules/gdpr.php CHANGED
@@ -1,765 +1,765 @@
1
- <?php
2
-
3
- /**
4
- * GDPR Compliance Module
5
- */
6
-
7
- add_filter("wplc_activate_default_settings_array", "wplc_gdpr_set_default_settings", 10, 1);
8
- /*
9
- * Sets the default GDPR options
10
- */
11
- function wplc_gdpr_set_default_settings($wplc_default_settings_array){
12
- //Disabled by default on new installations
13
- /*if(is_array($wplc_default_settings_array)){
14
- if(!isset($wplc_default_settings_array['wplc_gdpr_enabled'])){
15
- //Is not set already
16
- //$wplc_default_settings_array['wplc_gdpr_enabled'] = 0;
17
- }
18
- }*/
19
- return $wplc_default_settings_array;
20
- }
21
-
22
- add_action("wplc_hook_privacy_options_content", "wplc_gdpr_settings_content", 10, 1);
23
- /**
24
- * Adds the GDPR sepcific settings to the Privacy tab
25
- */
26
- function wplc_gdpr_settings_content($wplc_settings = false){
27
- if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
28
-
29
- ?>
30
- <table class="wp-list-table wplc_list_table widefat fixed striped pages">
31
- <tbody>
32
- <tr>
33
- <td width="250" valign="top">
34
- <label for="wplc_gdpr_enabled"><?php _e("Enbled GDPR Compliance", "wplivechat"); ?> <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e('Disabling will disable all GDPR related options, this is not advised.', 'wplivechat'); ?>"></i></label>
35
- </td>
36
- <td>
37
- <input type="checkbox" name="wplc_gdpr_enabled" value="1" <?php echo(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1' ? 'checked' : ''); ?> >
38
- <a href="https://www.eugdpr.org/" target="_blank"><?php _e("Importance of GDPR Compliance", "wplivechat"); ?></a>
39
- </td>
40
- </tr>
41
-
42
- <tr>
43
- <td width="250" valign="top">
44
- <label for="wplc_gdpr_notice_company"><?php _e("Company Name", "wplivechat"); ?></label>
45
- </td>
46
- <td>
47
- <input type="text" name="wplc_gdpr_notice_company" value="<?php echo(isset($wplc_settings['wplc_gdpr_notice_company']) ? $wplc_settings['wplc_gdpr_notice_company'] : get_bloginfo('name')); ?>" >
48
- </td>
49
- </tr>
50
-
51
- <tr>
52
- <td width="250" valign="top">
53
- <label for="wplc_gdpr_notice_retention_purpose"><?php _e("Retention Purpose", "wplivechat"); ?></label>
54
- </td>
55
- <td>
56
- <input type="text" name="wplc_gdpr_notice_retention_purpose" value="<?php echo(isset($wplc_settings['wplc_gdpr_notice_retention_purpose']) ? $wplc_settings['wplc_gdpr_notice_retention_purpose'] : __('Chat/Support', 'wplivechat')); ?>" >
57
- </td>
58
- </tr>
59
-
60
- <tr>
61
- <td width="250" valign="top">
62
- <label for="wplc_gdpr_notice_retention_period"><?php _e("Retention Period", "wplivechat"); ?></label>
63
- </td>
64
- <td>
65
- <input type="number" name="wplc_gdpr_notice_retention_period" value="<?php echo(isset($wplc_settings['wplc_gdpr_notice_retention_period']) ? intval($wplc_settings['wplc_gdpr_notice_retention_period']) < 1 ? 1 : intval($wplc_settings['wplc_gdpr_notice_retention_period']) : 30); ?>" > <?php _e('days', 'wplivechat'); ?>
66
- </td>
67
- </tr>
68
-
69
- <tr>
70
- <td width="250" valign="top">
71
- <label><?php _e("Next Check", "wplivechat"); ?>
72
- <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e('When the next cron will run to check for data which is older than our retention period.', 'wplivechat'); ?>"></i>
73
- </label>
74
- </td>
75
- <td>
76
- <span>
77
- <?php
78
- echo date('d-m-Y H:i:s', wp_next_scheduled('wplc_gdpr_cron_hook'));
79
- ?>
80
- </span>
81
- </td>
82
- </tr>
83
-
84
- <tr>
85
- <td width="250" valign="top">
86
- <label><?php _e("GDPR Notice", "wplivechat"); ?>
87
- <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e('Users will be asked to accept the notice shown here, in the form of a check box.', 'wplivechat'); ?>"></i>
88
- </label>
89
- </td>
90
- <td>
91
- <span>
92
- <?php
93
- echo wplc_gdpr_generate_retention_agreement_notice($wplc_settings);
94
- echo "<br><br>";
95
- echo apply_filters('wplc_gdpr_create_opt_in_checkbox_filter', "");
96
- ?>
97
- </span>
98
- </td>
99
- </tr>
100
-
101
-
102
- </tbody>
103
- </table>
104
- <?php
105
- }
106
-
107
- add_filter("wplc_settings_save_filter_hook", "wplc_gdpr_settings_save_hooked", 10, 1);
108
- /**
109
- * Save the settings for GDPR
110
- */
111
- function wplc_gdpr_settings_save_hooked($wplc_data){
112
-
113
- if (isset($_POST['wplc_gdpr_enabled'])) {
114
- $wplc_data['wplc_gdpr_enabled'] = esc_attr($_POST['wplc_gdpr_enabled']);
115
- do_action('wplc_gdpr_reg_cron_hook');
116
-
117
- update_option('WPLC_GDPR_DISABLED_WARNING_DISMISSED', 'false');
118
- } else {
119
- do_action('wplc_gdpr_de_reg_cron_hook');
120
- }
121
-
122
- if (isset($_POST['wplc_gdpr_notice_company'])) { $wplc_data['wplc_gdpr_notice_company'] = esc_attr($_POST['wplc_gdpr_notice_company']); }
123
- if (isset($_POST['wplc_gdpr_notice_retention_purpose'])) { $wplc_data['wplc_gdpr_notice_retention_purpose'] = esc_attr($_POST['wplc_gdpr_notice_retention_purpose']); }
124
- if (isset($_POST['wplc_gdpr_notice_retention_period'])) { $wplc_data['wplc_gdpr_notice_retention_period'] = esc_attr($_POST['wplc_gdpr_notice_retention_period']); }
125
-
126
- return $wplc_data;
127
- }
128
-
129
-
130
- add_action("wplc_hook_menu", "wplc_gdpr_add_menu");
131
- /**
132
- * Adds a menu specifically dedicated to GDPR
133
- */
134
- function wplc_gdpr_add_menu(){
135
- $wplc_settings = get_option("WPLC_SETTINGS");
136
-
137
- if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
138
- add_submenu_page('wplivechat-menu', __('GDPR', 'wplivechat'), __('GDPR', 'wplivechat'), 'manage_options', 'wplivechat-menu-gdpr-page', 'wplc_gdpr_page_layout');
139
- }
140
- }
141
-
142
- /**
143
- * Handles the layout for the GDPR page
144
- */
145
- function wplc_gdpr_page_layout(){
146
- ?>
147
- <h2><?php _e('WP Live Chat Support - GDPR', 'wplivechat'); ?></h2>
148
-
149
- <small><em><?php _e("Search is performed on chat sessions, messages, and offline messages. Data will also be deleted automatically per your retention policy.", "wplivechat"); ?></em></small>
150
- <?php do_action('wplc_gdpr_page_before_table_hook'); ?>
151
- <table class="wp-list-table wplc_list_table widefat fixed striped pages">
152
- <thead>
153
- <tr>
154
- <th></th>
155
- <th>
156
- </th>
157
- <th>
158
- <form method="GET" action="">
159
- <input type="hidden" name="page" value='wplivechat-menu-gdpr-page'>
160
- <input name='term' type="text" value='<?php echo(isset($_GET['term']) ? htmlspecialchars($_GET['term']) : ''); ?>' placeholder="<?php _e('Name, Email, Message', 'wplivechat'); ?>" style='height:30px; width: 70%'>
161
-
162
- <?php do_action('wplc_gdpr_page_search_form_before_submit_hook'); ?>
163
-
164
- <input type='submit' class='button' value="<?php _e("Search", "wplivechat"); ?>" >
165
- </form>
166
- </th>
167
- </tr>
168
- </thead>
169
- <tbody>
170
- <?php
171
- if(isset($_GET['term'])){
172
- $results = wplc_gdpr_return_chat_session_search_results(htmlspecialchars($_GET['term']));
173
-
174
- foreach ($results as $heading => $sub_results) {
175
- $original_heading = $heading;
176
- $heading = ucwords(str_replace("_", " ", $heading));
177
- $heading = str_replace("%%TABLE%%", $heading, __('Search Results in %%TABLE%%', 'wplivechat'));
178
- ?>
179
- <tr>
180
- <td><strong><?php echo $heading; ?></strong></td>
181
- <td></td>
182
- <td style="text-align: right"><em><?php echo count($sub_results); ?></em></td>
183
- </tr>
184
- <?php
185
-
186
- /**Setup Defaults*/
187
- $cid_identidier = 'id';
188
- $action_action_filter = 'chat_session';
189
- $show_fields = array('name', 'email');
190
- switch ($original_heading) {
191
- case 'chat_messages':
192
- $cid_identidier = 'chat_sess_id';
193
- $show_fields = array('msg');
194
- break;
195
- case 'offline_messages':
196
- $action_action_filter = 'offline_message';
197
- $show_fields = array('name', 'email', 'message');
198
- break;
199
- }
200
-
201
- $action_action_filter = htmlspecialchars($action_action_filter);
202
-
203
- foreach ($sub_results as $key => $value) {
204
- $cid = isset($value[$cid_identidier]) ? $value[$cid_identidier] : 'false';
205
- $delete_button_text = str_replace("%%CID%%", $cid, __("Delete Chat (%%CID%%)", "wplivechat"));
206
- $download_button_text = str_replace("%%CID%%", $cid, __("Download Chat (%%CID%%)", "wplivechat"));
207
-
208
- ?>
209
- <tr>
210
- <td><?php echo(__('Chat ID', 'wplivechat') . ": " . $cid ); ?></td>
211
- <td>
212
- <?php
213
- foreach ($value as $subkey => $sub_val) {
214
- if(in_array($subkey, $show_fields)){
215
- echo( sanitize_text_field($subkey) . ": " . str_replace("%%BREAK%%", "<br>", sanitize_text_field($sub_val) ) . "<br>");
216
- }
217
- }
218
- ?>
219
- </td>
220
- <td>
221
- <a class='button' href='?page=wplivechat-menu-gdpr-page&term=<?php echo(htmlspecialchars($_GET["term"])); ?>&action=delete&filter=<?php echo $action_action_filter; ?>&id=<?php echo htmlspecialchars($cid); ?>'><?php echo $delete_button_text; ?></a>
222
- <a class='button button-primary' href='?page=wplivechat-menu-gdpr-page&term=<?php echo(htmlspecialchars($_GET["term"])); ?>&action=download&filter=<?php echo $action_action_filter; ?>&id=<?php echo htmlspecialchars($cid); ?>'><?php echo $download_button_text; ?></a>
223
- </td>
224
- </tr>
225
- <?php
226
- }
227
- }
228
- } else {
229
- ?>
230
- <tr>
231
- <td><strong><?php _e('Please perform a search using the input field above', 'wplivechat'); ?></strong></td>
232
- <td></td>
233
- <td></td>
234
- </tr>
235
- <?php
236
- }
237
- ?>
238
- </tbody>
239
- </table>
240
-
241
- <?php do_action('wplc_gdpr_page_after_table_hook'); ?>
242
-
243
- <?php
244
- }
245
-
246
- add_action('admin_init', 'wplc_gdpr_admin_init', 1);
247
- /**
248
- * Runs on admin init, if we are on the GDPR page, we run the check action hook
249
- * This will allow us to alter the header if needed for JSON files
250
- */
251
- function wplc_gdpr_admin_init(){
252
- wplc_gdpr_check_for_cron();
253
-
254
- if(isset($_GET['page']) && $_GET['page'] === 'wplivechat-menu-gdpr-page'){
255
- do_action('wplc_gdpr_page_process_actions_hook');
256
- }
257
- }
258
-
259
-
260
- add_action('wplc_gdpr_page_process_actions_hook', 'wplc_gdpr_page_process_actions');
261
- /**
262
- * Handles the magic processing of the GDPR page
263
- */
264
- function wplc_gdpr_page_process_actions(){
265
- if(isset($_GET['action']) && isset($_GET['filter']) && isset($_GET['id'])){
266
- $action = sanitize_text_field($_GET['action']);
267
- $filter = sanitize_text_field($_GET['filter']);
268
- $id = sanitize_text_field($_GET['id']);
269
-
270
- if($action === 'delete'){
271
- wplc_gdpr_delete_chat($filter, $id);
272
- } else if($action === 'download'){
273
- wplc_gdpr_download_chat($filter, $id);
274
- }
275
- }
276
- }
277
-
278
- /**
279
- * Delete a chat
280
- */
281
- function wplc_gdpr_delete_chat($filter_type, $cid, $output = true){
282
- global $wpdb, $wplc_tblname_offline_msgs, $wplc_tblname_chats, $wplc_tblname_msgs;
283
- if($filter_type === 'chat_session'){
284
- $wpdb->delete($wplc_tblname_chats, array('id' => $cid));
285
- $wpdb->delete($wplc_tblname_msgs, array('chat_sess_id' => $cid));
286
- } else if ($filter_type === 'offline_message'){
287
- $wpdb->delete($wplc_tblname_offline_msgs, array('id' => $cid));
288
- }
289
-
290
- do_action('wplc_gdpr_delete_chat_extend_hook', $filter_type, $cid);
291
-
292
- if($output){
293
- $output = "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>";
294
- $output .= "<strong>" . __("Data Deleted", "wplivechat") . "(" . $cid . ")" . "</strong><br>";
295
- $output .= "</div>";
296
- echo $output;
297
- }
298
- }
299
-
300
- /**
301
- * Download a chat
302
- */
303
- function wplc_gdpr_download_chat($filter_type, $cid){
304
- global $wpdb, $wplc_tblname_offline_msgs, $wplc_tblname_chats, $wplc_tblname_msgs;
305
- if($filter_type === 'chat_session'){
306
- $result_chat_session = $wpdb->get_results("SELECT * FROM $wplc_tblname_chats WHERE `id` = '$cid' LIMIT 1", ARRAY_A);
307
- $result_chat_messages = $wpdb->get_results("SELECT * FROM $wplc_tblname_msgs WHERE `chat_sess_id` = '$cid'", ARRAY_A);
308
-
309
- if(count($result_chat_session) > 0){
310
- $chat_session = $result_chat_session[0];
311
-
312
- $chat_session['messages'] = array();
313
- foreach ($result_chat_messages as $key => $value) {
314
- $chat_session['messages'][] = $value;
315
- }
316
-
317
- $chat_session = apply_filters('wplc_gdpr_download_chat_extender_hook', $chat_session, $cid);
318
-
319
- //var_dump(json_encode($chat_session));
320
-
321
- header('Content-disposition: attachment; filename=chat_export_' . $cid . '.json');
322
- header('Content-type: application/json');
323
- echo json_encode($chat_session);
324
- die(); //Let's stop any further data capture please and thank you
325
- }
326
- } else if ($filter_type === 'offline_message'){
327
-
328
- }
329
- }
330
-
331
- /**
332
- * Searches the db for all relevant chat sessions based on the search term
333
- */
334
- function wplc_gdpr_return_chat_session_search_results($term){
335
- global $wpdb, $wplc_tblname_offline_msgs, $wplc_tblname_chats, $wplc_tblname_msgs;
336
-
337
- $term = sanitize_text_field($term);
338
-
339
- $results_chats = $wpdb->get_results("SELECT * FROM $wplc_tblname_chats WHERE `name` LIKE '%$term%' OR `email` LIKE '%$term%'", ARRAY_A);
340
- $results_message = $wpdb->get_results("SELECT * FROM $wplc_tblname_msgs WHERE `msg` LIKE '%$term%'", ARRAY_A);
341
- $results_offline = $wpdb->get_results("SELECT * FROM $wplc_tblname_offline_msgs WHERE `name` LIKE '%$term%' OR `email` LIKE '%$term%' OR `message` LIKE '%$term%'", ARRAY_A);
342
-
343
- $formatted_messages = array();
344
- foreach ($results_message as $key => $value) {
345
- $cid = isset($value['chat_sess_id']) ? $value['chat_sess_id'] : false;
346
- if($cid !== false){
347
- $msg = maybe_unserialize($value['msg']);
348
- $msg = is_array($msg) ? $msg['m'] : $msg;
349
- if(!isset($formatted_messages[$cid])){
350
- $formatted_messages[$cid]['chat_sess_id'] = $cid;
351
- $formatted_messages[$cid]['msg'] = $msg . "%%BREAK%%";
352
- } else {
353
- $formatted_messages[$cid]['msg'] .= $msg . "%%BREAK%%";
354
- }
355
- }
356
- }
357
-
358
- $return_results = array(
359
- 'chat_sessions' => $results_chats,
360
- 'chat_messages' => $formatted_messages,
361
- 'offline_messages' => $results_offline
362
- );
363
-
364
- return $return_results;
365
-
366
- }
367
-
368
- /**
369
- * Generates a localized retention notice message
370
- */
371
- function wplc_gdpr_generate_retention_agreement_notice($wplc_settings = false){
372
- if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
373
-
374
- $localized_notice = __("I agree for my personal data to be processed and for the use of cookies in order to engage in a chat processed by %%COMPANY%%, for the purpose of %%PURPOSE%%, for the time of %%PERIOD%% day(s) as per the GDPR.", "wplivechat");
375
- $company_replacement = isset($wplc_settings['wplc_gdpr_notice_company']) ? $wplc_settings['wplc_gdpr_notice_company'] : get_bloginfo('name');
376
- $purpose_replacement = isset($wplc_settings['wplc_gdpr_notice_retention_purpose']) ? $wplc_settings['wplc_gdpr_notice_retention_purpose'] : __('Chat/Support', 'wplivechat');
377
- $period_replacement = isset($wplc_settings['wplc_gdpr_notice_retention_period']) ? intval($wplc_settings['wplc_gdpr_notice_retention_period']) : 30;
378
-
379
- if($period_replacement < 1){ $period_replacement = 1; }
380
-
381
- $localized_notice = str_replace("%%COMPANY%%", $company_replacement, $localized_notice);
382
- $localized_notice = str_replace("%%PURPOSE%%", $purpose_replacement, $localized_notice);
383
- $localized_notice = str_replace("%%PERIOD%%", $period_replacement, $localized_notice);
384
-
385
- $localized_notice = apply_filters('wplc_gdpr_retention_agreement_notice_filter', $localized_notice);
386
-
387
- return $localized_notice;
388
- }
389
-
390
- add_filter('wplc_gdpr_create_opt_in_checkbox_filter', 'wplc_gdpr_add_wplc_privacy_notice', 10, 1);
391
- /**
392
- * WPLC Compliance notice and link to policy
393
- */
394
- function wplc_gdpr_add_wplc_privacy_notice($content){
395
- $link = '<a href="https://wp-livechat.com/privacy-policy/" target="_blank">' . __('Privacy Policy', 'wplivechat') . '</a>';
396
- $localized_content = __('We use WP Live Chat Support as our live chat platform. By clicking below to submit this form, you acknowledge that the information you provide now and during the chat will be transferred to WP Live Chat Support for processing in accordance with their %%POLICY_LINK%%.', 'wplivechat');
397
-
398
- $localized_content = str_replace("%%POLICY_LINK%%", $link, $localized_content);
399
- $html = "<div class='wplc_gdpr_privacy_notice'>$localized_content</div>";
400
-
401
- return $content . $html;
402
- }
403
-
404
- add_action("wplc_before_history_table_hook", "wplc_gdpr_retention_cron_notice");
405
- add_action("wplc_hook_chat_missed", "wplc_gdpr_retention_cron_notice");
406
- add_action("wplc_hook_offline_messages_display", "wplc_gdpr_retention_cron_notice", 1);
407
- /**
408
- * Shows a notice which notifies the admin that all messages older than the retention period will be removed
409
- */
410
- function wplc_gdpr_retention_cron_notice(){
411
- $wplc_settings = get_option("WPLC_SETTINGS");
412
-
413
- if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
414
- $period_replacement = isset($wplc_settings['wplc_gdpr_notice_retention_period']) ? intval($wplc_settings['wplc_gdpr_notice_retention_period']) : 30;
415
-
416
- if($period_replacement < 1){ $period_replacement = 1; }
417
-
418
- $retention_period_message = __("Please note as per the GDPR settings you have selected, all chat data will be retained for %%PERIOD%% day(s).", "wplivechat");
419
- $retention_period_message = str_replace("%%PERIOD%%", $period_replacement, $retention_period_message);
420
-
421
- $retention_period_message_alt = __("After this period of time, all chat data older than %%PERIOD%% day(s), will be permanently removed from your server. ", "wplivechat");
422
- $retention_period_message_alt = str_replace("%%PERIOD%%", $period_replacement, $retention_period_message_alt);
423
-
424
- $output = "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>";
425
- $output .= "<strong>" . __("GDPR - Data Retention", "wplivechat") . "</strong><br>";
426
- $output .= "<p>" . $retention_period_message . "</p>";
427
- $output .= "<p>" . $retention_period_message_alt . "</p>";
428
-
429
- $output .= apply_filters('wplc_gdpr_retention_cron_notice_extender_hook', "");
430
-
431
- $output .= "<a class='button' href='?page=wplivechat-menu-settings#tabs-privacy' >" . __("Privacy Settings", "wplivechat") . "</a>";
432
- $output .= "</div>";
433
- echo $output;
434
-
435
- }
436
- }
437
-
438
- add_filter('cron_schedules','wplc_gdpr_custom_cron_schedules', 10, 1);
439
- /**
440
- * Setup a cron schedule
441
- */
442
- function wplc_gdpr_custom_cron_schedules($schedules){
443
- if(!isset($schedules["wplc_6_hour"])){
444
- $schedules["wplc_6_hour"] = array(
445
- 'interval' => 6*60*60,
446
- 'display' => __('Once every 6 hours'));
447
- }
448
-
449
- return $schedules;
450
- }
451
-
452
- /**
453
- * Checks if cron is still registered
454
- */
455
- function wplc_gdpr_check_for_cron(){
456
- $cron_jobs = get_option( 'cron' );
457
- $cron_found = false;
458
- foreach ($cron_jobs as $cron_key => $cron_data) {
459
- if(is_array($cron_data)){
460
- foreach ($cron_data as $cron_inner_key => $cron_inner_data) {
461
- if($cron_inner_key === "wplc_gdpr_cron_hook"){
462
- $cron_found = true;
463
- }
464
- }
465
- }
466
- }
467
-
468
- if(!$cron_found){
469
- do_action('wplc_gdpr_reg_cron_hook'); //The cron was unregistered at some point. Lets fix that
470
- }
471
- }
472
-
473
- add_action('wplc_gdpr_reg_cron_hook', 'wplc_gdpr_register_cron');
474
- /**
475
- * Cron Register
476
- */
477
- function wplc_gdpr_register_cron(){
478
- $wplc_settings = get_option('WPLC_SETTINGS');
479
- if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
480
- wp_schedule_event( time(), 'wplc_6_hour', 'wplc_gdpr_cron_hook' );
481
- }
482
-
483
- }
484
-
485
- add_action('wplc_gdpr_de_reg_cron_hook', 'wplc_gdpr_de_register_cron');
486
- /**
487
- * Cron De-Register
488
- */
489
- function wplc_gdpr_de_register_cron(){
490
- wp_clear_scheduled_hook('wplc_gdpr_cron_hook');
491
- }
492
-
493
-
494
- add_action('wplc_gdpr_cron_hook', 'wplc_gdpr_cron_delete_chats');
495
- /**
496
- * GDPR Cron for deleting chats that are old school
497
- */
498
- function wplc_gdpr_cron_delete_chats(){
499
- global $wpdb, $wplc_tblname_chats, $wplc_tblname_msgs, $wplc_tblname_offline_msgs;
500
- $wplc_settings = get_option("WPLC_SETTINGS");
501
- if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
502
- $period_replacement = isset($wplc_settings['wplc_gdpr_notice_retention_period']) ? intval($wplc_settings['wplc_gdpr_notice_retention_period']) : 30;
503
-
504
- if($period_replacement < 1){ $period_replacement = 1; }
505
-
506
- $days_ago = date('Y-m-d', strtotime('-' . $period_replacement . ' days', time()));
507
-
508
- $results_chats = $wpdb->get_results("DELETE FROM $wplc_tblname_chats WHERE `timestamp` < '$days_ago'", ARRAY_A);
509
- $results_messages = $wpdb->get_results("DELETE FROM $wplc_tblname_msgs WHERE `timestamp` < '$days_ago'", ARRAY_A);
510
- $results_offline = $wpdb->get_results("DELETE FROM $wplc_tblname_offline_msgs WHERE `timestamp` < '$days_ago'", ARRAY_A);
511
-
512
- do_action('wplc_cron_delete_chats_extender', $days_ago);
513
- }
514
- }
515
-
516
- add_filter('wplc_filter_live_chat_box_html_start_chat_button', 'wplc_gdpr_create_opt_in_checkbox_in_chatbox', 10, 2);
517
- add_filter('wplc_filter_live_chat_box_html_send_offline_message_button', 'wplc_gdpr_create_opt_in_checkbox_in_chatbox', 10, 2);
518
- /**
519
- * Checkbox opt in please
520
- */
521
- function wplc_gdpr_create_opt_in_checkbox_in_chatbox($filter_content, $wplc_cid = false){
522
- $wplc_settings = get_option("WPLC_SETTINGS");
523
- if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
524
- $checkbox = "<input type='checkbox' id='wplc_chat_gdpr_opt_in'> <label for='wplc_chat_gdpr_opt_in'>" . wplc_gdpr_generate_retention_agreement_notice($wplc_settings) . "</label>";
525
-
526
- $checkbox = apply_filters('wplc_gdpr_create_opt_in_checkbox_filter', $checkbox);
527
-
528
- $filter_content = $checkbox . $filter_content;
529
-
530
- }
531
-
532
- return $filter_content;
533
- }
534
-
535
- add_filter('wplc_start_button_custom_attributes_filter', 'wplc_gdpr_chat_box_opt_in_custom_attributes', 10, 2);
536
- add_filter('wplc_offline_message_button_custom_attributes_filter', 'wplc_gdpr_chat_box_opt_in_custom_attributes', 10, 2);
537
- add_filter('wplc_end_button_custom_attributes_filter', 'wplc_gdpr_chat_box_opt_in_custom_attributes', 10, 2);
538
- /**
539
- * Adds custom attributes to the start chat, and offline messages buttons to prevent click without opt in
540
- */
541
- function wplc_gdpr_chat_box_opt_in_custom_attributes($content, $wplc_settings = false){
542
- if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
543
-
544
- if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
545
- $content .= " data-wplc-gdpr-enabled='true' ";
546
- }
547
-
548
- return $content;
549
- }
550
-
551
- add_filter("wplc_filter_inner_live_chat_box_4th_layer", "wplc_gdpr_end_chat_action_prompt", 10, 2);
552
- /**
553
- * Creates the GDPR end chat notice/prompt
554
- */
555
- function wplc_gdpr_end_chat_action_prompt($content, $wplc_settings = false){
556
- if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
557
-
558
- $notice_html = "";
559
- if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
560
- $remove_data_button = "<button id='wplc_gdpr_remove_data_button' class='wplc-color-bg-1 wplc-color-2' data-wplc-rest-nonce='" . wp_create_nonce('wp_rest'). "' data-wplc-rest-url='" . wplc_gdpr_get_rest_url() ."'>" . __("Delete Chat Data", "wplivechat") . "</button>";
561
- $download_data_button = "<button id='wplc_gdpr_download_data_button' class='wplc-color-bg-1 wplc-color-2' data-wplc-init-nonce='" . wp_create_nonce( 'wplc-init-nonce-' . date('Y-m-d') ). "'>" . __("Download Chat Data", "wplivechat") . "</button>";
562
-
563
- $notice_html = "<div class='wplc_in_chat_notice' id='wplc_gdpr_end_chat_notice_container' style='display:none;'>";
564
- $notice_html .= "<div class='wplc_in_chat_notice_heading'>" . __("Chat Ended", "wplivechat") . "</div>";
565
- $notice_html .= "<div class='wplc_in_chat_notice_content'>" . $download_data_button . " " . $remove_data_button . "</div>";
566
- $notice_html .= "</div>";
567
- }
568
-
569
- return $notice_html . $content;
570
-
571
- }
572
-
573
- add_action('init', 'wplc_gdpr_front_end_download_chat');
574
- /**
575
- * Runs a special function on init on the front end of the site. This allows us to write out a json file as long as certain spec is met
576
- */
577
- function wplc_gdpr_front_end_download_chat(){
578
- if(isset($_GET['wplc_action']) && isset($_GET['wplc_init_nonce']) && isset($_GET['wplc_cid'])){
579
- if($_GET['wplc_action'] === 'wplc_gdpr_download_chat_json'){
580
- if(wp_verify_nonce( htmlspecialchars($_GET['wplc_init_nonce']), 'wplc-init-nonce-' . date('Y-m-d'))){
581
- $chat_id = sanitize_text_field($_GET['wplc_cid']);
582
- if( ! filter_var($chat_id, FILTER_VALIDATE_INT) ) {
583
- /* We need to identify if this CID is a node CID, and if so, return the WP CID */
584
- $chat_id = wplc_return_chat_id_by_rel($chat_id);
585
- }
586
- wplc_gdpr_download_chat('chat_session', $chat_id);
587
- }
588
- }
589
- }
590
- }
591
-
592
- /**
593
- * A simle wrapper for getting the rest URL
594
- */
595
- function wplc_gdpr_get_rest_url(){
596
- if(function_exists('get_rest_url')){
597
- return get_rest_url() . "wp_live_chat_support/v1/gdpr";
598
- } else {
599
- return get_site_url() . "/wp-json/wp_live_chat_support/v1/gdpr";
600
- }
601
- }
602
-
603
- add_action('wplc_api_route_hook', 'wplc_gdpr_rest_end_points');
604
- /**
605
- * Adds a special rest end point for processing deleting of chats
606
- */
607
- function wplc_gdpr_rest_end_points(){
608
- register_rest_route('wp_live_chat_support/v1/gdpr','/delete_chat', array(
609
- 'methods' => 'GET, POST',
610
- 'callback' => 'wplc_gdpr_rest_delete_chat',
611
- 'permission_callback' => 'wplc_gdpr_rest_api_nonce_verify'
612
- ));
613
- }
614
-
615
- /**
616
- * GDPR Rest permission checks
617
- */
618
- function wplc_gdpr_rest_api_nonce_verify(){
619
- // $wplc_rest_access_allowed = wp_verify_nonce( $_REQUEST['wplc_rest_nonce'], 'wplc-gdpr-rest-nonce-' . date('Y-m-d'));
620
-
621
- $wplc_rest_access_allowed = check_ajax_referer('wp_rest', '_nonce' , false);
622
- // $wplc_rest_access_allowed = wp_verify_nonce($_REQUEST['wplc_rest_nonce'], 'wplc-gdpr-rest-nonce-' . date('Y-m-d'));
623
-
624
- return $wplc_rest_access_allowed;
625
- }
626
-
627
- /**
628
- * Handles the deleting of chats via the rest api
629
- */
630
- function wplc_gdpr_rest_delete_chat(WP_REST_Request $request ){
631
- $return_array = array();
632
- if(isset($request)){
633
- if(isset($request['wplc_cid'])){
634
- $chat_id = sanitize_text_field($request['wplc_cid']);
635
- if( ! filter_var($chat_id, FILTER_VALIDATE_INT) ) {
636
- /* We need to identify if this CID is a node CID, and if so, return the WP CID */
637
- $chat_id = wplc_return_chat_id_by_rel($chat_id);
638
-
639
- }
640
-
641
- wplc_gdpr_delete_chat('chat_session', $chat_id, false);
642
-
643
- $return_array['response'] = __('Complete', 'wplivechat');
644
- $return_array['cid'] = $chat_id;
645
- }
646
- }
647
-
648
- return $return_array;
649
-
650
- }
651
-
652
- add_action('admin_notices', 'wplc_gdpr_disabled_warning');
653
- /**
654
- * Notice of doom
655
- */
656
- function wplc_gdpr_disabled_warning(){
657
-
658
- if(isset($_GET['wplc_gdpr_dismiss_notice'])){
659
- update_option('WPLC_GDPR_DISABLED_WARNING_DISMISSED', 'true');
660
- }
661
-
662
- if(isset($_GET['page'])){
663
- if($_GET['page'] === 'wplivechat-menu-settings'){
664
- $wplc_settings = get_option("WPLC_SETTINGS");
665
- if(!isset($wplc_settings['wplc_gdpr_enabled']) || $wplc_settings['wplc_gdpr_enabled'] != '1'){
666
- $gdpr_disabled_warning_dismissed = get_option('WPLC_GDPR_DISABLED_WARNING_DISMISSED', false);
667
- if($gdpr_disabled_warning_dismissed === false || $gdpr_disabled_warning_dismissed === 'false'){
668
- $implication_warning = __('GDPR compliance has been disabled, read more about the implications of this here', 'wplivechat');
669
- $privacy_warning = __('Additionally please take a look at WP Live Chat Support', 'wplivechat');
670
- $final_warning = __('It is highly recommended that you enable GDPR compliance to ensure your user data is regulated.', 'wplivechat');
671
-
672
- $output = "<div class='update-nag' style='margin-bottom: 5px; border-color:#DD0000'>";
673
- $output .= "<strong>" . __("Warning - GDPR Compliance Disabled - Action Required", "wplivechat") . "</strong><br>";
674
- $output .= "<p>" . $implication_warning . ": <a href='https://www.eugdpr.org/' target='_blank'>" . __('EU GDPR', 'wplivechat') . "</a></p>";
675
- $output .= "<p>" . $privacy_warning . " <a href='https://wp-livechat.com/privacy-policy/' target='_blank'>" . __('Privacy Policy', 'wplivechat') . "</a></p>";
676
- $output .= "<p>" . $final_warning . "</p>";
677
- $output .= "<a class='button' href='?page=wplivechat-menu-settings#tabs-privacy' >" . __("Privacy Settings", "wplivechat") . "</a> ";
678
- $output .= "<a class='button' href='?page=" . htmlspecialchars($_GET['page']) ."&wplc_gdpr_dismiss_notice=true' style='color: #fff;background-color: #bb0000;border-color: #c70000;'>" . __("Dismiss & Accept Responsibility", "wplivechat") . "</a>";
679
- $output .= "</div>";
680
- echo $output;
681
- }
682
- }
683
- }
684
- }
685
- }
686
-
687
-
688
- add_filter( 'admin_footer_text', 'wplc_gdpr_footer_mod', 99, 1);
689
- /**
690
- * Adds the data privacy notices
691
- */
692
- 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>';
700
- }
701
- }
702
-
703
- return $footer_text;
704
-
705
- }
706
-
707
- add_filter( 'wplc_node_server_us_options_enabled', 'wplc_gdpr_allow_us_servers_check',10 ,2);
708
- /**
709
- * Checks if GDPR option is enabled so we can force users into the EU
710
- */
711
- function wplc_gdpr_allow_us_servers_check($is_allowed, $wplc_settings = false){
712
- if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
713
-
714
- if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
715
- return false;
716
- }
717
-
718
- return $is_allowed;
719
- }
720
-
721
-
722
- add_filter( 'wplc_node_server_default_selection_override', 'wplc_gdpr_node_server_eu_default_override',10,2);
723
- /**
724
- * Checks if GDPR option is enabled so we can force users into the EU
725
- */
726
- function wplc_gdpr_node_server_eu_default_override($selected, $wplc_settings = false){
727
- if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
728
- if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
729
- if($selected === 'auto' || $selected === 'us1' || $selected === 'us2'){
730
- //This is not allowed in the GDPR
731
- $selected = 'eu1';
732
- }
733
- }
734
-
735
- return $selected;
736
- }
737
-
738
-
739
- add_action('wplc_node_server_selection_notices', 'wplc_gdpr_node_server_override_notice',10,1);
740
- /**
741
- * Will add a very simple server override if GDPR is enabled
742
- */
743
- function wplc_gdpr_node_server_override_notice($wplc_settings = false){
744
- if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
745
- if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
746
- echo "<small><strong><em>" . __("GDPR Compliance Enabled - Server Selection Limited to EU", "wplivechat") . "</em></strong></small>";
747
- }
748
- }
749
-
750
- add_filter('wplc_update_settings_between_versions_hook', 'wplc_gdpr_update_settings_between_versions',10,1);
751
- /**
752
- * This will handle the auto update magic. Although we have a default in place this is far superior as it is a hard data set
753
- */
754
- function wplc_gdpr_update_settings_between_versions($wplc_settings){
755
- if(is_array($wplc_settings)){
756
- $gdpr_enabled_atleast_once_before = get_option('WPLC_GDPR_ENABLED_AT_LEAST_ONCE', false);
757
- if($gdpr_enabled_atleast_once_before === false){
758
- //Only fire if this user has never had GDPR enabled before
759
- update_option('WPLC_GDPR_ENABLED_AT_LEAST_ONCE', 'true');
760
- $wplc_settings['wplc_gdpr_enabled'] = '0';
761
- }
762
- }
763
-
764
- return $wplc_settings;
765
  }
1
+ <?php
2
+
3
+ /**
4
+ * GDPR Compliance Module
5
+ */
6
+
7
+ add_filter("wplc_activate_default_settings_array", "wplc_gdpr_set_default_settings", 10, 1);
8
+ /*
9
+ * Sets the default GDPR options
10
+ */
11
+ function wplc_gdpr_set_default_settings($wplc_default_settings_array){
12
+ //Disabled by default on new installations
13
+ /*if(is_array($wplc_default_settings_array)){
14
+ if(!isset($wplc_default_settings_array['wplc_gdpr_enabled'])){
15
+ //Is not set already
16
+ //$wplc_default_settings_array['wplc_gdpr_enabled'] = 0;
17
+ }
18
+ }*/
19
+ return $wplc_default_settings_array;
20
+ }
21
+
22
+ add_action("wplc_hook_privacy_options_content", "wplc_gdpr_settings_content", 10, 1);
23
+ /**
24
+ * Adds the GDPR sepcific settings to the Privacy tab
25
+ */
26
+ function wplc_gdpr_settings_content($wplc_settings = false){
27
+ if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
28
+
29
+ ?>
30
+ <table class="wp-list-table wplc_list_table widefat fixed striped pages">
31
+ <tbody>
32
+ <tr>
33
+ <td width="250" valign="top">
34
+ <label for="wplc_gdpr_enabled"><?php _e("Enbled GDPR Compliance", "wplivechat"); ?> <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e('Disabling will disable all GDPR related options, this is not advised.', 'wplivechat'); ?>"></i></label>
35
+ </td>
36
+ <td>
37
+ <input type="checkbox" name="wplc_gdpr_enabled" value="1" <?php echo(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1' ? 'checked' : ''); ?> >
38
+ <a href="https://www.eugdpr.org/" target="_blank"><?php _e("Importance of GDPR Compliance", "wplivechat"); ?></a>
39
+ </td>
40
+ </tr>
41
+
42
+ <tr>
43
+ <td width="250" valign="top">
44
+ <label for="wplc_gdpr_notice_company"><?php _e("Company Name", "wplivechat"); ?></label>
45
+ </td>
46
+ <td>
47
+ <input type="text" name="wplc_gdpr_notice_company" value="<?php echo(isset($wplc_settings['wplc_gdpr_notice_company']) ? $wplc_settings['wplc_gdpr_notice_company'] : get_bloginfo('name')); ?>" >
48
+ </td>
49
+ </tr>
50
+
51
+ <tr>
52
+ <td width="250" valign="top">
53
+ <label for="wplc_gdpr_notice_retention_purpose"><?php _e("Retention Purpose", "wplivechat"); ?></label>
54
+ </td>
55
+ <td>
56
+ <input type="text" name="wplc_gdpr_notice_retention_purpose" value="<?php echo(isset($wplc_settings['wplc_gdpr_notice_retention_purpose']) ? $wplc_settings['wplc_gdpr_notice_retention_purpose'] : __('Chat/Support', 'wplivechat')); ?>" >
57
+ </td>
58
+ </tr>
59
+
60
+ <tr>
61
+ <td width="250" valign="top">
62
+ <label for="wplc_gdpr_notice_retention_period"><?php _e("Retention Period", "wplivechat"); ?></label>
63
+ </td>
64
+ <td>
65
+ <input type="number" name="wplc_gdpr_notice_retention_period" value="<?php echo(isset($wplc_settings['wplc_gdpr_notice_retention_period']) ? intval($wplc_settings['wplc_gdpr_notice_retention_period']) < 1 ? 1 : intval($wplc_settings['wplc_gdpr_notice_retention_period']) : 30); ?>" > <?php _e('days', 'wplivechat'); ?>
66
+ </td>
67
+ </tr>
68
+
69
+ <tr>
70
+ <td width="250" valign="top">
71
+ <label><?php _e("Next Check", "wplivechat"); ?>
72
+ <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e('When the next cron will run to check for data which is older than our retention period.', 'wplivechat'); ?>"></i>
73
+ </label>
74
+ </td>
75
+ <td>
76
+ <span>
77
+ <?php
78
+ echo date('d-m-Y H:i:s', wp_next_scheduled('wplc_gdpr_cron_hook'));
79
+ ?>
80
+ </span>
81
+ </td>
82
+ </tr>
83
+
84
+ <tr>
85
+ <td width="250" valign="top">
86
+ <label><?php _e("GDPR Notice", "wplivechat"); ?>
87
+ <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e('Users will be asked to accept the notice shown here, in the form of a check box.', 'wplivechat'); ?>"></i>
88
+ </label>
89
+ </td>
90
+ <td>
91
+ <span>
92
+ <?php
93
+ echo wplc_gdpr_generate_retention_agreement_notice($wplc_settings);
94
+ echo "<br><br>";
95
+ echo apply_filters('wplc_gdpr_create_opt_in_checkbox_filter', "");
96
+ ?>
97
+ </span>
98
+ </td>
99
+ </tr>
100
+
101
+
102
+ </tbody>
103
+ </table>
104
+ <?php
105
+ }
106
+
107
+ add_filter("wplc_settings_save_filter_hook", "wplc_gdpr_settings_save_hooked", 10, 1);
108
+ /**
109
+ * Save the settings for GDPR
110
+ */
111
+ function wplc_gdpr_settings_save_hooked($wplc_data){
112
+
113
+ if (isset($_POST['wplc_gdpr_enabled'])) {
114
+ $wplc_data['wplc_gdpr_enabled'] = esc_attr($_POST['wplc_gdpr_enabled']);
115
+ do_action('wplc_gdpr_reg_cron_hook');
116
+
117
+ update_option('WPLC_GDPR_DISABLED_WARNING_DISMISSED', 'false');
118
+ } else {
119
+ do_action('wplc_gdpr_de_reg_cron_hook');
120
+ }
121
+
122
+ if (isset($_POST['wplc_gdpr_notice_company'])) { $wplc_data['wplc_gdpr_notice_company'] = esc_attr($_POST['wplc_gdpr_notice_company']); }
123
+ if (isset($_POST['wplc_gdpr_notice_retention_purpose'])) { $wplc_data['wplc_gdpr_notice_retention_purpose'] = esc_attr($_POST['wplc_gdpr_notice_retention_purpose']); }
124
+ if (isset($_POST['wplc_gdpr_notice_retention_period'])) { $wplc_data['wplc_gdpr_notice_retention_period'] = esc_attr($_POST['wplc_gdpr_notice_retention_period']); }
125
+
126
+ return $wplc_data;
127
+ }
128
+
129
+
130
+ add_action("wplc_hook_menu", "wplc_gdpr_add_menu");
131
+ /**
132
+ * Adds a menu specifically dedicated to GDPR
133
+ */
134
+ function wplc_gdpr_add_menu(){
135
+ $wplc_settings = get_option("WPLC_SETTINGS");
136
+
137
+ if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
138
+ add_submenu_page('wplivechat-menu', __('GDPR', 'wplivechat'), __('GDPR', 'wplivechat'), 'manage_options', 'wplivechat-menu-gdpr-page', 'wplc_gdpr_page_layout');
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Handles the layout for the GDPR page
144
+ */
145
+ function wplc_gdpr_page_layout(){
146
+ ?>
147
+ <h2><?php _e('WP Live Chat Support - GDPR', 'wplivechat'); ?></h2>
148
+
149
+ <small><em><?php _e("Search is performed on chat sessions, messages, and offline messages. Data will also be deleted automatically per your retention policy.", "wplivechat"); ?></em></small>
150
+ <?php do_action('wplc_gdpr_page_before_table_hook'); ?>
151
+ <table class="wp-list-table wplc_list_table widefat fixed striped pages">
152
+ <thead>
153
+ <tr>
154
+ <th></th>
155
+ <th>
156
+ </th>
157
+ <th>
158
+ <form method="GET" action="">
159
+ <input type="hidden" name="page" value='wplivechat-menu-gdpr-page'>
160
+ <input name='term' type="text" value='<?php echo(isset($_GET['term']) ? htmlspecialchars($_GET['term']) : ''); ?>' placeholder="<?php _e('Name, Email, Message', 'wplivechat'); ?>" style='height:30px; width: 70%'>
161
+
162
+ <?php do_action('wplc_gdpr_page_search_form_before_submit_hook'); ?>
163
+
164
+ <input type='submit' class='button' value="<?php _e("Search", "wplivechat"); ?>" >
165
+ </form>
166
+ </th>
167
+ </tr>
168
+ </thead>
169
+ <tbody>
170
+ <?php
171
+ if(isset($_GET['term'])){
172
+ $results = wplc_gdpr_return_chat_session_search_results(htmlspecialchars($_GET['term']));
173
+
174
+ foreach ($results as $heading => $sub_results) {
175
+ $original_heading = $heading;
176
+ $heading = ucwords(str_replace("_", " ", $heading));
177
+ $heading = str_replace("%%TABLE%%", $heading, __('Search Results in %%TABLE%%', 'wplivechat'));
178
+ ?>
179
+ <tr>
180
+ <td><strong><?php echo $heading; ?></strong></td>
181
+ <td></td>
182
+ <td style="text-align: right"><em><?php echo count($sub_results); ?></em></td>
183
+ </tr>
184
+ <?php
185
+
186
+ /**Setup Defaults*/
187
+ $cid_identidier = 'id';
188
+ $action_action_filter = 'chat_session';
189
+ $show_fields = array('name', 'email');
190
+ switch ($original_heading) {
191
+ case 'chat_messages':
192
+ $cid_identidier = 'chat_sess_id';
193
+ $show_fields = array('msg');
194
+ break;
195
+ case 'offline_messages':
196
+ $action_action_filter = 'offline_message';
197
+ $show_fields = array('name', 'email', 'message');
198
+ break;
199
+ }
200
+
201
+ $action_action_filter = htmlspecialchars($action_action_filter);
202
+
203
+ foreach ($sub_results as $key => $value) {
204
+ $cid = isset($value[$cid_identidier]) ? $value[$cid_identidier] : 'false';
205
+ $delete_button_text = str_replace("%%CID%%", $cid, __("Delete Chat (%%CID%%)", "wplivechat"));
206
+ $download_button_text = str_replace("%%CID%%", $cid, __("Download Chat (%%CID%%)", "wplivechat"));
207
+
208
+ ?>
209
+ <tr>
210
+ <td><?php echo(__('Chat ID', 'wplivechat') . ": " . $cid ); ?></td>
211
+ <td>
212
+ <?php
213
+ foreach ($value as $subkey => $sub_val) {
214
+ if(in_array($subkey, $show_fields)){
215
+ echo( sanitize_text_field($subkey) . ": " . str_replace("%%BREAK%%", "<br>", sanitize_text_field($sub_val) ) . "<br>");
216
+ }
217
+ }
218
+ ?>
219
+ </td>
220
+ <td>
221
+ <a class='button' href='?page=wplivechat-menu-gdpr-page&term=<?php echo(htmlspecialchars($_GET["term"])); ?>&action=delete&filter=<?php echo $action_action_filter; ?>&id=<?php echo htmlspecialchars($cid); ?>'><?php echo $delete_button_text; ?></a>
222
+ <a class='button button-primary' href='?page=wplivechat-menu-gdpr-page&term=<?php echo(htmlspecialchars($_GET["term"])); ?>&action=download&filter=<?php echo $action_action_filter; ?>&id=<?php echo htmlspecialchars($cid); ?>'><?php echo $download_button_text; ?></a>
223
+ </td>
224
+ </tr>
225
+ <?php
226
+ }
227
+ }
228
+ } else {
229
+ ?>
230
+ <tr>
231
+ <td><strong><?php _e('Please perform a search using the input field above', 'wplivechat'); ?></strong></td>
232
+ <td></td>
233
+ <td></td>
234
+ </tr>
235
+ <?php
236
+ }
237
+ ?>
238
+ </tbody>
239
+ </table>
240
+
241
+ <?php do_action('wplc_gdpr_page_after_table_hook'); ?>
242
+
243
+ <?php
244
+ }
245
+
246
+ add_action('admin_init', 'wplc_gdpr_admin_init', 1);
247
+ /**
248
+ * Runs on admin init, if we are on the GDPR page, we run the check action hook
249
+ * This will allow us to alter the header if needed for JSON files
250
+ */
251
+ function wplc_gdpr_admin_init(){
252
+ wplc_gdpr_check_for_cron();
253
+
254
+ if(isset($_GET['page']) && $_GET['page'] === 'wplivechat-menu-gdpr-page'){
255
+ do_action('wplc_gdpr_page_process_actions_hook');
256
+ }
257
+ }
258
+
259
+
260
+ add_action('wplc_gdpr_page_process_actions_hook', 'wplc_gdpr_page_process_actions');
261
+ /**
262
+ * Handles the magic processing of the GDPR page
263
+ */
264
+ function wplc_gdpr_page_process_actions(){
265
+ if(isset($_GET['action']) && isset($_GET['filter']) && isset($_GET['id'])){
266
+ $action = sanitize_text_field($_GET['action']);
267
+ $filter = sanitize_text_field($_GET['filter']);
268
+ $id = sanitize_text_field($_GET['id']);
269
+
270
+ if($action === 'delete'){
271
+ wplc_gdpr_delete_chat($filter, $id);
272
+ } else if($action === 'download'){
273
+ wplc_gdpr_download_chat($filter, $id);
274
+ }
275
+ }
276
+ }
277
+
278
+ /**
279
+ * Delete a chat
280
+ */
281
+ function wplc_gdpr_delete_chat($filter_type, $cid, $output = true){
282
+ global $wpdb, $wplc_tblname_offline_msgs, $wplc_tblname_chats, $wplc_tblname_msgs;
283
+ if($filter_type === 'chat_session'){
284
+ $wpdb->delete($wplc_tblname_chats, array('id' => $cid));
285
+ $wpdb->delete($wplc_tblname_msgs, array('chat_sess_id' => $cid));
286
+ } else if ($filter_type === 'offline_message'){
287
+ $wpdb->delete($wplc_tblname_offline_msgs, array('id' => $cid));
288
+ }
289
+
290
+ do_action('wplc_gdpr_delete_chat_extend_hook', $filter_type, $cid);
291
+
292
+ if($output){
293
+ $output = "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>";
294
+ $output .= "<strong>" . __("Data Deleted", "wplivechat") . "(" . $cid . ")" . "</strong><br>";
295
+ $output .= "</div>";
296
+ echo $output;
297
+ }
298
+ }
299
+
300
+ /**
301
+ * Download a chat
302
+ */
303
+ function wplc_gdpr_download_chat($filter_type, $cid){
304
+ global $wpdb, $wplc_tblname_offline_msgs, $wplc_tblname_chats, $wplc_tblname_msgs;
305
+ if($filter_type === 'chat_session'){
306
+ $result_chat_session = $wpdb->get_results("SELECT * FROM $wplc_tblname_chats WHERE `id` = '$cid' LIMIT 1", ARRAY_A);
307
+ $result_chat_messages = $wpdb->get_results("SELECT * FROM $wplc_tblname_msgs WHERE `chat_sess_id` = '$cid'", ARRAY_A);
308
+
309
+ if(count($result_chat_session) > 0){
310
+ $chat_session = $result_chat_session[0];
311
+
312
+ $chat_session['messages'] = array();
313
+ foreach ($result_chat_messages as $key => $value) {
314
+ $chat_session['messages'][] = $value;
315
+ }
316
+
317
+ $chat_session = apply_filters('wplc_gdpr_download_chat_extender_hook', $chat_session, $cid);
318
+
319
+ //var_dump(json_encode($chat_session));
320
+
321
+ header('Content-disposition: attachment; filename=chat_export_' . $cid . '.json');
322
+ header('Content-type: application/json');
323
+ echo json_encode($chat_session);
324
+ die(); //Let's stop any further data capture please and thank you
325
+ }
326
+ } else if ($filter_type === 'offline_message'){
327
+
328
+ }
329
+ }
330
+
331
+ /**
332
+ * Searches the db for all relevant chat sessions based on the search term
333
+ */
334
+ function wplc_gdpr_return_chat_session_search_results($term){
335
+ global $wpdb, $wplc_tblname_offline_msgs, $wplc_tblname_chats, $wplc_tblname_msgs;
336
+
337
+ $term = sanitize_text_field($term);
338
+
339
+ $results_chats = $wpdb->get_results("SELECT * FROM $wplc_tblname_chats WHERE `name` LIKE '%$term%' OR `email` LIKE '%$term%'", ARRAY_A);
340
+ $results_message = $wpdb->get_results("SELECT * FROM $wplc_tblname_msgs WHERE `msg` LIKE '%$term%'", ARRAY_A);
341
+ $results_offline = $wpdb->get_results("SELECT * FROM $wplc_tblname_offline_msgs WHERE `name` LIKE '%$term%' OR `email` LIKE '%$term%' OR `message` LIKE '%$term%'", ARRAY_A);
342
+
343
+ $formatted_messages = array();
344
+ foreach ($results_message as $key => $value) {
345
+ $cid = isset($value['chat_sess_id']) ? $value['chat_sess_id'] : false;
346
+ if($cid !== false){
347
+ $msg = maybe_unserialize($value['msg']);
348
+ $msg = is_array($msg) ? $msg['m'] : $msg;
349
+ if(!isset($formatted_messages[$cid])){
350
+ $formatted_messages[$cid]['chat_sess_id'] = $cid;
351
+ $formatted_messages[$cid]['msg'] = $msg . "%%BREAK%%";
352
+ } else {
353
+ $formatted_messages[$cid]['msg'] .= $msg . "%%BREAK%%";
354
+ }
355
+ }
356
+ }
357
+
358
+ $return_results = array(
359
+ 'chat_sessions' => $results_chats,
360
+ 'chat_messages' => $formatted_messages,
361
+ 'offline_messages' => $results_offline
362
+ );
363
+
364
+ return $return_results;
365
+
366
+ }
367
+
368
+ /**
369
+ * Generates a localized retention notice message
370
+ */
371
+ function wplc_gdpr_generate_retention_agreement_notice($wplc_settings = false){
372
+ if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
373
+
374
+ $localized_notice = __("I agree for my personal data to be processed and for the use of cookies in order to engage in a chat processed by %%COMPANY%%, for the purpose of %%PURPOSE%%, for the time of %%PERIOD%% day(s) as per the GDPR.", "wplivechat");
375
+ $company_replacement = isset($wplc_settings['wplc_gdpr_notice_company']) ? $wplc_settings['wplc_gdpr_notice_company'] : get_bloginfo('name');
376
+ $purpose_replacement = isset($wplc_settings['wplc_gdpr_notice_retention_purpose']) ? $wplc_settings['wplc_gdpr_notice_retention_purpose'] : __('Chat/Support', 'wplivechat');
377
+ $period_replacement = isset($wplc_settings['wplc_gdpr_notice_retention_period']) ? intval($wplc_settings['wplc_gdpr_notice_retention_period']) : 30;
378
+
379
+ if($period_replacement < 1){ $period_replacement = 1; }
380
+
381
+ $localized_notice = str_replace("%%COMPANY%%", $company_replacement, $localized_notice);
382
+ $localized_notice = str_replace("%%PURPOSE%%", $purpose_replacement, $localized_notice);
383
+ $localized_notice = str_replace("%%PERIOD%%", $period_replacement, $localized_notice);
384
+
385
+ $localized_notice = apply_filters('wplc_gdpr_retention_agreement_notice_filter', $localized_notice);
386
+
387
+ return $localized_notice;
388
+ }
389
+
390
+ add_filter('wplc_gdpr_create_opt_in_checkbox_filter', 'wplc_gdpr_add_wplc_privacy_notice', 10, 1);
391
+ /**
392
+ * WPLC Compliance notice and link to policy
393
+ */
394
+ function wplc_gdpr_add_wplc_privacy_notice($content){
395
+ $link = '<a href="https://wp-livechat.com/privacy-policy/" target="_blank">' . __('Privacy Policy', 'wplivechat') . '</a>';
396
+ $localized_content = __('We use WP Live Chat Support as our live chat platform. By clicking below to submit this form, you acknowledge that the information you provide now and during the chat will be transferred to WP Live Chat Support for processing in accordance with their %%POLICY_LINK%%.', 'wplivechat');
397
+
398
+ $localized_content = str_replace("%%POLICY_LINK%%", $link, $localized_content);
399
+ $html = "<div class='wplc_gdpr_privacy_notice'>$localized_content</div>";
400
+
401
+ return $content . $html;
402
+ }
403
+
404
+ add_action("wplc_before_history_table_hook", "wplc_gdpr_retention_cron_notice");
405
+ add_action("wplc_hook_chat_missed", "wplc_gdpr_retention_cron_notice");
406
+ add_action("wplc_hook_offline_messages_display", "wplc_gdpr_retention_cron_notice", 1);
407
+ /**
408
+ * Shows a notice which notifies the admin that all messages older than the retention period will be removed
409
+ */
410
+ function wplc_gdpr_retention_cron_notice(){
411
+ $wplc_settings = get_option("WPLC_SETTINGS");
412
+
413
+ if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
414
+ $period_replacement = isset($wplc_settings['wplc_gdpr_notice_retention_period']) ? intval($wplc_settings['wplc_gdpr_notice_retention_period']) : 30;
415
+
416
+ if($period_replacement < 1){ $period_replacement = 1; }
417
+
418
+ $retention_period_message = __("Please note as per the GDPR settings you have selected, all chat data will be retained for %%PERIOD%% day(s).", "wplivechat");
419
+ $retention_period_message = str_replace("%%PERIOD%%", $period_replacement, $retention_period_message);
420
+
421
+ $retention_period_message_alt = __("After this period of time, all chat data older than %%PERIOD%% day(s), will be permanently removed from your server. ", "wplivechat");
422
+ $retention_period_message_alt = str_replace("%%PERIOD%%", $period_replacement, $retention_period_message_alt);
423
+
424
+ $output = "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>";
425
+ $output .= "<strong>" . __("GDPR - Data Retention", "wplivechat") . "</strong><br>";
426
+ $output .= "<p>" . $retention_period_message . "</p>";
427
+ $output .= "<p>" . $retention_period_message_alt . "</p>";
428
+
429
+ $output .= apply_filters('wplc_gdpr_retention_cron_notice_extender_hook', "");
430
+
431
+ $output .= "<a class='button' href='?page=wplivechat-menu-settings#tabs-privacy' >" . __("Privacy Settings", "wplivechat") . "</a>";
432
+ $output .= "</div>";
433
+ echo $output;
434
+
435
+ }
436
+ }
437
+
438
+ add_filter('cron_schedules','wplc_gdpr_custom_cron_schedules', 10, 1);
439
+ /**
440
+ * Setup a cron schedule
441
+ */
442
+ function wplc_gdpr_custom_cron_schedules($schedules){
443
+ if(!isset($schedules["wplc_6_hour"])){
444
+ $schedules["wplc_6_hour"] = array(
445
+ 'interval' => 6*60*60,
446
+ 'display' => __('Once every 6 hours'));
447
+ }
448
+
449
+ return $schedules;
450
+ }
451
+
452
+ /**
453
+ * Checks if cron is still registered
454
+ */
455
+ function wplc_gdpr_check_for_cron(){
456
+ $cron_jobs = get_option( 'cron' );
457
+ $cron_found = false;
458
+ foreach ($cron_jobs as $cron_key => $cron_data) {
459
+ if(is_array($cron_data)){
460
+ foreach ($cron_data as $cron_inner_key => $cron_inner_data) {
461
+ if($cron_inner_key === "wplc_gdpr_cron_hook"){
462
+ $cron_found = true;
463
+ }
464
+ }
465
+ }
466
+ }
467
+
468
+ if(!$cron_found){
469
+ do_action('wplc_gdpr_reg_cron_hook'); //The cron was unregistered at some point. Lets fix that
470
+ }
471
+ }
472
+
473
+ add_action('wplc_gdpr_reg_cron_hook', 'wplc_gdpr_register_cron');
474
+ /**
475
+ * Cron Register
476
+ */
477
+ function wplc_gdpr_register_cron(){
478
+ $wplc_settings = get_option('WPLC_SETTINGS');
479
+ if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
480
+ wp_schedule_event( time(), 'wplc_6_hour', 'wplc_gdpr_cron_hook' );
481
+ }
482
+
483
+ }
484
+
485
+ add_action('wplc_gdpr_de_reg_cron_hook', 'wplc_gdpr_de_register_cron');
486
+ /**
487
+ * Cron De-Register
488
+ */
489
+ function wplc_gdpr_de_register_cron(){
490
+ wp_clear_scheduled_hook('wplc_gdpr_cron_hook');
491
+ }
492
+
493
+
494
+ add_action('wplc_gdpr_cron_hook', 'wplc_gdpr_cron_delete_chats');
495
+ /**
496
+ * GDPR Cron for deleting chats that are old school
497
+ */
498
+ function wplc_gdpr_cron_delete_chats(){
499
+ global $wpdb, $wplc_tblname_chats, $wplc_tblname_msgs, $wplc_tblname_offline_msgs;
500
+ $wplc_settings = get_option("WPLC_SETTINGS");
501
+ if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
502
+ $period_replacement = isset($wplc_settings['wplc_gdpr_notice_retention_period']) ? intval($wplc_settings['wplc_gdpr_notice_retention_period']) : 30;
503
+
504
+ if($period_replacement < 1){ $period_replacement = 1; }
505
+
506
+ $days_ago = date('Y-m-d', strtotime('-' . $period_replacement . ' days', time()));
507
+
508
+ $results_chats = $wpdb->get_results("DELETE FROM $wplc_tblname_chats WHERE `timestamp` < '$days_ago'", ARRAY_A);
509
+ $results_messages = $wpdb->get_results("DELETE FROM $wplc_tblname_msgs WHERE `timestamp` < '$days_ago'", ARRAY_A);
510
+ $results_offline = $wpdb->get_results("DELETE FROM $wplc_tblname_offline_msgs WHERE `timestamp` < '$days_ago'", ARRAY_A);
511
+
512
+ do_action('wplc_cron_delete_chats_extender', $days_ago);
513
+ }
514
+ }
515
+
516
+ add_filter('wplc_filter_live_chat_box_html_start_chat_button', 'wplc_gdpr_create_opt_in_checkbox_in_chatbox', 10, 2);
517
+ add_filter('wplc_filter_live_chat_box_html_send_offline_message_button', 'wplc_gdpr_create_opt_in_checkbox_in_chatbox', 10, 2);
518
+ /**
519
+ * Checkbox opt in please
520
+ */
521
+ function wplc_gdpr_create_opt_in_checkbox_in_chatbox($filter_content, $wplc_cid = false){
522
+ $wplc_settings = get_option("WPLC_SETTINGS");
523
+ if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
524
+ $checkbox = "<input type='checkbox' id='wplc_chat_gdpr_opt_in'> <label for='wplc_chat_gdpr_opt_in'>" . wplc_gdpr_generate_retention_agreement_notice($wplc_settings) . "</label>";
525
+
526
+ $checkbox = apply_filters('wplc_gdpr_create_opt_in_checkbox_filter', $checkbox);
527
+
528
+ $filter_content = $checkbox . $filter_content;
529
+
530
+ }
531
+
532
+ return $filter_content;
533
+ }
534
+
535
+ add_filter('wplc_start_button_custom_attributes_filter', 'wplc_gdpr_chat_box_opt_in_custom_attributes', 10, 2);
536
+ add_filter('wplc_offline_message_button_custom_attributes_filter', 'wplc_gdpr_chat_box_opt_in_custom_attributes', 10, 2);
537
+ add_filter('wplc_end_button_custom_attributes_filter', 'wplc_gdpr_chat_box_opt_in_custom_attributes', 10, 2);
538
+ /**
539
+ * Adds custom attributes to the start chat, and offline messages buttons to prevent click without opt in
540
+ */
541
+ function wplc_gdpr_chat_box_opt_in_custom_attributes($content, $wplc_settings = false){
542
+ if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
543
+
544
+ if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
545
+ $content .= " data-wplc-gdpr-enabled='true' ";
546
+ }
547
+
548
+ return $content;
549
+ }
550
+
551
+ add_filter("wplc_filter_inner_live_chat_box_4th_layer", "wplc_gdpr_end_chat_action_prompt", 10, 2);
552
+ /**
553
+ * Creates the GDPR end chat notice/prompt
554
+ */
555
+ function wplc_gdpr_end_chat_action_prompt($content, $wplc_settings = false){
556
+ if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
557
+
558
+ $notice_html = "";
559
+ if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
560
+ $remove_data_button = "<button id='wplc_gdpr_remove_data_button' class='wplc-color-bg-1 wplc-color-2' data-wplc-rest-nonce='" . wp_create_nonce('wp_rest'). "' data-wplc-rest-url='" . wplc_gdpr_get_rest_url() ."'>" . __("Delete Chat Data", "wplivechat") . "</button>";
561
+ $download_data_button = "<button id='wplc_gdpr_download_data_button' class='wplc-color-bg-1 wplc-color-2' data-wplc-init-nonce='" . wp_create_nonce( 'wplc-init-nonce-' . date('Y-m-d') ). "'>" . __("Download Chat Data", "wplivechat") . "</button>";
562
+
563
+ $notice_html = "<div class='wplc_in_chat_notice' id='wplc_gdpr_end_chat_notice_container' style='display:none;'>";
564
+ $notice_html .= "<div class='wplc_in_chat_notice_heading'>" . __("Chat Ended", "wplivechat") . "</div>";
565
+ $notice_html .= "<div class='wplc_in_chat_notice_content'>" . $download_data_button . " " . $remove_data_button . "</div>";
566
+ $notice_html .= "</div>";
567
+ }
568
+
569
+ return $notice_html . $content;
570
+
571
+ }
572
+
573
+ add_action('init', 'wplc_gdpr_front_end_download_chat');
574
+ /**
575
+ * Runs a special function on init on the front end of the site. This allows us to write out a json file as long as certain spec is met
576
+ */
577
+ function wplc_gdpr_front_end_download_chat(){
578
+ if(isset($_GET['wplc_action']) && isset($_GET['wplc_init_nonce']) && isset($_GET['wplc_cid'])){
579
+ if($_GET['wplc_action'] === 'wplc_gdpr_download_chat_json'){
580
+ if(wp_verify_nonce( htmlspecialchars($_GET['wplc_init_nonce']), 'wplc-init-nonce-' . date('Y-m-d'))){
581
+ $chat_id = sanitize_text_field($_GET['wplc_cid']);
582
+ if( ! filter_var($chat_id, FILTER_VALIDATE_INT) ) {
583
+ /* We need to identify if this CID is a node CID, and if so, return the WP CID */
584
+ $chat_id = wplc_return_chat_id_by_rel($chat_id);
585
+ }
586
+ wplc_gdpr_download_chat('chat_session', $chat_id);
587
+ }
588
+ }
589
+ }
590
+ }
591
+
592
+ /**
593
+ * A simle wrapper for getting the rest URL
594
+ */
595
+ function wplc_gdpr_get_rest_url(){
596
+ if(function_exists('get_rest_url')){
597
+ return get_rest_url() . "wp_live_chat_support/v1/gdpr";
598
+ } else {
599
+ return get_site_url() . "/wp-json/wp_live_chat_support/v1/gdpr";
600
+ }
601
+ }
602
+
603
+ add_action('wplc_api_route_hook', 'wplc_gdpr_rest_end_points');
604
+ /**
605
+ * Adds a special rest end point for processing deleting of chats
606
+ */
607
+ function wplc_gdpr_rest_end_points(){
608
+ register_rest_route('wp_live_chat_support/v1/gdpr','/delete_chat', array(
609
+ 'methods' => 'GET, POST',
610
+ 'callback' => 'wplc_gdpr_rest_delete_chat',
611
+ 'permission_callback' => 'wplc_gdpr_rest_api_nonce_verify'
612
+ ));
613
+ }
614
+
615
+ /**
616
+ * GDPR Rest permission checks
617
+ */
618
+ function wplc_gdpr_rest_api_nonce_verify(){
619
+ // $wplc_rest_access_allowed = wp_verify_nonce( $_REQUEST['wplc_rest_nonce'], 'wplc-gdpr-rest-nonce-' . date('Y-m-d'));
620
+
621
+ $wplc_rest_access_allowed = check_ajax_referer('wp_rest', '_nonce' , false);
622
+ // $wplc_rest_access_allowed = wp_verify_nonce($_REQUEST['wplc_rest_nonce'], 'wplc-gdpr-rest-nonce-' . date('Y-m-d'));
623
+
624
+ return $wplc_rest_access_allowed;
625
+ }
626
+
627
+ /**
628
+ * Handles the deleting of chats via the rest api
629
+ */
630
+ function wplc_gdpr_rest_delete_chat(WP_REST_Request $request ){
631
+ $return_array = array();
632
+ if(isset($request)){
633
+ if(isset($request['wplc_cid'])){
634
+ $chat_id = sanitize_text_field($request['wplc_cid']);
635
+ if( ! filter_var($chat_id, FILTER_VALIDATE_INT) ) {
636
+ /* We need to identify if this CID is a node CID, and if so, return the WP CID */
637
+ $chat_id = wplc_return_chat_id_by_rel($chat_id);
638
+
639
+ }
640
+
641
+ wplc_gdpr_delete_chat('chat_session', $chat_id, false);
642
+
643
+ $return_array['response'] = __('Complete', 'wplivechat');
644
+ $return_array['cid'] = $chat_id;
645
+ }
646
+ }
647
+
648
+ return $return_array;
649
+
650
+ }
651
+
652
+ add_action('admin_notices', 'wplc_gdpr_disabled_warning');
653
+ /**
654
+ * Notice of doom
655
+ */
656
+ function wplc_gdpr_disabled_warning(){
657
+
658
+ if(isset($_GET['wplc_gdpr_dismiss_notice'])){
659
+ update_option('WPLC_GDPR_DISABLED_WARNING_DISMISSED', 'true');
660
+ }
661
+
662
+ if(isset($_GET['page'])){
663
+ if($_GET['page'] === 'wplivechat-menu-settings'){
664
+ $wplc_settings = get_option("WPLC_SETTINGS");
665
+ if(!isset($wplc_settings['wplc_gdpr_enabled']) || $wplc_settings['wplc_gdpr_enabled'] != '1'){
666
+ $gdpr_disabled_warning_dismissed = get_option('WPLC_GDPR_DISABLED_WARNING_DISMISSED', false);
667
+ if($gdpr_disabled_warning_dismissed === false || $gdpr_disabled_warning_dismissed === 'false'){
668
+ $implication_warning = __('GDPR compliance has been disabled, read more about the implications of this here', 'wplivechat');
669
+ $privacy_warning = __('Additionally please take a look at WP Live Chat Support', 'wplivechat');
670
+ $final_warning = __('It is highly recommended that you enable GDPR compliance to ensure your user data is regulated.', 'wplivechat');
671
+
672
+ $output = "<div class='update-nag' style='margin-bottom: 5px; border-color:#DD0000'>";
673
+ $output .= "<strong>" . __("Warning - GDPR Compliance Disabled - Action Required", "wplivechat") . "</strong><br>";
674
+ $output .= "<p>" . $implication_warning . ": <a href='https://www.eugdpr.org/' target='_blank'>" . __('EU GDPR', 'wplivechat') . "</a></p>";
675
+ $output .= "<p>" . $privacy_warning . " <a href='https://wp-livechat.com/privacy-policy/' target='_blank'>" . __('Privacy Policy', 'wplivechat') . "</a></p>";
676
+ $output .= "<p>" . $final_warning . "</p>";
677
+ $output .= "<a class='button' href='?page=wplivechat-menu-settings#tabs-privacy' >" . __("Privacy Settings", "wplivechat") . "</a> ";
678
+ $output .= "<a class='button' href='?page=" . htmlspecialchars($_GET['page']) ."&wplc_gdpr_dismiss_notice=true' style='color: #fff;background-color: #bb0000;border-color: #c70000;'>" . __("Dismiss & Accept Responsibility", "wplivechat") . "</a>";
679
+ $output .= "</div>";
680
+ echo $output;
681
+ }
682
+ }
683
+ }
684
+ }
685
+ }
686
+
687
+
688
+ add_filter( 'admin_footer_text', 'wplc_gdpr_footer_mod', 99, 1);
689
+ /**
690
+ * Adds the data privacy notices
691
+ */
692
+ 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>';
700
+ }
701
+ }
702
+
703
+ return $footer_text;
704
+
705
+ }
706
+
707
+ add_filter( 'wplc_node_server_us_options_enabled', 'wplc_gdpr_allow_us_servers_check',10 ,2);
708
+ /**
709
+ * Checks if GDPR option is enabled so we can force users into the EU
710
+ */
711
+ function wplc_gdpr_allow_us_servers_check($is_allowed, $wplc_settings = false){
712
+ if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
713
+
714
+ if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
715
+ return false;
716
+ }
717
+
718
+ return $is_allowed;
719
+ }
720
+
721
+
722
+ add_filter( 'wplc_node_server_default_selection_override', 'wplc_gdpr_node_server_eu_default_override',10,2);
723
+ /**
724
+ * Checks if GDPR option is enabled so we can force users into the EU
725
+ */
726
+ function wplc_gdpr_node_server_eu_default_override($selected, $wplc_settings = false){
727
+ if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
728
+ if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
729
+ if($selected === 'auto' || $selected === 'us1' || $selected === 'us2'){
730
+ //This is not allowed in the GDPR
731
+ $selected = 'eu1';
732
+ }
733
+ }
734
+
735
+ return $selected;
736
+ }
737
+
738
+
739
+ add_action('wplc_node_server_selection_notices', 'wplc_gdpr_node_server_override_notice',10,1);
740
+ /**
741
+ * Will add a very simple server override if GDPR is enabled
742
+ */
743
+ function wplc_gdpr_node_server_override_notice($wplc_settings = false){
744
+ if($wplc_settings === false){ $wplc_settings = get_option("WPLC_SETTINGS"); }
745
+ if(isset($wplc_settings['wplc_gdpr_enabled']) && $wplc_settings['wplc_gdpr_enabled'] == '1'){
746
+ echo "<small><strong><em>" . __("GDPR Compliance Enabled - Server Selection Limited to EU", "wplivechat") . "</em></strong></small>";
747
+ }
748
+ }
749
+
750
+ add_filter('wplc_update_settings_between_versions_hook', 'wplc_gdpr_update_settings_between_versions',10,1);
751
+ /**
752
+ * This will handle the auto update magic. Although we have a default in place this is far superior as it is a hard data set
753
+ */
754
+ function wplc_gdpr_update_settings_between_versions($wplc_settings){
755
+ if(is_array($wplc_settings)){
756
+ $gdpr_enabled_atleast_once_before = get_option('WPLC_GDPR_ENABLED_AT_LEAST_ONCE', false);
757
+ if($gdpr_enabled_atleast_once_before === false){
758
+ //Only fire if this user has never had GDPR enabled before
759
+ update_option('WPLC_GDPR_ENABLED_AT_LEAST_ONCE', 'true');
760
+ $wplc_settings['wplc_gdpr_enabled'] = '0';
761
+ }
762
+ }
763
+
764
+ return $wplc_settings;
765
  }
modules/node_server.php CHANGED
@@ -1,1234 +1,1234 @@
1
- <?php
2
- /*
3
- * Node Code -> Insert pun here
4
- */
5
-
6
- define("BLEEPER_API_URL", "https://bleeper.io/app/api/v1/");
7
- define("BLEEPER_REMOTE_DASH_ROUTE", "remote_dashboard.php");
8
-
9
- define("BLEEPER_NODE_SERVER_URL", "https://bleeper.us-3.evennode.com");
10
-
11
- //define("BLEEPER_NODE_SERVER_URL", "http://localhost:3000");
12
- define("BLEEPER_NODE_END_POINTS_ROUTE", "api/v1/");
13
- define("BLEEPER_NODE_END_POINT_TOKEN", "zf6fe1399sdfgsdfg02ad09ab6a8cb7345s");
14
-
15
-
16
- add_action("wplc_activate_hook", "wplc_node_server_token_check", 10);
17
- add_action("wplc_update_hook", "wplc_node_server_token_check", 10);
18
- /**
19
- * Checks if a secret key has been created.
20
- * If not create one for use in the API
21
- *
22
- * @return void
23
- */
24
- function wplc_node_server_token_check(){
25
- if (!get_option("wplc_node_server_secret_token")) {
26
- $user_token = wplc_node_server_token_create();
27
- add_option("wplc_node_server_secret_token", $user_token);
28
- }
29
- }
30
-
31
- add_action("wplc_admin_remote_dashboard_below", "wplc_admin_remote_dashboard_thank_you_footer");
32
- /*
33
- * Adds a simple thank you message to the footer of the dashboard
34
- */
35
- function wplc_admin_remote_dashboard_thank_you_footer(){
36
- echo "<p id='wplc_footer_message' style='display:none;'>";
37
- echo __("Thank you for using WP Live Chat Support - Need assistance? Please get in touch here: ", "wplivechat");
38
- echo "<a href='https://wp-livechat.com/contact-us/' rel='nofollow' target='_blank'>" . __("Contact us", "wplivechat") . "</a><span class='bleeper_stats'></span><span class='bleeper_instance'></span>";
39
- echo "</p>";
40
- }
41
-
42
- /**
43
- * Generates a new Secret Token
44
- *
45
- * @return string
46
- */
47
- function wplc_node_server_token_create(){
48
- $the_code = rand(0, 1000) . rand(0, 1000) . rand(0, 1000) . rand(0, 1000) . rand(0, 1000);
49
- $the_time = time();
50
- $token = md5($the_code . $the_time);
51
- return $token;
52
- }
53
-
54
- /**
55
- * Re-Generates the token
56
- * @return void
57
- */
58
- function wplc_node_server_token_regenerate(){
59
- $wplc_node_token_new = wplc_node_server_token_create();
60
- update_option("wplc_node_server_secret_token", $wplc_node_token_new);
61
- }
62
-
63
- /**
64
- * Post to the NODE server -
65
- *
66
- * @param string $route Route you would like to use for the node server
67
- * @param string $form_data data to send
68
- * @return string (or false on fail)
69
- */
70
- function wplc_node_server_post($route, $form_data){
71
- $url = BLEEPER_NODE_SERVER_URL . BLEEPER_NODE_END_POINTS_ROUTE . $route;
72
-
73
- $wplc_end_point_override = get_option("wplc_end_point_override");
74
- if($wplc_end_point_override !== false && $wplc_end_point_override !== ""){
75
- $url = $wplc_end_point_override . BLEEPER_NODE_END_POINTS_ROUTE . $route; //Use the override URL
76
- }
77
-
78
-
79
- if(!isset($form_data['token'])){
80
- $form_data['token'] = BLEEPER_NODE_END_POINT_TOKEN; //Add the security token
81
- }
82
-
83
- if(!isset($form_data['api_key'])){
84
- $wplc_node_token = get_option("wplc_node_server_secret_token");
85
- if(!$wplc_node_token){
86
- if(function_exists("wplc_node_server_token_regenerate")){
87
- wplc_node_server_token_regenerate();
88
- $wplc_node_token = get_option("wplc_node_server_secret_token");
89
- }
90
- }
91
-
92
- $form_data['api_key'] = $wplc_node_token; //Add the security token
93
- }
94
-
95
- if(!isset($form_data['origin_url'])){
96
- $ajax_url = admin_url('admin-ajax.php');
97
- $origin_url = str_replace("/wp-admin/admin-ajax.php", "", $ajax_url);
98
- $form_data['origin_url'] = $origin_url; //Add the security token
99
- }
100
-
101
- $context = @stream_context_create($options);
102
- $result = @file_get_contents($url . "?" . http_build_query($form_data), false, $context);
103
-
104
- if ($result === FALSE) {
105
- return false;
106
- } else {
107
- return $result;
108
- }
109
- }
110
-
111
- add_action("wplc_hook_chat_notification","wplc_filter_notification_hook_node",20,3);
112
- /**
113
- * Send a system notification to the node server
114
- *
115
- * @return void
116
- */
117
- function wplc_filter_notification_hook_node($type,$cid,$data){
118
- $wplc_settings = get_option("WPLC_SETTINGS");
119
- if(isset($wplc_settings['wplc_use_node_server']) && intval($wplc_settings['wplc_use_node_server']) == 1) {
120
-
121
- if(filter_var($cid, FILTER_VALIDATE_INT) ) {
122
- //Let's reverse the CID back to it's rel counterpart
123
- $cid = wplc_return_chat_rel_by_id($cid);
124
- }
125
-
126
- $msg = false;
127
- switch($type){
128
- case "doc_suggestion":
129
- $msg = $data['formatted_msg'];
130
- break;
131
- default:
132
- break;
133
- }
134
-
135
- if(isset($cid)){
136
- if($msg !== false){
137
- $form_data = array(
138
- 'chat_id' => $cid,
139
- 'notification_text' => $msg,
140
- );
141
-
142
- $user_request = wplc_node_server_post("user_chat_notification", $form_data);
143
-
144
- if($user_request === false){
145
- //Something is wrong
146
- } else {
147
-
148
- }
149
- }
150
- }
151
- }
152
-
153
- return;
154
- }
155
-
156
- add_action("wplc_api_route_hook", "wplc_api_node_routes");
157
- /**
158
- * Add a REST API routes for the node server
159
- *
160
- * @return void
161
- */
162
- function wplc_api_node_routes(){
163
- register_rest_route('wp_live_chat_support/v1','/async_storage', array(
164
- 'methods' => 'POST',
165
- 'callback' => 'wplc_node_async_storage_rest'
166
- ));
167
- }
168
-
169
- /**
170
- * Handles Async storage REST -> Params are processed within the request
171
- * Required POST variables:
172
- * - Chat ID
173
- * - Security Key
174
- * - Message (JSON encoded array)
175
- * - Action
176
- *
177
- * @param WP_REST_Request $request Request Data
178
- * @return void
179
- */
180
- function wplc_node_async_storage_rest(WP_REST_Request $request){
181
- $return_array = array();
182
- $return_array['request_status'] = false; //Default to be returned if something goes wrong
183
- if(isset($request)){
184
- if(isset($request['security'])){
185
- $stored_token = get_option("wplc_node_server_secret_token");
186
- $check = $_POST['server_token'] == $stored_token ? true : false;
187
- if ($check) {
188
- if(isset($request['chat_id'])){
189
- if(isset($request['messages'])){
190
- if(isset($request['relay_action'])){
191
- $chat_id = sanitize_text_field($request['chat_id']);
192
- $message_data = json_decode($request['messages']);
193
- $chat_session = wplc_return_chat_session_variable($chat_id);
194
- $action = $request['relay_action'];
195
- if($message_data !== NULL){
196
- if($action == "wplc_user_send_msg"){
197
- foreach ($message_data as $message) {
198
- $message = sanitize_text_field($message);
199
- wplc_record_chat_msg("1", $chat_id, $message);
200
-
201
- //wplc_update_user_on_page($chat_id, "3", $chat_session); //Keep timestamp active
202
- wplc_update_active_timestamp($chat_id);
203
- }
204
-
205
- $return_array['request_status'] = true;
206
- $return_array['request_information'] = __("Success", "wplivechat");
207
- } else if ($action == "wplc_admin_send_msg"){
208
- foreach ($message_data as $message) {
209
- $message = sanitize_text_field($message);
210
- wplc_record_chat_msg("2", $chat_id, $message, true);
211
-
212
- //wplc_update_user_on_page($chat_id, "3", $chat_session); //Keep timestamp active
213
- wplc_update_active_timestamp($chat_id);
214
- }
215
-
216
- $return_array['request_status'] = true;
217
- $return_array['request_information'] = __("Success", "wplivechat");
218
- }
219
- } else {
220
- $return_array['request_information'] = __("Message data is corrupt", "wplivechat");
221
- }
222
- } else {
223
- $return_array['request_information'] = __("Action not set", "wplivechat");
224
- }
225
- } else {
226
- $return_array['request_information'] = __("Message data array not set", "wplivechat");
227
- }
228
- } else {
229
- $return_array['request_information'] = __("Chat ID is not set", "wplivechat");
230
- }
231
- }
232
- } else {
233
- $return_array['request_information'] = __("No security nonce found", "wplivechat");
234
- }
235
- }
236
-
237
- return $return_array;
238
-
239
- }
240
-
241
- add_action("wp_ajax_wplc_node_async_storage_ajax", "wplc_node_async_storage_ajax");
242
- add_action("wp_ajax_nopriv_wplc_node_async_storage_ajax", "wplc_node_async_storage_ajax");
243
- /**
244
- * Handles Async storage AJAX (Fallback for if REST is not present) -> Params are processed within the request
245
- * Required POST variables:
246
- * - Chat ID
247
- * - Security Key
248
- * - Message (JSON encoded array)
249
- * - Action
250
- *
251
- * @return void
252
- */
253
- function wplc_node_async_storage_ajax(){
254
- $return_array = array();
255
- $return_array['request_status'] = false; //Default to be returned if something goes wrong
256
- if(isset($_POST)){
257
- if(isset($_POST['server_token'])){
258
- $stored_token = get_option("wplc_node_server_secret_token");
259
- $check = $_POST['server_token'] == $stored_token ? true : false;
260
- if ($check) {
261
- if(isset($_POST['chat_id'])){
262
- if(isset($_POST['messages'])){
263
- if(isset($_POST['relay_action'])){
264
- $chat_id = sanitize_text_field($_POST['chat_id']);
265
- $message_data = json_decode($_POST['messages']);
266
- $chat_session = wplc_return_chat_session_variable($chat_id);
267
- $action = $_POST['relay_action'];
268
- if($message_data !== NULL){
269
- if($action == "wplc_user_send_msg"){
270
- foreach ($message_data as $message) {
271
- $message = sanitize_text_field($message);
272
- wplc_record_chat_msg("1", $chat_id, $message);
273
- //wplc_update_user_on_page($chat_id, "3", $chat_session); //Keep timestamp active
274
- wplc_update_active_timestamp($chat_id);
275
-
276
- }
277
-
278
- $return_array['request_status'] = true;
279
- $return_array['request_information'] = __("Success", "wplivechat");
280
- } else if ($action == "wplc_admin_send_msg"){
281
- foreach ($message_data as $message) {
282
- $message = sanitize_text_field($message);
283
- wplc_record_chat_msg("2", $chat_id, $message);
284
- //wplc_update_user_on_page($chat_id, "3", $chat_session); //Keep timestamp active
285
- wplc_update_active_timestamp($chat_id);
286
- }
287
-
288
- $return_array['request_status'] = true;
289
- $return_array['request_information'] = __("Success", "wplivechat");
290
- }
291
- } else {
292
- $return_array['request_information'] = __("Message data is corrupt", "wplivechat");
293
- }
294
- } else {
295
- $return_array['request_information'] = __("Action not set", "wplivechat");
296
- }
297
- } else {
298
- $return_array['request_information'] = __("Message data array not set", "wplivechat");
299
- }
300
- } else {
301
- $return_array['request_information'] = __("Chat ID is not set", "wplivechat");
302
- }
303
- }
304
- } else {
305
- $return_array['request_information'] = __("No security nonce found", "wplivechat");
306
- }
307
- }
308
-
309
- return $return_array;
310
-
311
- }
312
-
313
- /**
314
- * Loads remote dashboard
315
- *
316
- * @return void
317
- */
318
- function wplc_admin_dashboard_layout_node( $location = 'dashboard' ){
319
- if ( $location === 'dashboard') {
320
-
321
- if( ! get_user_meta( get_current_user_id(), 'wplc_ma_agent', true ) ){
322
- echo "<div class='error below-h1'>";
323
- echo "<h2>".__("Error", "wplivechat")."</h2>";
324
- echo "<p>".__("Only chat agents can access this page.", "wplivechat")."</p>";
325
- echo "</div>";
326
- return;
327
- }
328
-
329
- do_action("wplc_admin_remote_dashboard_above");
330
-
331
- echo "<div id='bleeper_content_wrapper'></div>";
332
-
333
- if ( ! isset( $_GET['action'] ) || 'history' !== $_GET['action'] ) {
334
-
335
- echo "<div class='wplc_remote_dash_below_contianer'>";
336
- do_action("wplc_admin_remote_dashboard_below");
337
- echo "</div>";
338
-
339
- }
340
- } else {
341
- do_action("wplc_admin_remote_dashboard_above");
342
-
343
- echo "<div id='bleeper_content_wrapper'></div>";
344
-
345
- if ( ! empty( $_GET['page'] ) && 'wplivechat-menu' === $_GET['page'] ) { // This div is also hidden by js under the same conditions
346
-
347
- echo "<div class='wplc_remote_dash_below_contianer'>";
348
- do_action("wplc_admin_remote_dashboard_below");
349
- echo "</div>";
350
-
351
- }
352
- }
353
- }
354
-
355
- add_action("wplc_admin_remote_dashboard_below", "wplc_admin_remote_dashboard_below_delegate");
356
- /*
357
- * Delegates the below dashboard hooks
358
- */
359
- function wplc_admin_remote_dashboard_below_delegate(){
360
- do_action("wplc_hook_chat_dashboard_bottom");
361
- }
362
-
363
- add_action("wplc_hook_chat_dashboard_bottom","wplc_hook_control_dashboard_bottom_loading_logo",1);
364
- /**
365
- * Decides whether or not to show the available extensions for this area.
366
- * @return void
367
- * @since 6.0.00
368
- * @author Nick Duncan <nick@codecabin.co.za>
369
- */
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
-
377
- add_action('admin_enqueue_scripts', 'wplc_enqueue_dashboard_popup_scripts');
378
- /**
379
- * Enqueues the scripts for the admin dashboard popup icon and chat box
380
- * @return void
381
- */
382
- function wplc_enqueue_dashboard_popup_scripts() {
383
- global $wplc_version;
384
- wp_enqueue_script('jquery-ui-draggable');
385
- wp_enqueue_script('wplc-admin-popup', plugins_url('../js/wplc_admin_popup.js', __FILE__ ), array('jquery-ui-draggable'), $wplc_version);
386
-
387
- wp_button_pointers_load_scripts('toplevel_page_wplivechat-menu');
388
- }
389
-
390
- add_action( "admin_footer", "wplc_dashboard_display_decide" );
391
- /**
392
- * Decide whether or not to display the dashboard layout on an admin page
393
- * @return void
394
- */
395
- function wplc_dashboard_display_decide() {
396
- $wplc_settings = get_option("WPLC_SETTINGS");
397
- if ( isset( $wplc_settings['wplc_use_node_server'] ) && $wplc_settings['wplc_use_node_server'] == 1 ) {
398
- //Node in use, load remote dashboard
399
- if ( isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu') {
400
- // we control this in the wplc_admin_menu_layout function
401
- //wplc_admin_dashboard_layout_node('dashboard');
402
- } else {
403
- if (function_exists("wplc_pro_version_control")) {
404
- global $wplc_pro_version;
405
- $wplc_ver = str_replace('.', '', $wplc_pro_version);
406
- $checker = intval($wplc_ver);
407
- if (function_exists("wplc_pro_version_control") && $checker < 8000) {
408
- /* ONLY SHOW THE POPOUT DASHBOARD IF THEY ARE USING PRO 8.0.00 and above */
409
- return;
410
- }
411
- }
412
-
413
-
414
- /**
415
- * Check to see if we have enabled "Enable chat dashboard and notifications on all admin pages"
416
- */
417
-
418
- if ( isset( $wplc_settings['wplc_enable_all_admin_pages'] ) && $wplc_settings['wplc_enable_all_admin_pages'] === '1' ) {
419
-
420
-
421
- wplc_admin_dashboard_layout_node('other');
422
-
423
- echo '<div class="floating-right-toolbar">';
424
- echo '<label for="user_list_bleeper_control" style="margin-bottom: 0; display:none;"></label>';
425
-
426
- echo '<i id="toolbar-item-open-bleeper" class="fa fa-fw" style="background:url(\''.plugins_url('../images/48px.png', __FILE__).'\') no-repeat; background-size: cover;"></i>';
427
- echo '</div>';
428
- }
429
-
430
- }
431
- }
432
-
433
-
434
-
435
- }
436
-
437
-
438
- /**
439
- * Loads remote dashboard scripts and styles
440
- *
441
- * @return void
442
- */
443
- function wplc_admin_remote_dashboard_scripts($wplc_settings){
444
- global $wplc_version;
445
- $wplc_current_user = get_current_user_id();
446
- if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true )) {
447
-
448
- $user_info = get_userdata(intval($wplc_current_user));
449
-
450
- $user_array = get_users(array(
451
- 'meta_key' => 'wplc_ma_agent',
452
- ));
453
-
454
- $a_array = array();
455
- if ($user_array) {
456
- foreach ($user_array as $user) {
457
- $current_user_name = apply_filters("wplc_agent_display_name_filter", $user->display_name);
458
- $a_array[$user->ID] = array();
459
- $a_array[$user->ID]['name'] = $user->display_name;
460
- $a_array[$user->ID]['display_name'] = $user->display_name;
461
- $a_array[$user->ID]['md5'] = md5( $user->user_email );
462
- $a_array[$user->ID]['email'] = md5( $user->user_email );
463
- }
464
- }
465
-
466
-
467
- if( isset($wplc_settings['wplc_show_name']) && $wplc_settings['wplc_show_name'] == '1' ){ $wplc_show_name = true; } else { $wplc_show_name = false; }
468
- if( isset($wplc_settings['wplc_show_avatar']) && $wplc_settings['wplc_show_avatar'] ){ $wplc_show_avatar = true; } else { $wplc_show_avatar = false; }
469
- if( isset($wplc_settings['wplc_show_date']) && $wplc_settings['wplc_show_date'] == '1' ){ $wplc_show_date = true; } else { $wplc_show_date = false; }
470
- if( isset($wplc_settings['wplc_show_time']) && $wplc_settings['wplc_show_time'] == '1' ){ $wplc_show_time = true; } else { $wplc_show_time = false; }
471
-
472
- $wplc_chat_detail = array( 'name' => $wplc_show_name, 'avatar' => $wplc_show_avatar, 'date' => $wplc_show_date, 'time' => $wplc_show_time );
473
-
474
-
475
-
476
-
477
- $wplc_end_point_override = get_option("wplc_end_point_override");
478
- if($wplc_end_point_override !== false && $wplc_end_point_override !== ""){
479
- $bleeper_url = $wplc_end_point_override; //Use the override URL
480
- } else {
481
- $bleeper_url = BLEEPER_NODE_SERVER_URL;
482
- }
483
-
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
-
505
- wp_register_script('md5', plugins_url( '../js/md5.js', __FILE__ ), array("wplc-admin-js-sockets"), false, false);
506
- wp_enqueue_script('md5');
507
-
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
-
515
- if (isset($wplc_settings['wplc_enable_msg_sound'])) {
516
-
517
- if (intval($wplc_settings['wplc_enable_msg_sound']) == 1) {
518
- wp_localize_script('wplc-admin-js-agent', "bleeper_ping_sound_notification_enabled", "true");
519
- } else {
520
- wp_localize_script('wplc-admin-js-agent', "bleeper_ping_sound_notification_enabled", "false");
521
- }
522
-
523
- }
524
-
525
- wp_register_script('my-wplc-admin-chatbox-ui-events', plugins_url('../js/wplc_u_admin_chatbox_ui_events.js', __FILE__), array('jquery'), $wplc_version, true);
526
- wp_enqueue_script('my-wplc-admin-chatbox-ui-events');
527
-
528
-
529
-
530
- $wplc_et_ajax_nonce = wp_create_nonce( "wplc_et_nonce" );
531
- wp_register_script( 'wplc_transcript_admin', plugins_url( '../js/wplc_transcript.js', __FILE__ ), null, '', true );
532
- $wplc_transcript_localizations = array(
533
- 'ajax_nonce' => $wplc_et_ajax_nonce,
534
- 'string_loading' => __( "Sending transcript...", "wplivechat" ),
535
- 'string_title' => __( "Sending Transcript", "wplivechat" ),
536
- 'string_close' => __( "Close", "wplivechat" ),
537
- 'string_chat_emailed' => __( "The chat transcript has been emailed.", "wplivechat" ),
538
- 'string_error1' => sprintf( __( "There was a problem emailing the chat. Please <a target='_BLANK' href='%s'>contact support</a>.", "wplivechat" ), "http://wp-livechat.com/contact-us/?utm_source=plugin&utm_medium=link&utm_campaign=error_emailing_chat" )
539
- );
540
- wp_localize_script( 'wplc_transcript_admin', 'wplc_transcript_nonce', $wplc_transcript_localizations );
541
- wp_enqueue_script( 'wplc_transcript_admin' );
542
-
543
- $wplc_node_token = get_option("wplc_node_server_secret_token");
544
- if(!$wplc_node_token){
545
- if(function_exists("wplc_node_server_token_regenerate")){
546
- wplc_node_server_token_regenerate();
547
- $wplc_node_token = get_option("wplc_node_server_secret_token");
548
- }
549
- }
550
-
551
- $form_data = array("node_token" => $wplc_node_token, "action" => "wordpress");
552
- $form_data = apply_filters("wplc_admin_dashboard_layout_node_request_variable_filter", $form_data); //Filter for pro to add a few request variables to the mix for additional structure
553
-
554
- /*$options = array(
555
- 'http' => array(
556
- 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
557
- 'method' => 'POST',
558
- 'content' => http_build_query($form_data)
559
- )
560
- );
561
- $context = @stream_context_create($options);
562
- $result = @file_get_contents(BLEEPER_API_URL . BLEEPER_REMOTE_DASH_ROUTE, false, $context);*/
563
-
564
- wp_localize_script('wplc-admin-js-agent', 'bleeper_remote_form_data_array', $form_data);
565
- wp_localize_script('wplc-admin-js-agent', 'bleeper_remote_form_api_url', BLEEPER_API_URL);
566
- wp_localize_script('wplc-admin-js-agent', 'bleeper_remote_form_route', BLEEPER_REMOTE_DASH_ROUTE);
567
-
568
-
569
- if ( isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu' ) {
570
- wp_localize_script('wplc-admin-js-agent', 'bleeper_in_dashboard', '1');
571
- } else {
572
- wp_localize_script('wplc-admin-js-agent', 'bleeper_in_dashboard', '0');
573
- }
574
-
575
- $inline_error_message = "<div class='error below-h1' style='display:none;' id='bleeper_inline_connection_error'>
576
- <p>" . __("Connection Error", "wplivechat") . "<br /></p>
577
- <p>" . __("We are having some trouble contacting the server. Please try again later.", "wplivechat") . "</p>
578
- </div>";
579
- wp_localize_script('wplc-admin-js-agent', 'bleeper_remote_form_error', $inline_error_message);
580
-
581
-
582
-
583
-
584
-
585
- if (isset($wplc_settings['wplc_enable_visitor_sound']) && intval($wplc_settings['wplc_enable_visitor_sound']) == 1) {
586
- wp_localize_script('wplc-admin-js-agent', 'bleeper_enable_visitor_sound', '1');
587
- } else {
588
- wp_localize_script('wplc-admin-js-agent', 'bleeper_enable_visitor_sound', '0');
589
- }
590
-
591
-
592
-
593
-
594
- $agent_display_name = $user_info->display_name;
595
-
596
- wp_localize_script('wplc-admin-js-agent', 'agent_id', "" . $wplc_current_user);
597
- wp_localize_script('wplc-admin-js-agent', 'bleeper_agent_name', apply_filters("wplc_agent_display_name_filter", $agent_display_name) );
598
- wp_localize_script('wplc-admin-js-agent', 'nifty_api_key', get_option("wplc_node_server_secret_token"));
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");
608
- wp_localize_script('wplc-admin-js-agent', 'bleeper_disable_add_message', "true");
609
- wp_localize_script('wplc-admin-js-agent', 'wplc_nonce', wp_create_nonce("wplc"));
610
- wp_localize_script('wplc-admin-js-agent', 'wplc_cid', "null");
611
- wp_localize_script('wplc-admin-js-agent', 'wplc_chat_name', "null");
612
- //wp_localize_script('wplc-admin-js-agent', 'wplc_chat_email', "null"); //TODO: Parse the email
613
-
614
- wp_localize_script( 'wplc-admin-js-agent', 'wplc_show_chat_detail', $wplc_chat_detail );
615
-
616
- wp_localize_script('wplc-admin-js-agent', 'wplc_agent_data', $a_array);
617
- wp_localize_script('wplc-admin-js-agent', 'all_agents', $a_array);
618
-
619
- wp_localize_script('wplc-admin-js-agent', 'wplc_url', plugins_url( '', dirname( __FILE__ ) ) );
620
-
621
- if( isset($wplc_settings['wplc_settings_enabled']) && intval($wplc_settings["wplc_settings_enabled"]) == 2) {
622
-
623
- $wplc_disabled_html = __("Chat is disabled in settings area, re-enable", "wplivechat");
624
- $wplc_disabled_html .= " <a href='?page=wplivechat-menu-settings'>" . __("here", "wplivechat") . "</a>";
625
-
626
- wp_localize_script('wplc-admin-js-agent', 'wplc_disabled', 'true');
627
- wp_localize_script('wplc-admin-js-agent', 'wplc_disabled_html', $wplc_disabled_html);
628
- }
629
-
630
-
631
- //Added rest nonces
632
- if(class_exists("WP_REST_Request")) {
633
- wp_localize_script('wplc-admin-js-agent', 'wplc_restapi_enabled', '1');
634
- wp_localize_script('wplc-admin-js-agent', 'wplc_restapi_token', get_option('wplc_api_secret_token'));
635
- wp_localize_script('wplc-admin-js-agent', 'wplc_restapi_endpoint', rest_url('wp_live_chat_support/v1'));
636
- wp_localize_script('wplc-admin-js-agent', 'bleeper_override_upload_url', rest_url('wp_live_chat_support/v1/remote_upload'));
637
- wp_localize_script('wplc-admin-js-agent', 'wplc_restapi_nonce', wp_create_nonce( 'wp_rest' ));
638
-
639
- } else {
640
- wp_localize_script('wplc-admin-js-agent', 'wplc_restapi_enabled', '0');
641
- wp_localize_script('wplc-admin-js-agent', 'wplc_restapi_nonce', "false");
642
- }
643
-
644
- $agent_tagline = apply_filters( "wplc_filter_simple_agent_data_agent_tagline", '', get_current_user_id() );
645
- $agent_bio = apply_filters( "wplc_filter_simple_agent_data_agent_bio", '', '', get_current_user_id() );
646
- $social_links = apply_filters( "wplc_filter_simple_agent_data_social_links", '', get_current_user_id() );
647
- $head_data = array(
648
- 'tagline' => $agent_tagline,
649
- 'bio' => $agent_bio,
650
- 'social' => $social_links
651
- );
652
- wp_localize_script( 'wplc-admin-js-agent', 'wplc_head_data', $head_data );
653
- wp_localize_script( 'wplc-admin-js-agent', 'wplc_user_chat_notification_prefix', __("User received notification:", "wplivechat") );
654
-
655
- wp_localize_script( 'wplc-admin-js-agent', 'bleeper_valid_direct_to_page_array', wplc_node_pages_posts_array() );
656
-
657
- if( isset($wplc_settings['wplc_new_chat_ringer_count']) && $wplc_settings['wplc_new_chat_ringer_count'] !== "") {
658
- $wplc_ringer_count = intval($wplc_settings['wplc_new_chat_ringer_count']);
659
- wp_localize_script( 'wplc-admin-js-agent', 'bleeper_ringer_count', "" . $wplc_ringer_count );
660
- }
661
-
662
-
663
- $wplc_server_location = get_option( "wplc_server_location" );
664
- $wplc_server_location = apply_filters('wplc_node_server_default_selection_override', $wplc_server_location, $wplc_settings);
665
-
666
- if( $wplc_server_location !== false && $wplc_server_location !== "" && $wplc_server_location !== "auto" ){
667
- if ( $wplc_server_location === "us1") { $wplc_server_location = "0"; }
668
- else if ( $wplc_server_location === "us2") { $wplc_server_location = "3"; }
669
- else if ( $wplc_server_location === "eu1") { $wplc_server_location = "1"; }
670
- else if ( $wplc_server_location === "eu2") { $wplc_server_location = "2"; }
671
- else { $wplc_server_location = "0"; }
672
- wp_localize_script( 'wplc-admin-js-agent', 'bleeper_server_location', $wplc_server_location );
673
- }
674
-
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') );
682
- wp_localize_script( 'wplc-admin-js-agent', 'bleeper_new_chat_notification_text', __("A new chat has been received. Please go the 'Live Chat' page to accept the chat", "wplivechat") );
683
-
684
- $wplc_notification_icon = plugin_dir_url(dirname(__FILE__)) . 'images/wplc_notification_icon.png';
685
- wp_localize_script( 'wplc-admin-js-agent', 'bleeper_new_chat_notification_icon', $wplc_notification_icon );
686
-
687
- do_action("wplc_admin_remoter_dashboard_scripts_localizer"); //For pro localization of agents list, and departments
688
-
689
- wp_enqueue_script('wplc-admin-js-agent');
690
-
691
- wp_register_script('wplc-admin-chat-server', plugins_url( '../js/wplc_server.js', __FILE__ ), array("wplc-admin-js-agent", "wplc-admin-js-sockets"), $wplc_version, false); //Added this for async storage calls
692
- wp_enqueue_script('wplc-admin-chat-server');
693
-
694
- wp_localize_script( 'wplc-admin-chat-server', 'wplc_datetime_format', array(
695
- 'date_format' => get_option( 'date_format' ),
696
- 'time_format' => get_option( 'time_format' ),
697
- ) );
698
-
699
- wp_register_script('wplc-admin-chat-events', plugins_url( '../js/wplc_u_admin_events.js', __FILE__ ), array("wplc-admin-js-agent", "wplc-admin-js-sockets", "wplc-admin-chat-server"), $wplc_version, false); //Added this for async storage calls
700
- wp_enqueue_script('wplc-admin-chat-events');
701
-
702
- if (isset($wplc_settings['wplc_show_date']) && $wplc_settings["wplc_show_date"] == '1') {
703
- wp_localize_script('wplc-admin-chat-server', 'wplc_show_date', 'true');
704
- } else {
705
- wp_localize_script('wplc-admin-chat-server', 'wplc_show_date', 'false');
706
- }
707
-
708
- if (isset($wplc_settings['wplc_show_time']) && $wplc_settings["wplc_show_time"] == '1') {
709
- wp_localize_script('wplc-admin-chat-server', 'wplc_show_time', 'true');
710
- } else {
711
- wp_localize_script('wplc-admin-chat-server', 'wplc_show_time', 'false');
712
- }
713
-
714
- if (isset($wplc_settings['wplc_show_name']) && $wplc_settings["wplc_show_name"] == '1') {
715
- wp_localize_script('wplc-admin-chat-server', 'wplc_show_name', 'true');
716
- } else {
717
- wp_localize_script('wplc-admin-chat-server', 'wplc_show_name', 'false');
718
- }
719
-
720
- if (isset($wplc_settings['wplc_show_avatar']) && $wplc_settings["wplc_show_avatar"] == '1') {
721
- wp_localize_script('wplc-admin-chat-server', 'wplc_show_avatar', 'true');
722
- } else {
723
- wp_localize_script('wplc-admin-chat-server', 'wplc_show_avatar', 'false');
724
- }
725
- }
726
- }
727
-
728
- add_action("wplc_admin_remoter_dashboard_scripts_localizer", "wplc_admin_remote_dashboard_localize_upselling_tips");
729
- /*
730
- * Localizes an array of upselling tips
731
- */
732
- function wplc_admin_remote_dashboard_localize_upselling_tips(){
733
- $tips_header = __("Did you know?", "wplivechat");
734
-
735
- $tips_array = array(
736
- "0" => "<p><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=unlimited_agents_tip' title='".__("Add unlimited agents", "wplivechat")."' target=\"_BLANK\">".__("Add unlimited agents", "wplivechat")."</a> ".__(" with the Pro add-on of WP Live Chat Support","wplivechat")." "."<a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=unlimited_agents_tip2' target='_BLANK'>".__("(once off payment).","wplivechat")."</a></p>",
737
- "1" => "<p>".__("With the Pro add-on of WP Live Chat Support, you can", "wplivechat")." <a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate_tip' title='".__("see who's online and initiate chats", "wplivechat")."' target=\"_BLANK\">".__("initiate chats", "wplivechat")."</a> ".__("with your online visitors with the click of a button.", "wplivechat")." <br /><br /><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate_tip2' title='".__("Buy the Pro add-on now (once off payment).", "wplivechat")."' target=\"_BLANK\"><strong>".__("Buy the Pro add-on now (once off payment).", "wplivechat")."</strong></a></p>",
738
- "2" => "<p><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=transfer_tip' title='".__("Transfer Chats", "wplivechat")."' target=\"_BLANK\">".__("Transfer Chats", "wplivechat")."</a> ".__(" with the Pro add-on of WP Live Chat Support","wplivechat")." "."<a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=transfer_tip2' target='_BLANK'>".__("(once off payment).","wplivechat")."</a></p>"
739
- );
740
-
741
- $tips_array = apply_filters("wplc_admin_remote_dashboard_localize_tips_array", $tips_array);
742
-
743
- wp_localize_script( 'wplc-admin-js-agent', 'agent_to_agent_chat_upsell', sprintf(__('Chat to other agents with the <a href="%s" target="_BLANK">Pro version</a>.' ,'wplivechat'),'https://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=a2achat'));
744
-
745
- $initiate_upsell = "<i class='fa fa-horn'></i> ".__("With the Pro add-on of WP Live Chat Support, you can", "wplivechat");
746
- $initiate_upsell .= ' <a href="https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate1" title="'.__("see who's online and initiate chats", "wplivechat").'" target=\"_BLANK\">';
747
- $initiate_upsell .= __("initiate chats", "wplivechat");
748
- $initiate_upsell .= '</a> '.__("with your online visitors with the click of a button.", "wplivechat");
749
- $initiate_upsell .= ' <a href="https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate2" title="'.__("Buy the Pro add-on now.", "wplivechat").'" target=\"_BLANK\">';
750
- $initiate_upsell .= '<strong>'.__("Buy the Pro add-on now.", "wplivechat").'</strong></a>';
751
-
752
-
753
-
754
- wp_localize_script( 'wplc-admin-js-agent', 'initiate_chat_upsell', $initiate_upsell);
755
-
756
-
757
- wp_localize_script( 'wplc-admin-js-agent', 'wplc_event_upsell', sprintf( __( 'Get detailed visitor events with the <a target="_BLANK" href="%s">Pro version</a>.', 'wplivechat'), 'https://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=pro_events' ) );
758
-
759
- wp_localize_script( 'wplc-admin-js-agent', 'wplc_tip_header', $tips_header );
760
- wp_localize_script( 'wplc-admin-js-agent', 'wplc_tip_array', $tips_array );
761
-
762
- if (!function_exists("wplc_pro_activate")) {
763
- /* identify if the user wants to display the agent to agent chat upsell */
764
- $wplc_current_user = get_current_user_id();
765
- $check = get_user_meta( $wplc_current_user, "wplc_a2a_upsell" );
766
- if ($check) {
767
- wp_localize_script( 'wplc-admin-js-agent', 'wplc_upsell_a2a', '1' );
768
- }
769
-
770
- }
771
-
772
-
773
- }
774
-
775
- /**
776
- * Loads remote dashboard styles
777
- *
778
- * @return void
779
- */
780
- function wplc_admin_remote_dashboard_styles(){
781
- global $wplc_version;
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) ) {
789
- wp_add_inline_style( 'wplc-admin-style', ".wplc-user-message, .wplc-admin-message { padding-left: 0 !important; }" );
790
-
791
- /*
792
- if(!isset($wplc_settings['wplc_show_name']) || (isset($wplc_settings['wplc_show_name']) && intval($wplc_settings['wplc_show_name']) == 0) ){
793
- //User is hiding both name and grav - add more inline styles
794
-
795
- $current_agent_info = wp_get_current_user();
796
- $current_agent_initial = "A"; //Default
797
-
798
- if(isset($current_agent_info->display_name)){
799
- $current_agent_initial = substr($current_agent_info->display_name, 0, 1);
800
- }
801
-
802
-
803
- $inline_identity_css =
804
- "
805
- .wplc-admin-message .messageBody::before {
806
- display:inline-block; width: 15px; height: 15px; background:#333; content:'" . $current_agent_initial . "'; color:#fff; margin-right:10px; position:relative; top:px; text-align:center; font-size: 10px; border-radius:3px;
807
- }
808
-
809
- .wplc-user-message .messageBody::before {
810
- display:inline-block; width: 15px; height: 15px; background:#2b97d2; content:'U'; color:#fff; margin-right:10px; position:relative; top:px; text-align:center; font-size: 10px; border-radius:3px;
811
- }
812
- ";
813
-
814
- wp_add_inline_style( 'wplc-admin-style', $inline_identity_css );
815
- }*/
816
-
817
-
818
-
819
- } else if( !isset($wplc_settings['wplc_show_name']) || (isset($wplc_settings['wplc_show_name']) && intval($wplc_settings['wplc_show_name']) == 0) ){
820
- //User has enabled the gravatar, but has chosen to hide the user name.
821
- //This causes some issues with admin display so let's just add some different styling to get around this
822
- $inline_identity_css =
823
- "
824
- .wplc-admin-message-avatar, .wplc-user-message-avatar {
825
- max-width:28px !important;
826
- max-height:28px !important;
827
- }
828
-
829
- .wplc-admin-message, .wplc-user-message{
830
- padding-left:25px !important;
831
- }
832
-
833
- .wplc-admin-message::before, .wplc-user-message::before {
834
- content: ' ';
835
- width: 7px;
836
- height: 7px;
837
- background:#343434;
838
- position: absolute;
839
- left: 12px;
840
- border-radius: 2px;
841
- z-index: 1;
842
- }
843
-
844
- .wplc-user-message::before {
845
- background:#2b97d2;
846
- }
847
- ";
848
-
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
-
861
- do_action("wplc_admin_remote_dashboard_styles_hook");
862
- }
863
-
864
- add_action("wplc_admin_remote_dashboard_above", "wplc_limited_error_output");
865
- /*
866
- * Outputs an error for limitations due to API key
867
- */
868
- function wplc_limited_error_output(){
869
- if(function_exists("wplc_pro_activate")){
870
- echo "<p id='wplc_limited_container' class='update-nag' style='display:none;'>";
871
- echo "<strong>" . __("Dear Pro User,", "wplivechat") . "</strong><br>";
872
- echo __("Your API Key could not be validated, some functionality may be limited", "wplivechat");
873
- echo "</p>";
874
- }
875
-
876
- echo "<p id='wplc_agent_invalid_container' class='update-nag' style='display:none;'>";
877
- echo __("You are not a verified agent, chat dashboard has been disabled", "wplivechat");
878
- echo "</p>";
879
- }
880
-
881
- /*
882
- * Add action for notice checks
883
- */
884
- if ( ! function_exists( "wplc_active_chat_box_notices" ) ) {
885
- if(isset($_GET['page']) && $_GET['page'] === "wplivechat-menu"){
886
- add_action( "wplc_admin_remote_dashboard_above", "wplc_active_chat_box_notices" );
887
- }
888
- }
889
-
890
- add_action("wplc_admin_general_node_compat_check", "wplc_node_compat_version_check");
891
- add_action("wplc_admin_remote_dashboard_above", "wplc_node_compat_version_check", 1);
892
- /*
893
- * Checks if current Pro is compatible with node basic, if not, show notice, and localize scripts needed for conflict free execution
894
- */
895
- function wplc_node_compat_version_check(){
896
- global $wplc_pro_version;
897
- $wplc_ver = str_replace('.', '', $wplc_pro_version);
898
- $checker = intval($wplc_ver);
899
- if (function_exists("wplc_pro_version_control") && $checker < 8000) {
900
- $wpc_ma_js_strings = array(
901
- 'remove_agent' => __('Remove', 'wplivechat'),
902
- 'nonce' => wp_create_nonce("wplc"),
903
- 'user_id' => get_current_user_id(),
904
- 'typing_string' => __('Typing...', 'wplivechat')
905
-
906
- );
907
- wp_localize_script('wplc-admin-js-agent', 'wplc_admin_strings', $wpc_ma_js_strings);
908
-
909
- if(isset($_GET['page']) && $_GET['page'] === "wplivechat-menu"){
910
- wp_register_script('wplc-admin-force-offline-js', plugins_url('../js/wplc_node_offline_mode_controller.js', __FILE__), array('jquery'), '', true);
911
- wp_enqueue_script('wplc-admin-force-offline-js');
912
- }
913
-
914
- $is_dashboard = (isset($_GET['page']) && $_GET['page'] === "wplivechat-menu") ? true : false;
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>
922
- <?php echo wplc_node_compat_pro_update_nag_content(); ?>
923
- </div>
924
- </div>
925
- <?php
926
- }
927
- }
928
-
929
- /*
930
- * Checks if the users Pro API key is expired - this will only be called if pro is active and is less than V8
931
- * true -> Show link to my account page
932
- * false -> Show link to update page
933
- */
934
- function wplc_node_compat_pro_update_nag_content(){
935
- $html_out = "<p id='wplc_offline_mode_reason'>";
936
-
937
- $is_pro_valid = wplc_node_compat_pro_api_key_is_valid_post();
938
-
939
- if($is_pro_valid){
940
- $html_out .= sprintf(__("Chat is now in offline mode, please <a href='%s' target='_BLANK'>upgrade to Version 8</a> (or above) of the WP Live Chat Support Pro Add-on to ensure all functionality works as expected.", "wplivechat"), "update-core.php");
941
- } else {
942
- $html_out .= sprintf(__("Chat is now in offline mode, please renew your API key by visiting the <a href='%s' target='_BLANK'>My Account</a> area, and receive updates.", "wplivechat"), "https://wp-livechat.com/my-account");
943
- }
944
-
945
- $html_out .= "</p>";
946
-
947
- $html_out .= "<p>";
948
- $html_out .= __("Alternatively, please disable the node server option in the Live Chat settings area (Live Chat -> Settings -> Advanced Features)", "wplivechat");
949
- $html_out .= "</p>";
950
-
951
- if($is_pro_valid){
952
- $html_out .= "<a href='update-core.php' class='button button-primary' target='_BLANK'>" . __("Upgrade", "wplivechat") . "</a>";
953
- } else {
954
- $html_out .= "<a href='update-core.php' class='button button-primary' target='_BLANK'>" . __("Renew License", "wplivechat") . "</a>";
955
- }
956
-
957
- if(!isset($_GET['page']) || $_GET['page'] !== "wplivechat-menu-settings"){
958
- $html_out .= " <a href='?page=wplivechat-menu-settings#tabs-beta' class='button' target='_BLANK'>" . __("Settings", "wplivechat") . "</a>";
959
- }
960
-
961
- $html_out .= " <a href='?page=wplivechat-menu&action=welcome' class='button' target='_BLANK'>" . __("Whats new in Version 8", "wplivechat") . "</a>";
962
-
963
- return $html_out;
964
-
965
- }
966
-
967
- /*
968
- * Checks if the Pro API key is valid or not
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
976
- if (get_option($wplc_pro_option_key)) {
977
- $args = array(
978
- 'slug' => $wplc_pro_slug,
979
- );
980
- $data_array = array(
981
- 'method' => 'POST',
982
- 'body' => array(
983
- 'action' => 'api_validation',
984
- 'd' => get_option('siteurl'),
985
- 'request' => serialize($args),
986
- 'api_key' => get_option($wplc_pro_option_key)
987
- ));
988
- $response = wp_remote_post($wplc_pro_validation_url, $data_array);
989
- if (is_array($response)) {
990
- if ( $response['response']['code'] == "200" ) {
991
- $data = $response['body'];
992
- $data = unserialize($data);
993
-
994
- if(isset($data['status']) && $data['status'] === "OK"){
995
- $is_valid = true;
996
- }
997
- }
998
- }
999
-
1000
- }
1001
-
1002
- return $is_valid;
1003
- }
1004
-
1005
- add_filter("wplc_loggedin_filter","wplc_node_compat_version_disable_chat",99,1);
1006
- /*
1007
- * Checks if user is using out-date pro with node server, if so, disable chat on front end
1008
- */
1009
- function wplc_node_compat_version_disable_chat($logged_in) {
1010
- global $wplc_pro_version;
1011
- $wplc_settings = get_option("WPLC_SETTINGS");
1012
- if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
1013
- $wplc_ver = str_replace('.', '', $wplc_pro_version);
1014
- $checker = intval($wplc_ver);
1015
- if (function_exists("wplc_pro_version_control") && $checker < 8000) {
1016
- return false; //Force chat offline
1017
- }
1018
- }
1019
- return $logged_in;
1020
- }
1021
-
1022
- add_action("admin_notices", "wplc_node_v8_plus_notice_dismissable");
1023
- /*
1024
- * Displays an admin notice (which can be dismissed), to notify any V8+ users of the node option (if not already checked)
1025
- */
1026
- function wplc_node_v8_plus_notice_dismissable(){
1027
- if(isset($_GET['page']) && strpos($_GET['page'], 'wplivechat') !== FALSE){
1028
- if(isset($_GET['wplc_dismiss_notice_v8']) && $_GET['wplc_dismiss_notice_v8'] === "true"){
1029
- update_option("wplc_node_v8_plus_notice_dismissed", 'true');
1030
- }
1031
-
1032
- $wplc_settings = get_option("WPLC_SETTINGS");
1033
- if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
1034
- //Do Nothing
1035
- } else {
1036
- //User is not on node, let's check if they have seen this notice before, if not, let's show a notice
1037
- $wplc_has_notice_been_dismissed = get_option("wplc_node_v8_plus_notice_dismissed", false);
1038
- if($wplc_has_notice_been_dismissed === false){
1039
- //Has not been dismissed
1040
- $output = "<div class='notice notice-warning' style='border-color: #0180bc;'>";
1041
- $output .= "<p><strong>" . __( 'Welcome to V8 of WP Live Chat Support', 'wplivechat' ) . "</strong></p>";
1042
- $output .= "<p>" . __('Did you know, this version features high speed message delivery, agent to agent chat, and a single window layout?', 'wplivechat') . "</p>";
1043
- $output .= "<p>" . __('To activate this functionality please navigate to Live Chat -> Settings -> Advanced Features -> And enable our Chat Server option.', 'wplivechat') . "</p>";
1044
-
1045
- $output .= "<p>";
1046
- $output .= "<a href='?page=wplivechat-menu-settings#tabs-beta' class='button button-primary'>" . __("Show me!", "wplivechat") . "</a> ";
1047
- $output .= "<a href='?page=".$_GET['page']."&wplc_dismiss_notice_v8=true' id='wplc_v8_dismiss_node_notice' class='button'>" . __("Don't Show This Again", "wplivechat") . "</a>";
1048
- $output .= "</p>";
1049
-
1050
- $output .= "</div>";
1051
-
1052
- echo $output;
1053
- }
1054
- }
1055
- }
1056
- }
1057
-
1058
- add_filter("wplc_activate_default_settings_array", "wplc_node_set_default_settings", 10, 1);
1059
- /*
1060
- * Adds default node setting to the default settings array
1061
- */
1062
- function wplc_node_set_default_settings($wplc_default_settings_array){
1063
- if(is_array($wplc_default_settings_array)){
1064
- if(!isset($wplc_default_settings_array['wplc_use_node_server'])){
1065
- //Is not set already
1066
- $wplc_default_settings_array['wplc_use_node_server'] = 1;
1067
- }
1068
- }
1069
- return $wplc_default_settings_array;
1070
- }
1071
-
1072
- add_filter( 'rest_url', 'wplc_node_rest_url_ssl_fix');
1073
- /**
1074
- * Changes the REST URL to include the SSL version if we are using SSL
1075
- * See https://core.trac.wordpress.org/ticket/36451
1076
- */
1077
- function wplc_node_rest_url_ssl_fix($url){
1078
- if (is_ssl()){
1079
- $url = set_url_scheme( $url, 'https' );
1080
- return $url;
1081
- }
1082
- return $url;
1083
- }
1084
-
1085
- /**
1086
- * Returns an array of pages/posts available on the site
1087
- */
1088
- function wplc_node_pages_posts_array(){
1089
- $r = array(
1090
- 'depth' => 0,
1091
- 'child_of' => 0,
1092
- 'echo' => false,
1093
- 'id' => '',
1094
- 'class' => '',
1095
- 'show_option_none' => '',
1096
- 'show_option_no_change' => '',
1097
- 'option_none_value' => '',
1098
- 'value_field' => 'ID',
1099
- );
1100
-
1101
- $pages = get_pages($r);
1102
- $posts = get_posts(array('posts_per_page' => -1));
1103
-
1104
- $posts_pages = array_merge($pages,$posts);
1105
-
1106
- $return_array = array();
1107
-
1108
- foreach ($posts_pages as $key => $value) {
1109
- $post_page_id = $value->ID;
1110
- $post_page_title = $value->post_title;
1111
-
1112
- $return_array[get_permalink($post_page_id)] = $post_page_title;
1113
- }
1114
-
1115
- return $return_array;
1116
- }
1117
-
1118
-
1119
-
1120
- add_action("init","wplc_node_cloud_server_integration_hook_handler");
1121
- /**
1122
- * V8 Cloud Action & Filter Handlers
1123
- */
1124
- function wplc_node_cloud_server_integration_hook_handler() {
1125
- $wplc_settings = get_option("WPLC_SETTINGS");
1126
- if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
1127
- if(function_exists("wplc_cloud_load_updates")){
1128
- remove_action("init","wplc_cloud_load_updates");
1129
- remove_action("wplc_hook_chat_dashboard_above","wplc_cloud_1_hook_chat_dashboard_above");
1130
- remove_action("wplc_hook_admin_chatbox_javascript","wplc_cloud_hook_control_push_js_to_admin", 10);
1131
- remove_action("wplc_hook_push_js_to_front","wplc_cloud_hook_control_push_js_to_front", 10);
1132
- remove_action("wplc_hook_chat_history","wplc_cloud_hook_control_chat_history", 1);
1133
- remove_action("wplc_hook_chat_missed","wplc_cloud_hook_control_chat_missed", 1);
1134
- remove_action("wplc_hook_initiate_check","wplc_cloud_hook_control_intiate_check", 1);
1135
- remove_action("wplc_hook_history_draw_area","wplc_cloud_hook_control_history_draw_area", 1);
1136
- remove_action("wplc_hook_change_status_on_answer","wplc_cloud_hook_control_change_status_on_answer", 1);
1137
- remove_action("wplc_hook_update_agent_id","wplc_cloud_hook_control_update_agent_id", 1);
1138
- remove_action('wplc_hook_accept_chat_url' , 'wplc_cloud_hook_control_accept_chat_url', 1);
1139
- remove_action("wplc_hook_ma_check_if_answered_by_another_agent","wplc_cloud_hook_check_if_answered_by_another_agent", 1);
1140
- remove_action("wplc_hook_settings_page_more_tabs","wplc_cloud_hook_control_settings_page_more_tabs");
1141
- remove_action("init","wplc_cloud_first_run_check");
1142
- remove_action('wplc_hook_admin_settings_save','wplc_cloud_save_settings');
1143
- remove_action("wplc_api_route_hook", "wplc_api_node_routes_cloud", 1);
1144
- remove_action('http_api_curl', 'wplc_cloud_http_api_curl', 100);
1145
- remove_action("init", "wplc_cloud_additional_hooks", 1);
1146
-
1147
- remove_filter("wplc_filter_get_chat_messages","wplc_cloud_filter_control_chat_messages",10);
1148
- remove_filter("wplc_filter_get_chat_data","wplc_cloud_filter_control_chat_data",1);
1149
- remove_filter("wplc_filter_chat_area_data","wplc_cloud_filter_control_chat_area_data",10);
1150
- remove_filter("wplc_rating_data_filter","wplc_cloud_filter_control_get_rating_data",1);
1151
- remove_filter("wplc_filter_admin_javascript","wplc_cloud_filter_control_admin_javascript");
1152
- remove_filter("wplc_start_chat_user_form_after_filter", "wplc_start_chat_user_form_after_filter_remove_departments_cloud",2);
1153
- remove_filter("wplc_after_chat_visitor_count_hook", "wplc_admin_cloud_remove_departments_chat_area_before_end_chat_button",2);
1154
- remove_filter("wplc_admin_chat_area_before_end_chat_button", "wplc_admin_cloud_remove_transfer_button_chat_area_before_end_chat_button",2);
1155
- remove_filter("wplc_filter_front_js_extra_data","wplc_cloud_filter_control_front_js_extra_data",10);
1156
- remove_filter("wplc_filter_ajax_url","wplc_cloud_filter_control_ajax_url",10);
1157
- remove_filter("wplc_filter_setting_tabs","wplc_cloud_filter_control_setting_tabs");
1158
- remove_filter("wplc_filter_menu_api","wplc_cloud_filter_control_menu_api",1);
1159
- remove_filter('http_request_args', 'wplc_cloud_http_request_args',100);
1160
- }
1161
- }
1162
- }
1163
-
1164
- add_action("init","wplc_node_mobile_integration_hook_handler");
1165
- /**
1166
- * V8 Mobile/Desktop Extension Action & Filter Handlers
1167
- */
1168
- function wplc_node_mobile_integration_hook_handler() {
1169
- $wplc_settings = get_option("WPLC_SETTINGS");
1170
- if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
1171
- if(function_exists("wplc_md_load_updates")){
1172
- remove_action("init","wplc_md_load_updates");
1173
- remove_action("wplc_hook_settings_page_more_tabs","wplc_mobile_hook_control_settings_page_more_tabs");
1174
- remove_action("init","wplc_mobile_first_run_check");
1175
- remove_action('wplc_hook_admin_settings_save','wplc_mobile_save_settings');
1176
-
1177
- remove_filter("wplc_filter_is_admin_logged_in","wplc_mobile_check_if_logged_in",10);
1178
- remove_filter("wplc_filter_setting_tabs","wplc_mobile_filter_control_setting_tabs");
1179
- remove_filter("wplc_filter_menu_api","wplc_mobile_filter_control_menu_api");
1180
- }
1181
- }
1182
- }
1183
-
1184
-
1185
- add_action("wplc_admin_remoter_dashboard_scripts_localizer", "wplc_admin_remote_dashboard_dynamic_translation_handler");
1186
- /*
1187
- * Localizes an array of strings and ids in the dashboard which need to be replaced
1188
- * Loads the custom JS file responsible for replacing the content dynamically.
1189
- */
1190
- function wplc_admin_remote_dashboard_dynamic_translation_handler(){
1191
-
1192
- global $wplc_version;
1193
- wp_register_script('wplc-admin-dynamic-translation', plugins_url( '../js/wplc_admin_dynamic_translations.js', __FILE__ ), array("wplc-admin-js-agent", "wplc-admin-js-sockets", "jquery"), $wplc_version, false); //Added this for async storage calls
1194
-
1195
- $wplc_dynamic_translation_array = array(
1196
- 'nifty_bg_holder_text_inner' => __('Connecting...', 'wplivechat'),
1197
- 'nifty_admin_chat_prompt_title' => __('Please Confirm', 'wplivechat'),
1198
- 'nifty_admin_chat_prompt_confirm' => __('Confirm', 'wplivechat'),
1199
- 'nifty_admin_chat_prompt_cancel' => __('Cancel', 'wplivechat'),
1200
- 'active_count_string' => __(' Active visitors', 'wplivechat'),
1201
- 'wplc-agent-info' => __('Agent(s) Online', 'wplivechat'),
1202
- 'wplc_history_link' => __('Chat History', 'wplivechat'),
1203
- 'nifty_agent_heading' => __('Agents', 'wplivechat'),
1204
- 'drag_zone_inner_text' => __('Drag Files Here', 'wplivechat'),
1205
- 'chatTransferLink' => __('Transfer', 'wplivechat'),
1206
- 'chatTransferDepLink' => __('Department Transfer', 'wplivechat'),
1207
- 'chatDirectUserToPageLink' => __('Direct User To Page', 'wplivechat'),
1208
- 'chatCloseTitle' => __('Leave chat', 'wplivechat'),
1209
- 'chatEndTitle' => __('End chat', 'wplivechat'),
1210
- 'chatTransferUps' => __('Transfer', 'wplivechat'),
1211
- 'chatDirectUserToPageUps' => __('Direct User To Page', 'wplivechat'),
1212
- 'nifty_event_heading' => __('Events', 'wplivechat'),
1213
- 'nifty_join_chat_button' => __('Join chat', 'wplivechat'),
1214
- 'nifty_filter_button' => __('Filters', 'wplivechat'),
1215
- 'nifty_new_visitor_item' => __('New Visitors (3 Min)', 'wplivechat'),
1216
- 'nifty_active_chats_item' => __('Active Chats', 'wplivechat'),
1217
- 'nifty_clear_filters_item' => __('Clear Filters', 'wplivechat'),
1218
- 'nifty_active_chats_heading' => __('Active visitors', 'wplivechat'),
1219
- 'nifty_vis_col_heading' => __('Visitor', 'wplivechat'),
1220
- 'nifty_vis_info_heading' => __('Info', 'wplivechat'),
1221
- 'nifty_vis_page_heading' => __('Page', 'wplivechat'),
1222
- 'nifty_vis_status_heading' => __('Chat Status', 'wplivechat'),
1223
- 'nifty_vis_dep_heading' => __('Department', 'wplivechat'),
1224
- 'wdt-emoji-search-result-title' => __('Search Results', 'wplivechat'),
1225
- 'wdt-emoji-no-result' => __('No emoji found', 'wplivechat')
1226
- );
1227
-
1228
- apply_filters("wplc_adming_dynamic_translation_filter", $wplc_dynamic_translation_array);
1229
-
1230
-
1231
- wp_localize_script('wplc-admin-dynamic-translation', 'wplc_dynamic_translation_array', $wplc_dynamic_translation_array);
1232
- wp_enqueue_script('wplc-admin-dynamic-translation');
1233
-
1234
  }
1
+ <?php
2
+ /*
3
+ * Node Code -> Insert pun here
4
+ */
5
+
6
+ define("BLEEPER_API_URL", "https://bleeper.io/app/api/v1/");
7
+ define("BLEEPER_REMOTE_DASH_ROUTE", "remote_dashboard.php");
8
+
9
+ define("BLEEPER_NODE_SERVER_URL", "https://bleeper.us-3.evennode.com");
10
+
11
+ //define("BLEEPER_NODE_SERVER_URL", "http://localhost:3000");
12
+ define("BLEEPER_NODE_END_POINTS_ROUTE", "api/v1/");
13
+ define("BLEEPER_NODE_END_POINT_TOKEN", "zf6fe1399sdfgsdfg02ad09ab6a8cb7345s");
14
+
15
+
16
+ add_action("wplc_activate_hook", "wplc_node_server_token_check", 10);
17
+ add_action("wplc_update_hook", "wplc_node_server_token_check", 10);
18
+ /**
19
+ * Checks if a secret key has been created.
20
+ * If not create one for use in the API
21
+ *
22
+ * @return void
23
+ */
24
+ function wplc_node_server_token_check(){
25
+ if (!get_option("wplc_node_server_secret_token")) {
26
+ $user_token = wplc_node_server_token_create();
27
+ add_option("wplc_node_server_secret_token", $user_token);
28
+ }
29
+ }
30
+
31
+ add_action("wplc_admin_remote_dashboard_below", "wplc_admin_remote_dashboard_thank_you_footer");
32
+ /*
33
+ * Adds a simple thank you message to the footer of the dashboard
34
+ */
35
+ function wplc_admin_remote_dashboard_thank_you_footer(){
36
+ echo "<p id='wplc_footer_message' style='display:none;'>";
37
+ echo __("Thank you for using WP Live Chat Support - Need assistance? Please get in touch here: ", "wplivechat");
38
+ echo "<a href='https://wp-livechat.com/contact-us/' rel='nofollow' target='_blank'>" . __("Contact us", "wplivechat") . "</a><span class='bleeper_stats'></span><span class='bleeper_instance'></span>";
39
+ echo "</p>";
40
+ }
41
+
42
+ /**
43
+ * Generates a new Secret Token
44
+ *
45
+ * @return string
46
+ */
47
+ function wplc_node_server_token_create(){
48
+ $the_code = rand(0, 1000) . rand(0, 1000) . rand(0, 1000) . rand(0, 1000) . rand(0, 1000);
49
+ $the_time = time();
50
+ $token = md5($the_code . $the_time);
51
+ return $token;
52
+ }
53
+
54
+ /**
55
+ * Re-Generates the token
56
+ * @return void
57
+ */
58
+ function wplc_node_server_token_regenerate(){
59
+ $wplc_node_token_new = wplc_node_server_token_create();
60
+ update_option("wplc_node_server_secret_token", $wplc_node_token_new);
61
+ }
62
+
63
+ /**
64
+ * Post to the NODE server -
65
+ *
66
+ * @param string $route Route you would like to use for the node server
67
+ * @param string $form_data data to send
68
+ * @return string (or false on fail)
69
+ */
70
+ function wplc_node_server_post($route, $form_data){
71
+ $url = trailingslashit(BLEEPER_NODE_SERVER_URL) . trailingslashit(BLEEPER_NODE_END_POINTS_ROUTE) . $route;
72
+
73
+ $wplc_end_point_override = get_option("wplc_end_point_override");
74
+ if($wplc_end_point_override !== false && $wplc_end_point_override !== ""){
75
+ $url = $wplc_end_point_override . BLEEPER_NODE_END_POINTS_ROUTE . $route; //Use the override URL
76
+ }
77
+
78
+
79
+ if(!isset($form_data['token'])){
80
+ $form_data['token'] = BLEEPER_NODE_END_POINT_TOKEN; //Add the security token
81
+ }
82
+
83
+ if(!isset($form_data['api_key'])){
84
+ $wplc_node_token = get_option("wplc_node_server_secret_token");
85
+ if(!$wplc_node_token){
86
+ if(function_exists("wplc_node_server_token_regenerate")){
87
+ wplc_node_server_token_regenerate();
88
+ $wplc_node_token = get_option("wplc_node_server_secret_token");
89
+ }
90
+ }
91
+
92
+ $form_data['api_key'] = $wplc_node_token; //Add the security token
93
+ }
94
+
95
+ if(!isset($form_data['origin_url'])){
96
+ $ajax_url = admin_url('admin-ajax.php');
97
+ $origin_url = str_replace("/wp-admin/admin-ajax.php", "", $ajax_url);
98
+ $form_data['origin_url'] = $origin_url; //Add the security token
99
+ }
100
+
101
+ $context = @stream_context_create($options);
102
+ $result = @file_get_contents($url . "?" . http_build_query($form_data), false, $context);
103
+
104
+ if ($result === FALSE) {
105
+ return false;
106
+ } else {
107
+ return $result;
108
+ }
109
+ }
110
+
111
+ add_action("wplc_hook_chat_notification","wplc_filter_notification_hook_node",20,3);
112
+ /**
113
+ * Send a system notification to the node server
114
+ *
115
+ * @return void
116
+ */
117
+ function wplc_filter_notification_hook_node($type,$cid,$data){
118
+ $wplc_settings = get_option("WPLC_SETTINGS");
119
+ if(isset($wplc_settings['wplc_use_node_server']) && intval($wplc_settings['wplc_use_node_server']) == 1) {
120
+
121
+ if(filter_var($cid, FILTER_VALIDATE_INT) ) {
122
+ //Let's reverse the CID back to it's rel counterpart
123
+ $cid = wplc_return_chat_rel_by_id($cid);
124
+ }
125
+
126
+ $msg = false;
127
+ switch($type){
128
+ case "doc_suggestion":
129
+ $msg = $data['formatted_msg'];
130
+ break;
131
+ default:
132
+ break;
133
+ }
134
+
135
+ if(isset($cid)){
136
+ if($msg !== false){
137
+ $form_data = array(
138
+ 'chat_id' => $cid,
139
+ 'notification_text' => $msg,
140
+ );
141
+
142
+ $user_request = wplc_node_server_post("user_chat_notification", $form_data);
143
+
144
+ if($user_request === false){
145
+ //Something is wrong
146
+ } else {
147
+
148
+ }
149
+ }
150
+ }
151
+ }
152
+
153
+ return;
154
+ }
155
+
156
+ add_action("wplc_api_route_hook", "wplc_api_node_routes");
157
+ /**
158
+ * Add a REST API routes for the node server
159
+ *
160
+ * @return void
161
+ */
162
+ function wplc_api_node_routes(){
163
+ register_rest_route('wp_live_chat_support/v1','/async_storage', array(
164
+ 'methods' => 'POST',
165
+ 'callback' => 'wplc_node_async_storage_rest'
166
+ ));
167
+ }
168
+
169
+ /**
170
+ * Handles Async storage REST -> Params are processed within the request
171
+ * Required POST variables:
172
+ * - Chat ID
173
+ * - Security Key
174
+ * - Message (JSON encoded array)
175
+ * - Action
176
+ *
177
+ * @param WP_REST_Request $request Request Data
178
+ * @return void
179
+ */
180
+ function wplc_node_async_storage_rest(WP_REST_Request $request){
181
+ $return_array = array();
182
+ $return_array['request_status'] = false; //Default to be returned if something goes wrong
183
+ if(isset($request)){
184
+ if(isset($request['security'])){
185
+ $stored_token = get_option("wplc_node_server_secret_token");
186
+ $check = $_POST['server_token'] == $stored_token ? true : false;
187
+ if ($check) {
188
+ if(isset($request['chat_id'])){
189
+ if(isset($request['messages'])){
190
+ if(isset($request['relay_action'])){
191
+ $chat_id = sanitize_text_field($request['chat_id']);
192
+ $message_data = json_decode($request['messages']);
193
+ $chat_session = wplc_return_chat_session_variable($chat_id);
194
+ $action = $request['relay_action'];
195
+ if($message_data !== NULL){
196
+ if($action == "wplc_user_send_msg"){
197
+ foreach ($message_data as $message) {
198
+ $message = sanitize_text_field($message);
199
+ wplc_record_chat_msg("1", $chat_id, $message);
200
+
201
+ //wplc_update_user_on_page($chat_id, "3", $chat_session); //Keep timestamp active
202
+ wplc_update_active_timestamp($chat_id);
203
+ }
204
+
205
+ $return_array['request_status'] = true;
206
+ $return_array['request_information'] = __("Success", "wplivechat");
207
+ } else if ($action == "wplc_admin_send_msg"){
208
+ foreach ($message_data as $message) {
209
+ $message = sanitize_text_field($message);
210
+ wplc_record_chat_msg("2", $chat_id, $message, true);
211
+
212
+ //wplc_update_user_on_page($chat_id, "3", $chat_session); //Keep timestamp active
213
+ wplc_update_active_timestamp($chat_id);
214
+ }
215
+
216
+ $return_array['request_status'] = true;
217
+ $return_array['request_information'] = __("Success", "wplivechat");
218
+ }
219
+ } else {
220
+ $return_array['request_information'] = __("Message data is corrupt", "wplivechat");
221
+ }
222
+ } else {
223
+ $return_array['request_information'] = __("Action not set", "wplivechat");
224
+ }
225
+ } else {
226
+ $return_array['request_information'] = __("Message data array not set", "wplivechat");
227
+ }
228
+ } else {
229
+ $return_array['request_information'] = __("Chat ID is not set", "wplivechat");
230
+ }
231
+ }
232
+ } else {
233
+ $return_array['request_information'] = __("No security nonce found", "wplivechat");
234
+ }
235
+ }
236
+
237
+ return $return_array;
238
+
239
+ }
240
+
241
+ add_action("wp_ajax_wplc_node_async_storage_ajax", "wplc_node_async_storage_ajax");
242
+ add_action("wp_ajax_nopriv_wplc_node_async_storage_ajax", "wplc_node_async_storage_ajax");
243
+ /**
244
+ * Handles Async storage AJAX (Fallback for if REST is not present) -> Params are processed within the request
245
+ * Required POST variables:
246
+ * - Chat ID
247
+ * - Security Key
248
+ * - Message (JSON encoded array)
249
+ * - Action
250
+ *
251
+ * @return void
252
+ */
253
+ function wplc_node_async_storage_ajax(){
254
+ $return_array = array();
255
+ $return_array['request_status'] = false; //Default to be returned if something goes wrong
256
+ if(isset($_POST)){
257
+ if(isset($_POST['server_token'])){
258
+ $stored_token = get_option("wplc_node_server_secret_token");
259
+ $check = $_POST['server_token'] == $stored_token ? true : false;
260
+ if ($check) {
261
+ if(isset($_POST['chat_id'])){
262
+ if(isset($_POST['messages'])){
263
+ if(isset($_POST['relay_action'])){
264
+ $chat_id = sanitize_text_field($_POST['chat_id']);
265
+ $message_data = json_decode($_POST['messages']);
266
+ $chat_session = wplc_return_chat_session_variable($chat_id);
267
+ $action = $_POST['relay_action'];
268
+ if($message_data !== NULL){
269
+ if($action == "wplc_user_send_msg"){
270
+ foreach ($message_data as $message) {
271
+ $message = sanitize_text_field($message);
272
+ wplc_record_chat_msg("1", $chat_id, $message);
273
+ //wplc_update_user_on_page($chat_id, "3", $chat_session); //Keep timestamp active
274
+ wplc_update_active_timestamp($chat_id);
275
+
276
+ }
277
+
278
+ $return_array['request_status'] = true;
279
+ $return_array['request_information'] = __("Success", "wplivechat");
280
+ } else if ($action == "wplc_admin_send_msg"){
281
+ foreach ($message_data as $message) {
282
+ $message = sanitize_text_field($message);
283
+ wplc_record_chat_msg("2", $chat_id, $message);
284
+ //wplc_update_user_on_page($chat_id, "3", $chat_session); //Keep timestamp active
285
+ wplc_update_active_timestamp($chat_id);
286
+ }
287
+
288
+ $return_array['request_status'] = true;
289
+ $return_array['request_information'] = __("Success", "wplivechat");
290
+ }
291
+ } else {
292
+ $return_array['request_information'] = __("Message data is corrupt", "wplivechat");
293
+ }
294
+ } else {
295
+ $return_array['request_information'] = __("Action not set", "wplivechat");
296
+ }
297
+ } else {
298
+ $return_array['request_information'] = __("Message data array not set", "wplivechat");
299
+ }
300
+ } else {
301
+ $return_array['request_information'] = __("Chat ID is not set", "wplivechat");
302
+ }
303
+ }
304
+ } else {
305
+ $return_array['request_information'] = __("No security nonce found", "wplivechat");
306
+ }
307
+ }
308
+
309
+ return $return_array;
310
+
311
+ }
312
+
313
+ /**
314
+ * Loads remote dashboard
315
+ *
316
+ * @return void
317
+ */
318
+ function wplc_admin_dashboard_layout_node( $location = 'dashboard' ){
319
+ if ( $location === 'dashboard') {
320
+
321
+ if( ! get_user_meta( get_current_user_id(), 'wplc_ma_agent', true ) ){
322
+ echo "<div class='error below-h1'>";
323
+ echo "<h2>".__("Error", "wplivechat")."</h2>";
324
+ echo "<p>".__("Only chat agents can access this page.", "wplivechat")."</p>";
325
+ echo "</div>";
326
+ return;
327
+ }
328
+
329
+ do_action("wplc_admin_remote_dashboard_above");
330
+
331
+ echo "<div id='bleeper_content_wrapper'></div>";
332
+
333
+ if ( ! isset( $_GET['action'] ) || 'history' !== $_GET['action'] ) {
334
+
335
+ echo "<div class='wplc_remote_dash_below_contianer'>";
336
+ do_action("wplc_admin_remote_dashboard_below");
337
+ echo "</div>";
338
+
339
+ }
340
+ } else {
341
+ do_action("wplc_admin_remote_dashboard_above");
342
+
343
+ echo "<div id='bleeper_content_wrapper'></div>";
344
+
345
+ if ( ! empty( $_GET['page'] ) && 'wplivechat-menu' === $_GET['page'] ) { // This div is also hidden by js under the same conditions
346
+
347
+ echo "<div class='wplc_remote_dash_below_contianer'>";
348
+ do_action("wplc_admin_remote_dashboard_below");
349
+ echo "</div>";
350
+
351
+ }
352
+ }
353
+ }
354
+
355
+ add_action("wplc_admin_remote_dashboard_below", "wplc_admin_remote_dashboard_below_delegate");
356
+ /*
357
+ * Delegates the below dashboard hooks
358
+ */
359
+ function wplc_admin_remote_dashboard_below_delegate(){
360
+ do_action("wplc_hook_chat_dashboard_bottom");
361
+ }
362
+
363
+ add_action("wplc_hook_chat_dashboard_bottom","wplc_hook_control_dashboard_bottom_loading_logo",1);
364
+ /**
365
+ * Decides whether or not to show the available extensions for this area.
366
+ * @return void
367
+ * @since 6.0.00
368
+ * @author Nick Duncan <nick@codecabin.co.za>
369
+ */
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
+
377
+ add_action('admin_enqueue_scripts', 'wplc_enqueue_dashboard_popup_scripts');
378
+ /**
379
+ * Enqueues the scripts for the admin dashboard popup icon and chat box
380
+ * @return void
381
+ */
382
+ function wplc_enqueue_dashboard_popup_scripts() {
383
+ global $wplc_version;
384
+ wp_enqueue_script('jquery-ui-draggable');
385
+ wp_enqueue_script('wplc-admin-popup', plugins_url('../js/wplc_admin_popup.js', __FILE__ ), array('jquery-ui-draggable'), $wplc_version);
386
+
387
+ wp_button_pointers_load_scripts('toplevel_page_wplivechat-menu');
388
+ }
389
+
390
+ add_action( "admin_footer", "wplc_dashboard_display_decide" );
391
+ /**
392
+ * Decide whether or not to display the dashboard layout on an admin page
393
+ * @return void
394
+ */
395
+ function wplc_dashboard_display_decide() {
396
+ $wplc_settings = get_option("WPLC_SETTINGS");
397
+ if ( isset( $wplc_settings['wplc_use_node_server'] ) && $wplc_settings['wplc_use_node_server'] == 1 ) {
398
+ //Node in use, load remote dashboard
399
+ if ( isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu') {
400
+ // we control this in the wplc_admin_menu_layout function
401
+ //wplc_admin_dashboard_layout_node('dashboard');
402
+ } else {
403
+ if (function_exists("wplc_pro_version_control")) {
404
+ global $wplc_pro_version;
405
+ $wplc_ver = str_replace('.', '', $wplc_pro_version);
406
+ $checker = intval($wplc_ver);
407
+ if (function_exists("wplc_pro_version_control") && $checker < 8000) {
408
+ /* ONLY SHOW THE POPOUT DASHBOARD IF THEY ARE USING PRO 8.0.00 and above */
409
+ return;
410
+ }
411
+ }
412
+
413
+
414
+ /**
415
+ * Check to see if we have enabled "Enable chat dashboard and notifications on all admin pages"
416
+ */
417
+
418
+ if ( isset( $wplc_settings['wplc_enable_all_admin_pages'] ) && $wplc_settings['wplc_enable_all_admin_pages'] === '1' ) {
419
+
420
+
421
+ wplc_admin_dashboard_layout_node('other');
422
+
423
+ echo '<div class="floating-right-toolbar">';
424
+ echo '<label for="user_list_bleeper_control" style="margin-bottom: 0; display:none;"></label>';
425
+
426
+ echo '<i id="toolbar-item-open-bleeper" class="fa fa-fw" style="background:url(\''.plugins_url('../images/48px.png', __FILE__).'\') no-repeat; background-size: cover;"></i>';
427
+ echo '</div>';
428
+ }
429
+
430
+ }
431
+ }
432
+
433
+
434
+
435
+ }
436
+
437
+
438
+ /**
439
+ * Loads remote dashboard scripts and styles
440
+ *
441
+ * @return void
442
+ */
443
+ function wplc_admin_remote_dashboard_scripts($wplc_settings){
444
+ global $wplc_version;
445
+ $wplc_current_user = get_current_user_id();
446
+ if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true )) {
447
+
448
+ $user_info = get_userdata(intval($wplc_current_user));
449
+
450
+ $user_array = get_users(array(
451
+ 'meta_key' => 'wplc_ma_agent',
452
+ ));
453
+
454
+ $a_array = array();
455
+ if ($user_array) {
456
+ foreach ($user_array as $user) {
457
+ $current_user_name = apply_filters("wplc_agent_display_name_filter", $user->display_name);
458
+ $a_array[$user->ID] = array();
459
+ $a_array[$user->ID]['name'] = $user->display_name;
460
+ $a_array[$user->ID]['display_name'] = $user->display_name;
461
+ $a_array[$user->ID]['md5'] = md5( $user->user_email );
462
+ $a_array[$user->ID]['email'] = md5( $user->user_email );
463
+ }
464
+ }
465
+
466
+
467
+ if( isset($wplc_settings['wplc_show_name']) && $wplc_settings['wplc_show_name'] == '1' ){ $wplc_show_name = true; } else { $wplc_show_name = false; }
468
+ if( isset($wplc_settings['wplc_show_avatar']) && $wplc_settings['wplc_show_avatar'] ){ $wplc_show_avatar = true; } else { $wplc_show_avatar = false; }
469
+ if( isset($wplc_settings['wplc_show_date']) && $wplc_settings['wplc_show_date'] == '1' ){ $wplc_show_date = true; } else { $wplc_show_date = false; }
470
+ if( isset($wplc_settings['wplc_show_time']) && $wplc_settings['wplc_show_time'] == '1' ){ $wplc_show_time = true; } else { $wplc_show_time = false; }
471
+
472
+ $wplc_chat_detail = array( 'name' => $wplc_show_name, 'avatar' => $wplc_show_avatar, 'date' => $wplc_show_date, 'time' => $wplc_show_time );
473
+
474
+
475
+
476
+
477
+ $wplc_end_point_override = get_option("wplc_end_point_override");
478
+ if($wplc_end_point_override !== false && $wplc_end_point_override !== ""){
479
+ $bleeper_url = $wplc_end_point_override; //Use the override URL
480
+ } else {
481
+ $bleeper_url = BLEEPER_NODE_SERVER_URL;
482
+ }
483
+
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
+
505
+ wp_register_script('md5', plugins_url( '../js/md5.js', __FILE__ ), array("wplc-admin-js-sockets"), false, false);
506
+ wp_enqueue_script('md5');
507
+
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
+
515
+ if (isset($wplc_settings['wplc_enable_msg_sound'])) {
516
+
517
+ if (intval($wplc_settings['wplc_enable_msg_sound']) == 1) {
518
+ wp_localize_script('wplc-admin-js-agent', "bleeper_ping_sound_notification_enabled", "true");
519
+ } else {
520
+ wp_localize_script('wplc-admin-js-agent', "bleeper_ping_sound_notification_enabled", "false");
521
+ }
522
+
523
+ }
524
+
525
+ wp_register_script('my-wplc-admin-chatbox-ui-events', plugins_url('../js/wplc_u_admin_chatbox_ui_events.js', __FILE__), array('jquery'), $wplc_version, true);
526
+ wp_enqueue_script('my-wplc-admin-chatbox-ui-events');
527
+
528
+
529
+
530
+ $wplc_et_ajax_nonce = wp_create_nonce( "wplc_et_nonce" );
531
+ wp_register_script( 'wplc_transcript_admin', plugins_url( '../js/wplc_transcript.js', __FILE__ ), null, '', true );
532
+ $wplc_transcript_localizations = array(
533
+ 'ajax_nonce' => $wplc_et_ajax_nonce,
534
+ 'string_loading' => __( "Sending transcript...", "wplivechat" ),
535
+ 'string_title' => __( "Sending Transcript", "wplivechat" ),
536
+ 'string_close' => __( "Close", "wplivechat" ),
537
+ 'string_chat_emailed' => __( "The chat transcript has been emailed.", "wplivechat" ),
538
+ 'string_error1' => sprintf( __( "There was a problem emailing the chat. Please <a target='_BLANK' href='%s'>contact support</a>.", "wplivechat" ), "http://wp-livechat.com/contact-us/?utm_source=plugin&utm_medium=link&utm_campaign=error_emailing_chat" )
539
+ );
540
+ wp_localize_script( 'wplc_transcript_admin', 'wplc_transcript_nonce', $wplc_transcript_localizations );
541
+ wp_enqueue_script( 'wplc_transcript_admin' );
542
+
543
+ $wplc_node_token = get_option("wplc_node_server_secret_token");
544
+ if(!$wplc_node_token){
545
+ if(function_exists("wplc_node_server_token_regenerate")){
546
+ wplc_node_server_token_regenerate();
547
+ $wplc_node_token = get_option("wplc_node_server_secret_token");
548
+ }
549
+ }
550
+
551
+ $form_data = array("node_token" => $wplc_node_token, "action" => "wordpress");
552
+ $form_data = apply_filters("wplc_admin_dashboard_layout_node_request_variable_filter", $form_data); //Filter for pro to add a few request variables to the mix for additional structure
553
+
554
+ /*$options = array(
555
+ 'http' => array(
556
+ 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
557
+ 'method' => 'POST',
558
+ 'content' => http_build_query($form_data)
559
+ )
560
+ );
561
+ $context = @stream_context_create($options);
562
+ $result = @file_get_contents(BLEEPER_API_URL . BLEEPER_REMOTE_DASH_ROUTE, false, $context);*/
563
+
564
+ wp_localize_script('wplc-admin-js-agent', 'bleeper_remote_form_data_array', $form_data);
565
+ wp_localize_script('wplc-admin-js-agent', 'bleeper_remote_form_api_url', BLEEPER_API_URL);
566
+ wp_localize_script('wplc-admin-js-agent', 'bleeper_remote_form_route', BLEEPER_REMOTE_DASH_ROUTE);
567
+
568
+
569
+ if ( isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu' ) {
570
+ wp_localize_script('wplc-admin-js-agent', 'bleeper_in_dashboard', '1');
571
+ } else {
572
+ wp_localize_script('wplc-admin-js-agent', 'bleeper_in_dashboard', '0');
573
+ }
574
+
575
+ $inline_error_message = "<div class='error below-h1' style='display:none;' id='bleeper_inline_connection_error'>
576
+ <p>" . __("Connection Error", "wplivechat") . "<br /></p>
577
+ <p>" . __("We are having some trouble contacting the server. Please try again later.", "wplivechat") . "</p>
578
+ </div>";
579
+ wp_localize_script('wplc-admin-js-agent', 'bleeper_remote_form_error', $inline_error_message);
580
+
581
+
582
+
583
+
584
+
585
+ if (isset($wplc_settings['wplc_enable_visitor_sound']) && intval($wplc_settings['wplc_enable_visitor_sound']) == 1) {
586
+ wp_localize_script('wplc-admin-js-agent', 'bleeper_enable_visitor_sound', '1');
587
+ } else {
588
+ wp_localize_script('wplc-admin-js-agent', 'bleeper_enable_visitor_sound', '0');
589
+ }
590
+
591
+
592
+
593
+
594
+ $agent_display_name = $user_info->display_name;
595
+
596
+ wp_localize_script('wplc-admin-js-agent', 'agent_id', "" . $wplc_current_user);
597
+ wp_localize_script('wplc-admin-js-agent', 'bleeper_agent_name', apply_filters("wplc_agent_display_name_filter", $agent_display_name) );
598
+ wp_localize_script('wplc-admin-js-agent', 'nifty_api_key', get_option("wplc_node_server_secret_token"));
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");
608
+ wp_localize_script('wplc-admin-js-agent', 'bleeper_disable_add_message', "true");
609
+ wp_localize_script('wplc-admin-js-agent', 'wplc_nonce', wp_create_nonce("wplc"));
610
+ wp_localize_script('wplc-admin-js-agent', 'wplc_cid', "null");
611
+ wp_localize_script('wplc-admin-js-agent', 'wplc_chat_name', "null");
612
+ //wp_localize_script('wplc-admin-js-agent', 'wplc_chat_email', "null"); //TODO: Parse the email
613
+
614
+ wp_localize_script( 'wplc-admin-js-agent', 'wplc_show_chat_detail', $wplc_chat_detail );
615
+
616
+ wp_localize_script('wplc-admin-js-agent', 'wplc_agent_data', $a_array);
617
+ wp_localize_script('wplc-admin-js-agent', 'all_agents', $a_array);
618
+
619
+ wp_localize_script('wplc-admin-js-agent', 'wplc_url', plugins_url( '', dirname( __FILE__ ) ) );
620
+
621
+ if( isset($wplc_settings['wplc_settings_enabled']) && intval($wplc_settings["wplc_settings_enabled"]) == 2) {
622
+
623
+ $wplc_disabled_html = __("Chat is disabled in settings area, re-enable", "wplivechat");
624
+ $wplc_disabled_html .= " <a href='?page=wplivechat-menu-settings'>" . __("here", "wplivechat") . "</a>";
625
+
626
+ wp_localize_script('wplc-admin-js-agent', 'wplc_disabled', 'true');
627
+ wp_localize_script('wplc-admin-js-agent', 'wplc_disabled_html', $wplc_disabled_html);
628
+ }
629
+
630
+
631
+ //Added rest nonces
632
+ if(class_exists("WP_REST_Request")) {
633
+ wp_localize_script('wplc-admin-js-agent', 'wplc_restapi_enabled', '1');
634
+ wp_localize_script('wplc-admin-js-agent', 'wplc_restapi_token', get_option('wplc_api_secret_token'));
635
+ wp_localize_script('wplc-admin-js-agent', 'wplc_restapi_endpoint', rest_url('wp_live_chat_support/v1'));
636
+ wp_localize_script('wplc-admin-js-agent', 'bleeper_override_upload_url', rest_url('wp_live_chat_support/v1/remote_upload'));
637
+ wp_localize_script('wplc-admin-js-agent', 'wplc_restapi_nonce', wp_create_nonce( 'wp_rest' ));
638
+
639
+ } else {
640
+ wp_localize_script('wplc-admin-js-agent', 'wplc_restapi_enabled', '0');
641
+ wp_localize_script('wplc-admin-js-agent', 'wplc_restapi_nonce', "false");
642
+ }
643
+
644
+ $agent_tagline = apply_filters( "wplc_filter_simple_agent_data_agent_tagline", '', get_current_user_id() );
645
+ $agent_bio = apply_filters( "wplc_filter_simple_agent_data_agent_bio", '', '', get_current_user_id() );
646
+ $social_links = apply_filters( "wplc_filter_simple_agent_data_social_links", '', get_current_user_id() );
647
+ $head_data = array(
648
+ 'tagline' => $agent_tagline,
649
+ 'bio' => $agent_bio,
650
+ 'social' => $social_links
651
+ );
652
+ wp_localize_script( 'wplc-admin-js-agent', 'wplc_head_data', $head_data );
653
+ wp_localize_script( 'wplc-admin-js-agent', 'wplc_user_chat_notification_prefix', __("User received notification:", "wplivechat") );
654
+
655
+ wp_localize_script( 'wplc-admin-js-agent', 'bleeper_valid_direct_to_page_array', wplc_node_pages_posts_array() );
656
+
657
+ if( isset($wplc_settings['wplc_new_chat_ringer_count']) && $wplc_settings['wplc_new_chat_ringer_count'] !== "") {
658
+ $wplc_ringer_count = intval($wplc_settings['wplc_new_chat_ringer_count']);
659
+ wp_localize_script( 'wplc-admin-js-agent', 'bleeper_ringer_count', "" . $wplc_ringer_count );
660
+ }
661
+
662
+
663
+ $wplc_server_location = get_option( "wplc_server_location" );
664
+ $wplc_server_location = apply_filters('wplc_node_server_default_selection_override', $wplc_server_location, $wplc_settings);
665
+
666
+ if( $wplc_server_location !== false && $wplc_server_location !== "" && $wplc_server_location !== "auto" ){
667
+ if ( $wplc_server_location === "us1") { $wplc_server_location = "0"; }
668
+ else if ( $wplc_server_location === "us2") { $wplc_server_location = "3"; }
669
+ else if ( $wplc_server_location === "eu1") { $wplc_server_location = "1"; }
670
+ else if ( $wplc_server_location === "eu2") { $wplc_server_location = "2"; }
671
+ else { $wplc_server_location = "0"; }
672
+ wp_localize_script( 'wplc-admin-js-agent', 'bleeper_server_location', $wplc_server_location );
673
+ }
674
+
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') );
682
+ wp_localize_script( 'wplc-admin-js-agent', 'bleeper_new_chat_notification_text', __("A new chat has been received. Please go the 'Live Chat' page to accept the chat", "wplivechat") );
683
+
684
+ $wplc_notification_icon = plugin_dir_url(dirname(__FILE__)) . 'images/wplc_notification_icon.png';
685
+ wp_localize_script( 'wplc-admin-js-agent', 'bleeper_new_chat_notification_icon', $wplc_notification_icon );
686
+
687
+ do_action("wplc_admin_remoter_dashboard_scripts_localizer"); //For pro localization of agents list, and departments
688
+
689
+ wp_enqueue_script('wplc-admin-js-agent');
690
+
691
+ wp_register_script('wplc-admin-chat-server', plugins_url( '../js/wplc_server.js', __FILE__ ), array("wplc-admin-js-agent", "wplc-admin-js-sockets"), $wplc_version, false); //Added this for async storage calls
692
+ wp_enqueue_script('wplc-admin-chat-server');
693
+
694
+ wp_localize_script( 'wplc-admin-chat-server', 'wplc_datetime_format', array(
695
+ 'date_format' => get_option( 'date_format' ),
696
+ 'time_format' => get_option( 'time_format' ),
697
+ ) );
698
+
699
+ wp_register_script('wplc-admin-chat-events', plugins_url( '../js/wplc_u_admin_events.js', __FILE__ ), array("wplc-admin-js-agent", "wplc-admin-js-sockets", "wplc-admin-chat-server"), $wplc_version, false); //Added this for async storage calls
700
+ wp_enqueue_script('wplc-admin-chat-events');
701
+
702
+ if (isset($wplc_settings['wplc_show_date']) && $wplc_settings["wplc_show_date"] == '1') {
703
+ wp_localize_script('wplc-admin-chat-server', 'wplc_show_date', 'true');
704
+ } else {
705
+ wp_localize_script('wplc-admin-chat-server', 'wplc_show_date', 'false');
706
+ }
707
+
708
+ if (isset($wplc_settings['wplc_show_time']) && $wplc_settings["wplc_show_time"] == '1') {
709
+ wp_localize_script('wplc-admin-chat-server', 'wplc_show_time', 'true');
710
+ } else {
711
+ wp_localize_script('wplc-admin-chat-server', 'wplc_show_time', 'false');
712
+ }
713
+
714
+ if (isset($wplc_settings['wplc_show_name']) && $wplc_settings["wplc_show_name"] == '1') {
715
+ wp_localize_script('wplc-admin-chat-server', 'wplc_show_name', 'true');
716
+ } else {
717
+ wp_localize_script('wplc-admin-chat-server', 'wplc_show_name', 'false');
718
+ }
719
+
720
+ if (isset($wplc_settings['wplc_show_avatar']) && $wplc_settings["wplc_show_avatar"] == '1') {
721
+ wp_localize_script('wplc-admin-chat-server', 'wplc_show_avatar', 'true');
722
+ } else {
723
+ wp_localize_script('wplc-admin-chat-server', 'wplc_show_avatar', 'false');
724
+ }
725
+ }
726
+ }
727
+
728
+ add_action("wplc_admin_remoter_dashboard_scripts_localizer", "wplc_admin_remote_dashboard_localize_upselling_tips");
729
+ /*
730
+ * Localizes an array of upselling tips
731
+ */
732
+ function wplc_admin_remote_dashboard_localize_upselling_tips(){
733
+ $tips_header = __("Did you know?", "wplivechat");
734
+
735
+ $tips_array = array(
736
+ "0" => "<p><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=unlimited_agents_tip' title='".__("Add unlimited agents", "wplivechat")."' target=\"_BLANK\">".__("Add unlimited agents", "wplivechat")."</a> ".__(" with the Pro add-on of WP Live Chat Support","wplivechat")." "."<a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=unlimited_agents_tip2' target='_BLANK'>".__("(once off payment).","wplivechat")."</a></p>",
737
+ "1" => "<p>".__("With the Pro add-on of WP Live Chat Support, you can", "wplivechat")." <a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate_tip' title='".__("see who's online and initiate chats", "wplivechat")."' target=\"_BLANK\">".__("initiate chats", "wplivechat")."</a> ".__("with your online visitors with the click of a button.", "wplivechat")." <br /><br /><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate_tip2' title='".__("Buy the Pro add-on now (once off payment).", "wplivechat")."' target=\"_BLANK\"><strong>".__("Buy the Pro add-on now (once off payment).", "wplivechat")."</strong></a></p>",
738
+ "2" => "<p><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=transfer_tip' title='".__("Transfer Chats", "wplivechat")."' target=\"_BLANK\">".__("Transfer Chats", "wplivechat")."</a> ".__(" with the Pro add-on of WP Live Chat Support","wplivechat")." "."<a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=transfer_tip2' target='_BLANK'>".__("(once off payment).","wplivechat")."</a></p>"
739
+ );
740
+
741
+ $tips_array = apply_filters("wplc_admin_remote_dashboard_localize_tips_array", $tips_array);
742
+
743
+ wp_localize_script( 'wplc-admin-js-agent', 'agent_to_agent_chat_upsell', sprintf(__('Chat to other agents with the <a href="%s" target="_BLANK">Pro version</a>.' ,'wplivechat'),'https://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=a2achat'));
744
+
745
+ $initiate_upsell = "<i class='fa fa-horn'></i> ".__("With the Pro add-on of WP Live Chat Support, you can", "wplivechat");
746
+ $initiate_upsell .= ' <a href="https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate1" title="'.__("see who's online and initiate chats", "wplivechat").'" target=\"_BLANK\">';
747
+ $initiate_upsell .= __("initiate chats", "wplivechat");
748
+ $initiate_upsell .= '</a> '.__("with your online visitors with the click of a button.", "wplivechat");
749
+ $initiate_upsell .= ' <a href="https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate2" title="'.__("Buy the Pro add-on now.", "wplivechat").'" target=\"_BLANK\">';
750
+ $initiate_upsell .= '<strong>'.__("Buy the Pro add-on now.", "wplivechat").'</strong></a>';
751
+
752
+
753
+
754
+ wp_localize_script( 'wplc-admin-js-agent', 'initiate_chat_upsell', $initiate_upsell);
755
+
756
+
757
+ wp_localize_script( 'wplc-admin-js-agent', 'wplc_event_upsell', sprintf( __( 'Get detailed visitor events with the <a target="_BLANK" href="%s">Pro version</a>.', 'wplivechat'), 'https://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=pro_events' ) );
758
+
759
+ wp_localize_script( 'wplc-admin-js-agent', 'wplc_tip_header', $tips_header );
760
+ wp_localize_script( 'wplc-admin-js-agent', 'wplc_tip_array', $tips_array );
761
+
762
+ if (!function_exists("wplc_pro_activate")) {
763
+ /* identify if the user wants to display the agent to agent chat upsell */
764
+ $wplc_current_user = get_current_user_id();
765
+ $check = get_user_meta( $wplc_current_user, "wplc_a2a_upsell" );
766
+ if ($check) {
767
+ wp_localize_script( 'wplc-admin-js-agent', 'wplc_upsell_a2a', '1' );
768
+ }
769
+
770
+ }
771
+
772
+
773
+ }
774
+
775
+ /**
776
+ * Loads remote dashboard styles
777
+ *
778
+ * @return void
779
+ */
780
+ function wplc_admin_remote_dashboard_styles(){
781
+ global $wplc_version;
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) ) {
789
+ wp_add_inline_style( 'wplc-admin-style', ".wplc-user-message, .wplc-admin-message { padding-left: 0 !important; }" );
790
+
791
+ /*
792
+ if(!isset($wplc_settings['wplc_show_name']) || (isset($wplc_settings['wplc_show_name']) && intval($wplc_settings['wplc_show_name']) == 0) ){
793
+ //User is hiding both name and grav - add more inline styles
794
+
795
+ $current_agent_info = wp_get_current_user();
796
+ $current_agent_initial = "A"; //Default
797
+
798
+ if(isset($current_agent_info->display_name)){
799
+ $current_agent_initial = substr($current_agent_info->display_name, 0, 1);
800
+ }
801
+
802
+
803
+ $inline_identity_css =
804
+ "
805
+ .wplc-admin-message .messageBody::before {
806
+ display:inline-block; width: 15px; height: 15px; background:#333; content:'" . $current_agent_initial . "'; color:#fff; margin-right:10px; position:relative; top:px; text-align:center; font-size: 10px; border-radius:3px;
807
+ }
808
+
809
+ .wplc-user-message .messageBody::before {
810
+ display:inline-block; width: 15px; height: 15px; background:#2b97d2; content:'U'; color:#fff; margin-right:10px; position:relative; top:px; text-align:center; font-size: 10px; border-radius:3px;
811
+ }
812
+ ";
813
+
814
+ wp_add_inline_style( 'wplc-admin-style', $inline_identity_css );
815
+ }*/
816
+
817
+
818
+
819
+ } else if( !isset($wplc_settings['wplc_show_name']) || (isset($wplc_settings['wplc_show_name']) && intval($wplc_settings['wplc_show_name']) == 0) ){
820
+ //User has enabled the gravatar, but has chosen to hide the user name.
821
+ //This causes some issues with admin display so let's just add some different styling to get around this
822
+ $inline_identity_css =
823
+ "
824
+ .wplc-admin-message-avatar, .wplc-user-message-avatar {
825
+ max-width:28px !important;
826
+ max-height:28px !important;
827
+ }
828
+
829
+ .wplc-admin-message, .wplc-user-message{
830
+ padding-left:25px !important;
831
+ }
832
+
833
+ .wplc-admin-message::before, .wplc-user-message::before {
834
+ content: ' ';
835
+ width: 7px;
836
+ height: 7px;
837
+ background:#343434;
838
+ position: absolute;
839
+ left: 12px;
840
+ border-radius: 2px;
841
+ z-index: 1;
842
+ }
843
+
844
+ .wplc-user-message::before {
845
+ background:#2b97d2;
846
+ }
847
+ ";
848
+
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
+
861
+ do_action("wplc_admin_remote_dashboard_styles_hook");
862
+ }
863
+
864
+ add_action("wplc_admin_remote_dashboard_above", "wplc_limited_error_output");
865
+ /*
866
+ * Outputs an error for limitations due to API key
867
+ */
868
+ function wplc_limited_error_output(){
869
+ if(function_exists("wplc_pro_activate")){
870
+ echo "<p id='wplc_limited_container' class='update-nag' style='display:none;'>";
871
+ echo "<strong>" . __("Dear Pro User,", "wplivechat") . "</strong><br>";
872
+ echo __("Your API Key could not be validated, some functionality may be limited", "wplivechat");
873
+ echo "</p>";
874
+ }
875
+
876
+ echo "<p id='wplc_agent_invalid_container' class='update-nag' style='display:none;'>";
877
+ echo __("You are not a verified agent, chat dashboard has been disabled", "wplivechat");
878
+ echo "</p>";
879
+ }
880
+
881
+ /*
882
+ * Add action for notice checks
883
+ */
884
+ if ( ! function_exists( "wplc_active_chat_box_notices" ) ) {
885
+ if(isset($_GET['page']) && $_GET['page'] === "wplivechat-menu"){
886
+ add_action( "wplc_admin_remote_dashboard_above", "wplc_active_chat_box_notices" );
887
+ }
888
+ }
889
+
890
+ add_action("wplc_admin_general_node_compat_check", "wplc_node_compat_version_check");
891
+ add_action("wplc_admin_remote_dashboard_above", "wplc_node_compat_version_check", 1);
892
+ /*
893
+ * Checks if current Pro is compatible with node basic, if not, show notice, and localize scripts needed for conflict free execution
894
+ */
895
+ function wplc_node_compat_version_check(){
896
+ global $wplc_pro_version;
897
+ $wplc_ver = str_replace('.', '', $wplc_pro_version);
898
+ $checker = intval($wplc_ver);
899
+ if (function_exists("wplc_pro_version_control") && $checker < 8000) {
900
+ $wpc_ma_js_strings = array(
901
+ 'remove_agent' => __('Remove', 'wplivechat'),
902
+ 'nonce' => wp_create_nonce("wplc"),
903
+ 'user_id' => get_current_user_id(),
904
+ 'typing_string' => __('Typing...', 'wplivechat')
905
+
906
+ );
907
+ wp_localize_script('wplc-admin-js-agent', 'wplc_admin_strings', $wpc_ma_js_strings);
908
+
909
+ if(isset($_GET['page']) && $_GET['page'] === "wplivechat-menu"){
910
+ wp_register_script('wplc-admin-force-offline-js', plugins_url('../js/wplc_node_offline_mode_controller.js', __FILE__), array('jquery'), '', true);
911
+ wp_enqueue_script('wplc-admin-force-offline-js');
912
+ }
913
+
914
+ $is_dashboard = (isset($_GET['page']) && $_GET['page'] === "wplivechat-menu") ? true : false;
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>
922
+ <?php echo wplc_node_compat_pro_update_nag_content(); ?>
923
+ </div>
924
+ </div>
925
+ <?php
926
+ }
927
+ }
928
+
929
+ /*
930
+ * Checks if the users Pro API key is expired - this will only be called if pro is active and is less than V8
931
+ * true -> Show link to my account page
932
+ * false -> Show link to update page
933
+ */
934
+ function wplc_node_compat_pro_update_nag_content(){
935
+ $html_out = "<p id='wplc_offline_mode_reason'>";
936
+
937
+ $is_pro_valid = wplc_node_compat_pro_api_key_is_valid_post();
938
+
939
+ if($is_pro_valid){
940
+ $html_out .= sprintf(__("Chat is now in offline mode, please <a href='%s' target='_BLANK'>upgrade to Version 8</a> (or above) of the WP Live Chat Support Pro Add-on to ensure all functionality works as expected.", "wplivechat"), "update-core.php");
941
+ } else {
942
+ $html_out .= sprintf(__("Chat is now in offline mode, please renew your API key by visiting the <a href='%s' target='_BLANK'>My Account</a> area, and receive updates.", "wplivechat"), "https://wp-livechat.com/my-account");
943
+ }
944
+
945
+ $html_out .= "</p>";
946
+
947
+ $html_out .= "<p>";
948
+ $html_out .= __("Alternatively, please disable the node server option in the Live Chat settings area (Live Chat -> Settings -> Advanced Features)", "wplivechat");
949
+ $html_out .= "</p>";
950
+
951
+ if($is_pro_valid){
952
+ $html_out .= "<a href='update-core.php' class='button button-primary' target='_BLANK'>" . __("Upgrade", "wplivechat") . "</a>";
953
+ } else {
954
+ $html_out .= "<a href='update-core.php' class='button button-primary' target='_BLANK'>" . __("Renew License", "wplivechat") . "</a>";
955
+ }
956
+
957
+ if(!isset($_GET['page']) || $_GET['page'] !== "wplivechat-menu-settings"){
958
+ $html_out .= " <a href='?page=wplivechat-menu-settings#tabs-beta' class='button' target='_BLANK'>" . __("Settings", "wplivechat") . "</a>";
959
+ }
960
+
961
+ $html_out .= " <a href='?page=wplivechat-menu&action=welcome' class='button' target='_BLANK'>" . __("Whats new in Version 8", "wplivechat") . "</a>";
962
+
963
+ return $html_out;
964
+
965
+ }
966
+
967
+ /*
968
+ * Checks if the Pro API key is valid or not
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
976
+ if (get_option($wplc_pro_option_key)) {
977
+ $args = array(
978
+ 'slug' => $wplc_pro_slug,
979
+ );
980
+ $data_array = array(
981
+ 'method' => 'POST',
982
+ 'body' => array(
983
+ 'action' => 'api_validation',
984
+ 'd' => get_option('siteurl'),
985
+ 'request' => serialize($args),
986
+ 'api_key' => get_option($wplc_pro_option_key)
987
+ ));
988
+ $response = wp_remote_post($wplc_pro_validation_url, $data_array);
989
+ if (is_array($response)) {
990
+ if ( $response['response']['code'] == "200" ) {
991
+ $data = $response['body'];
992
+ $data = unserialize($data);
993
+
994
+ if(isset($data['status']) && $data['status'] === "OK"){
995
+ $is_valid = true;
996
+ }
997
+ }
998
+ }
999
+
1000
+ }
1001
+
1002
+ return $is_valid;
1003
+ }
1004
+
1005
+ add_filter("wplc_loggedin_filter","wplc_node_compat_version_disable_chat",99,1);
1006
+ /*
1007
+ * Checks if user is using out-date pro with node server, if so, disable chat on front end
1008
+ */
1009
+ function wplc_node_compat_version_disable_chat($logged_in) {
1010
+ global $wplc_pro_version;
1011
+ $wplc_settings = get_option("WPLC_SETTINGS");
1012
+ if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
1013
+ $wplc_ver = str_replace('.', '', $wplc_pro_version);
1014
+ $checker = intval($wplc_ver);
1015
+ if (function_exists("wplc_pro_version_control") && $checker < 8000) {
1016
+ return false; //Force chat offline
1017
+ }
1018
+ }
1019
+ return $logged_in;
1020
+ }
1021
+
1022
+ add_action("admin_notices", "wplc_node_v8_plus_notice_dismissable");
1023
+ /*
1024
+ * Displays an admin notice (which can be dismissed), to notify any V8+ users of the node option (if not already checked)
1025
+ */
1026
+ function wplc_node_v8_plus_notice_dismissable(){
1027
+ if(isset($_GET['page']) && strpos($_GET['page'], 'wplivechat') !== FALSE){
1028
+ if(isset($_GET['wplc_dismiss_notice_v8']) && $_GET['wplc_dismiss_notice_v8'] === "true"){
1029
+ update_option("wplc_node_v8_plus_notice_dismissed", 'true');
1030
+ }
1031
+
1032
+ $wplc_settings = get_option("WPLC_SETTINGS");
1033
+ if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
1034
+ //Do Nothing
1035
+ } else {
1036
+ //User is not on node, let's check if they have seen this notice before, if not, let's show a notice
1037
+ $wplc_has_notice_been_dismissed = get_option("wplc_node_v8_plus_notice_dismissed", false);
1038
+ if($wplc_has_notice_been_dismissed === false){
1039
+ //Has not been dismissed
1040
+ $output = "<div class='notice notice-warning' style='border-color: #0180bc;'>";
1041
+ $output .= "<p><strong>" . __( 'Welcome to V8 of WP Live Chat Support', 'wplivechat' ) . "</strong></p>";
1042
+ $output .= "<p>" . __('Did you know, this version features high speed message delivery, agent to agent chat, and a single window layout?', 'wplivechat') . "</p>";
1043
+ $output .= "<p>" . __('To activate this functionality please navigate to Live Chat -> Settings -> Advanced Features -> And enable our Chat Server option.', 'wplivechat') . "</p>";
1044
+
1045
+ $output .= "<p>";
1046
+ $output .= "<a href='?page=wplivechat-menu-settings#tabs-beta' class='button button-primary'>" . __("Show me!", "wplivechat") . "</a> ";
1047
+ $output .= "<a href='?page=".$_GET['page']."&wplc_dismiss_notice_v8=true' id='wplc_v8_dismiss_node_notice' class='button'>" . __("Don't Show This Again", "wplivechat") . "</a>";
1048
+ $output .= "</p>";
1049
+
1050
+ $output .= "</div>";
1051
+
1052
+ echo $output;
1053
+ }
1054
+ }
1055
+ }
1056
+ }
1057
+
1058
+ add_filter("wplc_activate_default_settings_array", "wplc_node_set_default_settings", 10, 1);
1059
+ /*
1060
+ * Adds default node setting to the default settings array
1061
+ */
1062
+ function wplc_node_set_default_settings($wplc_default_settings_array){
1063
+ if(is_array($wplc_default_settings_array)){
1064
+ if(!isset($wplc_default_settings_array['wplc_use_node_server'])){
1065
+ //Is not set already
1066
+ $wplc_default_settings_array['wplc_use_node_server'] = 1;
1067
+ }
1068
+ }
1069
+ return $wplc_default_settings_array;
1070
+ }
1071
+
1072
+ add_filter( 'rest_url', 'wplc_node_rest_url_ssl_fix');
1073
+ /**
1074
+ * Changes the REST URL to include the SSL version if we are using SSL
1075
+ * See https://core.trac.wordpress.org/ticket/36451
1076
+ */
1077
+ function wplc_node_rest_url_ssl_fix($url){
1078
+ if (is_ssl()){
1079
+ $url = set_url_scheme( $url, 'https' );
1080
+ return $url;
1081
+ }
1082
+ return $url;
1083
+ }
1084
+
1085
+ /**
1086
+ * Returns an array of pages/posts available on the site
1087
+ */
1088
+ function wplc_node_pages_posts_array(){
1089
+ $r = array(
1090
+ 'depth' => 0,
1091
+ 'child_of' => 0,
1092
+ 'echo' => false,
1093
+ 'id' => '',
1094
+ 'class' => '',
1095
+ 'show_option_none' => '',
1096
+ 'show_option_no_change' => '',
1097
+ 'option_none_value' => '',
1098
+ 'value_field' => 'ID',
1099
+ );
1100
+
1101
+ $pages = get_pages($r);
1102
+ $posts = get_posts(array('posts_per_page' => -1));
1103
+
1104
+ $posts_pages = array_merge($pages,$posts);
1105
+
1106
+ $return_array = array();
1107
+
1108
+ foreach ($posts_pages as $key => $value) {
1109
+ $post_page_id = $value->ID;
1110
+ $post_page_title = $value->post_title;
1111
+
1112
+ $return_array[get_permalink($post_page_id)] = $post_page_title;
1113
+ }
1114
+
1115
+ return $return_array;
1116
+ }
1117
+
1118
+
1119
+
1120
+ add_action("init","wplc_node_cloud_server_integration_hook_handler");
1121
+ /**
1122
+ * V8 Cloud Action & Filter Handlers
1123
+ */
1124
+ function wplc_node_cloud_server_integration_hook_handler() {
1125
+ $wplc_settings = get_option("WPLC_SETTINGS");
1126
+ if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
1127
+ if(function_exists("wplc_cloud_load_updates")){
1128
+ remove_action("init","wplc_cloud_load_updates");
1129
+ remove_action("wplc_hook_chat_dashboard_above","wplc_cloud_1_hook_chat_dashboard_above");
1130
+ remove_action("wplc_hook_admin_chatbox_javascript","wplc_cloud_hook_control_push_js_to_admin", 10);
1131
+ remove_action("wplc_hook_push_js_to_front","wplc_cloud_hook_control_push_js_to_front", 10);
1132
+ remove_action("wplc_hook_chat_history","wplc_cloud_hook_control_chat_history", 1);
1133
+ remove_action("wplc_hook_chat_missed","wplc_cloud_hook_control_chat_missed", 1);
1134
+ remove_action("wplc_hook_initiate_check","wplc_cloud_hook_control_intiate_check", 1);
1135
+ remove_action("wplc_hook_history_draw_area","wplc_cloud_hook_control_history_draw_area", 1);
1136
+ remove_action("wplc_hook_change_status_on_answer","wplc_cloud_hook_control_change_status_on_answer", 1);
1137
+ remove_action("wplc_hook_update_agent_id","wplc_cloud_hook_control_update_agent_id", 1);
1138
+ remove_action('wplc_hook_accept_chat_url' , 'wplc_cloud_hook_control_accept_chat_url', 1);
1139
+ remove_action("wplc_hook_ma_check_if_answered_by_another_agent","wplc_cloud_hook_check_if_answered_by_another_agent", 1);
1140
+ remove_action("wplc_hook_settings_page_more_tabs","wplc_cloud_hook_control_settings_page_more_tabs");
1141
+ remove_action("init","wplc_cloud_first_run_check");
1142
+ remove_action('wplc_hook_admin_settings_save','wplc_cloud_save_settings');
1143
+ remove_action("wplc_api_route_hook", "wplc_api_node_routes_cloud", 1);
1144
+ remove_action('http_api_curl', 'wplc_cloud_http_api_curl', 100);
1145
+ remove_action("init", "wplc_cloud_additional_hooks", 1);
1146
+
1147
+ remove_filter("wplc_filter_get_chat_messages","wplc_cloud_filter_control_chat_messages",10);
1148
+ remove_filter("wplc_filter_get_chat_data","wplc_cloud_filter_control_chat_data",1);
1149
+ remove_filter("wplc_filter_chat_area_data","wplc_cloud_filter_control_chat_area_data",10);
1150
+ remove_filter("wplc_rating_data_filter","wplc_cloud_filter_control_get_rating_data",1);
1151
+ remove_filter("wplc_filter_admin_javascript","wplc_cloud_filter_control_admin_javascript");
1152
+ remove_filter("wplc_start_chat_user_form_after_filter", "wplc_start_chat_user_form_after_filter_remove_departments_cloud",2);
1153
+ remove_filter("wplc_after_chat_visitor_count_hook", "wplc_admin_cloud_remove_departments_chat_area_before_end_chat_button",2);
1154
+ remove_filter("wplc_admin_chat_area_before_end_chat_button", "wplc_admin_cloud_remove_transfer_button_chat_area_before_end_chat_button",2);
1155
+ remove_filter("wplc_filter_front_js_extra_data","wplc_cloud_filter_control_front_js_extra_data",10);
1156
+ remove_filter("wplc_filter_ajax_url","wplc_cloud_filter_control_ajax_url",10);
1157
+ remove_filter("wplc_filter_setting_tabs","wplc_cloud_filter_control_setting_tabs");
1158
+ remove_filter("wplc_filter_menu_api","wplc_cloud_filter_control_menu_api",1);
1159
+ remove_filter('http_request_args', 'wplc_cloud_http_request_args',100);
1160
+ }
1161
+ }
1162
+ }
1163
+
1164
+ add_action("init","wplc_node_mobile_integration_hook_handler");
1165
+ /**
1166
+ * V8 Mobile/Desktop Extension Action & Filter Handlers
1167
+ */
1168
+ function wplc_node_mobile_integration_hook_handler() {
1169
+ $wplc_settings = get_option("WPLC_SETTINGS");
1170
+ if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
1171
+ if(function_exists("wplc_md_load_updates")){
1172
+ remove_action("init","wplc_md_load_updates");
1173
+ remove_action("wplc_hook_settings_page_more_tabs","wplc_mobile_hook_control_settings_page_more_tabs");
1174
+ remove_action("init","wplc_mobile_first_run_check");
1175
+ remove_action('wplc_hook_admin_settings_save','wplc_mobile_save_settings');
1176
+
1177
+ remove_filter("wplc_filter_is_admin_logged_in","wplc_mobile_check_if_logged_in",10);
1178
+ remove_filter("wplc_filter_setting_tabs","wplc_mobile_filter_control_setting_tabs");
1179
+ remove_filter("wplc_filter_menu_api","wplc_mobile_filter_control_menu_api");
1180
+ }
1181
+ }
1182
+ }
1183
+
1184
+
1185
+ add_action("wplc_admin_remoter_dashboard_scripts_localizer", "wplc_admin_remote_dashboard_dynamic_translation_handler");
1186
+ /*
1187
+ * Localizes an array of strings and ids in the dashboard which need to be replaced
1188
+ * Loads the custom JS file responsible for replacing the content dynamically.
1189
+ */
1190
+ function wplc_admin_remote_dashboard_dynamic_translation_handler(){
1191
+
1192
+ global $wplc_version;
1193
+ wp_register_script('wplc-admin-dynamic-translation', plugins_url( '../js/wplc_admin_dynamic_translations.js', __FILE__ ), array("wplc-admin-js-agent", "wplc-admin-js-sockets", "jquery"), $wplc_version, false); //Added this for async storage calls
1194
+
1195
+ $wplc_dynamic_translation_array = array(
1196
+ 'nifty_bg_holder_text_inner' => __('Connecting...', 'wplivechat'),
1197
+ 'nifty_admin_chat_prompt_title' => __('Please Confirm', 'wplivechat'),
1198
+ 'nifty_admin_chat_prompt_confirm' => __('Confirm', 'wplivechat'),
1199
+ 'nifty_admin_chat_prompt_cancel' => __('Cancel', 'wplivechat'),
1200
+ 'active_count_string' => __(' Active visitors', 'wplivechat'),
1201
+ 'wplc-agent-info' => __('Agent(s) Online', 'wplivechat'),
1202
+ 'wplc_history_link' => __('Chat History', 'wplivechat'),
1203
+ 'nifty_agent_heading' => __('Agents', 'wplivechat'),
1204
+ 'drag_zone_inner_text' => __('Drag Files Here', 'wplivechat'),
1205
+ 'chatTransferLink' => __('Transfer', 'wplivechat'),
1206
+ 'chatTransferDepLink' => __('Department Transfer', 'wplivechat'),
1207
+ 'chatDirectUserToPageLink' => __('Direct User To Page', 'wplivechat'),
1208
+ 'chatCloseTitle' => __('Leave chat', 'wplivechat'),
1209
+ 'chatEndTitle' => __('End chat', 'wplivechat'),
1210
+ 'chatTransferUps' => __('Transfer', 'wplivechat'),
1211
+ 'chatDirectUserToPageUps' => __('Direct User To Page', 'wplivechat'),
1212
+ 'nifty_event_heading' => __('Events', 'wplivechat'),
1213
+ 'nifty_join_chat_button' => __('Join chat', 'wplivechat'),
1214
+ 'nifty_filter_button' => __('Filters', 'wplivechat'),
1215
+ 'nifty_new_visitor_item' => __('New Visitors (3 Min)', 'wplivechat'),
1216
+ 'nifty_active_chats_item' => __('Active Chats', 'wplivechat'),
1217
+ 'nifty_clear_filters_item' => __('Clear Filters', 'wplivechat'),
1218
+ 'nifty_active_chats_heading' => __('Active visitors', 'wplivechat'),
1219
+ 'nifty_vis_col_heading' => __('Visitor', 'wplivechat'),
1220
+ 'nifty_vis_info_heading' => __('Info', 'wplivechat'),
1221
+ 'nifty_vis_page_heading' => __('Page', 'wplivechat'),
1222
+ 'nifty_vis_status_heading' => __('Chat Status', 'wplivechat'),
1223
+ 'nifty_vis_dep_heading' => __('Department', 'wplivechat'),
1224
+ 'wdt-emoji-search-result-title' => __('Search Results', 'wplivechat'),
1225
+ 'wdt-emoji-no-result' => __('No emoji found', 'wplivechat')
1226
+ );
1227
+
1228
+ apply_filters("wplc_adming_dynamic_translation_filter", $wplc_dynamic_translation_array);
1229
+
1230
+
1231
+ wp_localize_script('wplc-admin-dynamic-translation', 'wplc_dynamic_translation_array', $wplc_dynamic_translation_array);
1232
+ wp_enqueue_script('wplc-admin-dynamic-translation');
1233
+
1234
  }
readme.txt CHANGED
@@ -1,4 +1,4 @@
1
- === WP Live Chat Support ===
2
  Contributors: WP-LiveChat, NickDuncan, CodeCabin_, dylanauty
3
  Donate link: http://www.wp-livechat.com
4
  Tags: live chat, live support, chat plugin, live help, wordpress live chat, chat, live chat plugin, live support plugin, live chat support plugin, chat plugin, support plugin, live help
@@ -258,12 +258,21 @@ We have patched the PHPMailer vulnerability. Please update to version 7.0.02.
258
 
259
 
260
  == Changelog ==
 
 
 
 
 
261
 
262
  = 8.0.22 - 2019-02-04 - Low priority =
263
- * Introduced a new dashboard that showcases latest blog posts, the latest podcast episode and the system status
264
- * Moved GDPR warnings for first time users to the settings page only
 
 
 
265
  * Moved the warning regarding desktop notifications to the settings page only
266
 
 
267
  = 8.0.21 - 2018-12-18 - Low priority =
268
  * Readme Update: Coming soon features
269
  * Readme Update: Features list
1
+ === WP Live Chat Support ===
2
  Contributors: WP-LiveChat, NickDuncan, CodeCabin_, dylanauty
3
  Donate link: http://www.wp-livechat.com
4
  Tags: live chat, live support, chat plugin, live help, wordpress live chat, chat, live chat plugin, live support plugin, live chat support plugin, chat plugin, support plugin, live help
258
 
259
 
260
  == Changelog ==
261
+ = 8.0.23 - 2019-02-05 - Low priority =
262
+
263
+ * Fixed access to new dashboard for non admin agents
264
+ * Fixed documentation suggestions not working (Pro)
265
+
266
 
267
  = 8.0.22 - 2019-02-04 - Low priority =
268
+
269
+ * Introduced a new dashboard that showcases latest blog posts, the latest podcast episode and the system status
270
+
271
+ * Moved GDPR warnings for first time users to the settings page only
272
+
273
  * Moved the warning regarding desktop notifications to the settings page only
274
 
275
+
276
  = 8.0.21 - 2018-12-18 - Low priority =
277
  * Readme Update: Coming soon features
278
  * Readme Update: Features list
wp-live-chat-support.php CHANGED
@@ -1,6471 +1,6485 @@
1
- <?php
2
- /*
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.22
7
- Author: WP-LiveChat
8
- Author URI: http://www.wp-livechat.com
9
- Text Domain: wplivechat
10
- Domain Path: /languages
11
- */
12
-
13
- /**
14
- * 8.0.22 - 2019-02-04 - Low priority
15
- * Introduced a new dashboard that showcases latest blog posts, the latest podcast episode and the system status
16
- * Moved GDPR warnings for first time users to the settings page only
17
- * Moved the warning regarding desktop notifications to the settings page only
18
- *
19
- * 8.0.21 - 2018-12-18 - Low priority
20
- * Readme Update: Coming soon features
21
- * Readme Update: Features list
22
- * Tested on WordPress 5.0.1
23
- * Updated ZH_CN translation files. Thanks to Air
24
- *
25
- * 8.0.20 - 2018-11-29 - Medium priority
26
- * Fixed issue where relay server requests were made via a shortpoll. (Performance Update)
27
- * Re-enabled automatic server location selection for new insttalations
28
- * GDPR Compliance is now disabled by default for new installations
29
- *
30
- * 8.0.19 - 2018-11-19 - Medium priority
31
- * Tested on WordPress 5 Beta
32
- * Tested Basic Gutenberg Block Support
33
- *
34
- * 8.0.18 - 2018-11-01 - High Priority
35
- * Fixed XSS vulnerability within the GDPR search system (Thanks to Tim Coen)
36
- * Fixed Self-XSS vulnerability within the message input field on both dashboard and chat box (Thanks to Tim Coen)
37
- *
38
- * 8.0.17 - 2018-10-19 - Low priority
39
- * Removes WP User Avatar option from settings page. This was incorrectly included in the last release.
40
- *
41
- * 8.0.16 - 2018-10-18 - Low priority
42
- * Fixed undefined 'wplc_user_avatars' not defined error on frontend
43
- *
44
- * 8.0.15 - 2018-10-11 - High priority
45
- * Added WP User Avatar integration
46
- * Added jQuery 3 compatibility as per WordPress.org guidelines
47
- * Added auto hide of chat ended prompt on close or restart
48
- * Fixed a possible injection issue within the notification control (Thanks to Nico from https://serhack.me)
49
- * Fixed Gutenberg and Yoast compatibility issue
50
- * Fixed minor issue with rest storage module
51
- * Fixed minor styling issue with popup dashbaord
52
- * Fixed some core issues which influenced custom fields (Pro)
53
- * Fixed issue with Android Browser image missing in dashboard
54
- * Fixed delete chat history not deleting messages
55
- * Fixed nonce checking for non-logged in users failing on cached pages for AJAX and WP API
56
- * Updated NL translation with GDPR strings (Google Translate)
57
- * Updated EL translation files. Thanks to Ioannis Barkouzos
58
- * Updated FR translation files. Thanks to Freitas Junior
59
- * Updated IT translation files. Thanks to Carlo Piazzano
60
- * Updated AR translation files.
61
- *
62
- * 8.0.14 - 2018-07-19 - Low priority
63
- * Removed 'let' from wplc_server.js file (Adds Safari compatibility)
64
- * Fixed issues with Google Analytics integration when using our servers
65
- * Fixed issues with chat box styling with classic theme and GDPR module enabled
66
- * Fixed issues with Contact From Ready integration styling with modern theme
67
- * Fixed issues with Slack integration extension
68
- * Bulgarian Translation Added (Thank you Emil Genchev!)
69
- * Fixed erroneous display of set_time_limit and safe_mode warnings
70
- * Fixed a big that lead to the deletion of sessions and not messages when a chat was marked for deletion
71
- * Improved security in the chat history code
72
- * Added better styling support for smaller width devices (<500px)
73
- * Updated Swedish translation files
74
- * Added Arabic translation files
75
- * Fixed the duplicate message history loading in the history area
76
- * Fixed core framework issues with Voice Note system
77
- * Fixed an issue where invalid query selectors would break the 'Open chat via' functionality
78
- * Fixed an issue with username encoding
79
- * Fixed issue with surveys showing after chat end
80
- * Fixed an issue with classic theme display when anchored to left/right positions
81
- * Added auto transcript mailing to frontend end chat button, and REST API
82
- * Added an 'incomplete' class when GDPR checkbox is not ticket, to draw attention to this input field
83
- * Tested Multi-Site compatibility
84
- * Updated all PO/MO files with updated sources
85
- * Added default GDPR translations for DE, FR, ES, and IT languages (Using Google Translate)
86
- *
87
- * 8.0.13 - 2018-06-06 - Medium priority
88
- * Fix chat delay not working for first visit and offline
89
- * Optimize images
90
- * Mootools compatibility
91
- * Fix new chat request email notifications when Pro is active
92
- *
93
- * 8.0.12 - 2018-05-29 - High priority
94
- * Fixed a bug which caused the chat box not to display on some sites
95
- * Fixed minor styling issues
96
- *
97
- * 8.0.11 - 2018-05-28 - High priority
98
- * Fixed a bug that caused a fatal error on PHP 5.3 and below
99
- */
100
-
101
- //error_reporting(E_ERROR);
102
- global $wplc_version;
103
- global $wplc_p_version;
104
- global $wplc_tblname;
105
- global $wpdb;
106
- global $wplc_tblname_chats;
107
- global $wplc_tblname_msgs;
108
- global $wplc_tblname_offline_msgs;
109
-
110
- /**
111
- * This stores the admin chat data once so that we do not need to keep sourcing it via the WP DB or Cloud DB
112
- */
113
- global $admin_chat_data;
114
- $admin_chat_data = false;
115
-
116
- global $debug_start;
117
-
118
- $wplc_tblname_offline_msgs = $wpdb->prefix . "wplc_offline_messages";
119
- $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
120
- $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
121
- $wplc_version = "8.0.22";
122
-
123
- define('WPLC_BASIC_PLUGIN_DIR', dirname(__FILE__));
124
- define('WPLC_BASIC_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
125
- define('WPLC_PLUGIN', plugin_basename( __FILE__ ) );
126
- global $wplc_basic_plugin_url;
127
- $wplc_basic_plugin_url = WPLC_BASIC_PLUGIN_URL;
128
-
129
-
130
- global $wplc_pro_version;
131
- $wplc_ver = str_replace('.', '', $wplc_pro_version);
132
- $checker = intval($wplc_ver);
133
- if (function_exists("wplc_pro_version_control") && $checker < 6000) { } else {
134
- require_once (plugin_dir_path(__FILE__) . "ajax_new.php");
135
- }
136
-
137
- require_once (plugin_dir_path(__FILE__) . "functions.php");
138
- require_once (plugin_dir_path(__FILE__) . "includes/deprecated.php");
139
- require_once (plugin_dir_path(__FILE__) . "includes/surveys.php");
140
- require_once (plugin_dir_path(__FILE__) . "includes/notification_control.php");
141
- require_once (plugin_dir_path(__FILE__) . "includes/modal_control.php");
142
- require_once (plugin_dir_path(__FILE__) . "modules/documentation_suggestions.php");
143
- require_once (plugin_dir_path(__FILE__) . "modules/offline_messages_custom_fields.php");
144
- require_once (plugin_dir_path(__FILE__) . "modules/google_analytics.php");
145
- require_once (plugin_dir_path(__FILE__) . "modules/api/wplc-api.php");
146
- require_once (plugin_dir_path(__FILE__) . "modules/beta_features.php");
147
- require_once (plugin_dir_path(__FILE__) . "modules/node_server.php");
148
- require_once (plugin_dir_path(__FILE__) . "modules/module_gif.php");
149
- require_once (plugin_dir_path(__FILE__) . "includes/update_control.class.php");
150
- require_once (plugin_dir_path(__FILE__) . "modules/webhooks_manager.php");
151
- require_once (plugin_dir_path(__FILE__) . "modules/privacy.php");
152
-
153
- // Gutenberg Blocks
154
- require_once (plugin_dir_path(__FILE__) . "includes/blocks/wplc-chat-box/index.php");
155
- require_once (plugin_dir_path(__FILE__) . "includes/blocks/wplc-inline-chat-box/index.php");
156
-
157
- // Shortcodes
158
- require_once (plugin_dir_path(__FILE__) . "includes/shortcodes.php");
159
-
160
- add_action( 'wp_ajax_wplc_admin_set_transient', 'wplc_action_callback' );
161
- add_action( 'wp_ajax_wplc_admin_remove_transient', 'wplc_action_callback' );
162
- add_action( 'wp_ajax_wplc_hide_ftt', 'wplc_action_callback' );
163
- add_action( 'wp_ajax_nopriv_wplc_user_send_offline_message', 'wplc_action_callback' );
164
- add_action( 'wp_ajax_wplc_user_send_offline_message', 'wplc_action_callback' );
165
- add_action( 'wp_ajax_delete_offline_message', 'wplc_action_callback' );
166
- add_action( 'wp_ajax_wplc_a2a_dismiss', 'wplc_action_callback' );
167
- add_action( 'init', 'wplc_version_control' );
168
- add_action( "activated_plugin", "wplc_redirect_on_activate" );
169
- add_action( 'wp_footer', 'wplc_display_box' );
170
- add_action( 'init', 'wplc_init' );
171
-
172
-
173
-
174
- if (function_exists('wplc_head_pro')) {
175
- add_action('admin_init', 'wplc_head_pro');
176
- } else {
177
- add_action('admin_init', 'wplc_head_basic');
178
- }
179
-
180
- add_action('wp_enqueue_scripts', 'wplc_add_user_stylesheet');
181
- add_action('admin_enqueue_scripts', 'wplc_add_admin_stylesheet');
182
-
183
- if (function_exists('wplc_admin_menu_pro')) {
184
- add_action('admin_menu', 'wplc_admin_menu_pro');
185
- } else {
186
- add_action('admin_menu', 'wplc_admin_menu', 4);
187
- }
188
- add_action('admin_head', 'wplc_superadmin_javascript');
189
- register_activation_hook(__FILE__, 'wplc_activate');
190
-
191
-
192
- function wplc_basic_check() {
193
- // check if basic exists if pro is installed
194
- }
195
-
196
- function wplc_init() {
197
- $plugin_dir = basename(dirname(__FILE__)) . "/languages/";
198
- load_plugin_textdomain('wplivechat', false, $plugin_dir);
199
-
200
-
201
- }
202
-
203
-
204
- /**
205
- * Redirect the user to the welcome page on plugin activate
206
- * @param string $plugin
207
- * @return void
208
- */
209
- function wplc_redirect_on_activate( $plugin ) {
210
-
211
- if( $plugin == plugin_basename( __FILE__ ) ) {
212
- if (get_option("WPLC_V8_FIRST_TIME") == true) {
213
- update_option("WPLC_V8_FIRST_TIME",false);
214
- // clean the output header and redirect the user
215
- @ob_flush();
216
- @ob_end_flush();
217
- @ob_end_clean();
218
- exit( wp_redirect( admin_url( 'admin.php?page=wplivechat-menu&action=welcome' ) ) );
219
- }
220
- }
221
- }
222
-
223
-
224
- add_action( 'admin_init', 'wplc_redirect_on_activate' );
225
-
226
-
227
-
228
- function wplc_version_control() {
229
-
230
- global $wplc_version;
231
-
232
-
233
- $current_version = get_option("wplc_current_version");
234
- if (!isset($current_version) || $current_version != $wplc_version) {
235
-
236
- $wplc_settings = get_option( 'WPLC_SETTINGS' );
237
-
238
- /**
239
- * Are we updating from a version before version 8?
240
- * If yes, set NODE to enabled
241
- */
242
- if ( isset( $current_version ) ) {
243
- $main_ver = intval( $current_version[0] );
244
- if ( $main_ver < 8 ) {
245
- if ( $wplc_settings ) {
246
- $wplc_settings['wplc_use_node_server'] = 1;
247
-
248
- update_option( "WPLC_V8_FIRST_TIME", true );
249
-
250
- }
251
- }
252
-
253
- }
254
-
255
-
256
- $admins = get_role('administrator');
257
- if( $admins !== null ) {
258
- $admins->add_cap('wplc_ma_agent');
259
- }
260
-
261
- $uid = get_current_user_id();
262
- update_user_meta($uid, 'wplc_ma_agent', 1);
263
- update_user_meta($uid, "wplc_chat_agent_online", time());
264
-
265
- /*$wplc_super_admins = get_super_admins();
266
-
267
- foreach( $wplc_super_admins as $super_admin ){
268
-
269
- $user = get_user_by( 'login', $super_admin );
270
-
271
- $wplc_super_admin_id = $user->ID;
272
-
273
- update_user_meta( $wplc_super_admin_id, 'wplc_ma_agent', 1);
274
- update_user_meta( $wplc_super_admin_id, "wplc_chat_agent_online", time());
275
-
276
- break;
277
-
278
- }
279
- */
280
-
281
-
282
- /* add caps to admin */
283
- if (current_user_can('manage_options')) {
284
- global $user_ID;
285
- $user = new WP_User($user_ID);
286
- foreach ($user->roles as $urole) {
287
- if ($urole == "administrator") {
288
- $admins = get_role('administrator');
289
- $admins->add_cap('edit_wplc_quick_response');
290
- $admins->add_cap('edit_wplc_quick_response');
291
- $admins->add_cap('edit_other_wplc_quick_response');
292
- $admins->add_cap('publish_wplc_quick_response');
293
- $admins->add_cap('read_wplc_quick_response');
294
- $admins->add_cap('read_private_wplc_quick_response');
295
- $admins->add_cap('delete_wplc_quick_response');
296
- }
297
- }
298
- }
299
-
300
-
301
-
302
- if (!isset($wplc_settings['wplc_pro_na'])) { $wplc_settings["wplc_pro_na"] = __("Chat offline. Leave a message", "wplivechat"); }
303
- if (!isset($wplc_settings['wplc_pro_intro'])) { $wplc_settings["wplc_pro_intro"] = __("Hello. Please input your details so that I may help you.", "wplivechat"); }
304
- if (!isset($wplc_settings['wplc_pro_offline1'])) { $wplc_settings["wplc_pro_offline1"] = __("We are currently offline. Please leave a message and we'll get back to you shortly.", "wplivechat"); }
305
- if (!isset($wplc_settings['wplc_pro_offline2'])) { $wplc_settings["wplc_pro_offline2"] = __("Sending message...", "wplivechat"); }
306
- if (!isset($wplc_settings['wplc_pro_offline3'])) { $wplc_settings["wplc_pro_offline3"] = __("Thank you for your message. We will be in contact soon.", "wplivechat"); }
307
- if (!isset($wplc_settings['wplc_pro_offline_btn']) || (isset($wplc_settings['wplc_pro_offline_btn']) && $wplc_settings['wplc_pro_offline_btn'] == "")) { $wplc_settings["wplc_pro_offline_btn"] = __("Leave a message", "wplivechat"); }
308
- if (!isset($wplc_settings['wplc_pro_offline_btn_send']) || (isset($wplc_settings['wplc_pro_offline_btn_send']) && $wplc_settings['wplc_pro_offline_btn_send'] == "")) { $wplc_settings["wplc_pro_offline_btn_send"] = __("Send message", "wplivechat"); }
309
- if (!isset($wplc_settings['wplc_pro_fst1'])) { $wplc_settings["wplc_pro_fst1"] = __("Questions?", "wplivechat"); }
310
- if (!isset($wplc_settings['wplc_pro_fst2'])) { $wplc_settings["wplc_pro_fst2"] = __("Chat with us", "wplivechat"); }
311
- if (!isset($wplc_settings['wplc_pro_fst3'])) { $wplc_settings["wplc_pro_fst3"] = __("Start live chat", "wplivechat"); }
312
- if (!isset($wplc_settings['wplc_pro_sst1'])) { $wplc_settings["wplc_pro_sst1"] = __("Start Chat", "wplivechat"); }
313
- if (!isset($wplc_settings['wplc_pro_sst1_survey'])) { $wplc_settings["wplc_pro_sst1_survey"] = __("Or chat to an agent now", "wplivechat"); }
314
- if (!isset($wplc_settings['wplc_pro_sst1e_survey'])) { $wplc_settings["wplc_pro_sst1e_survey"] = __("Chat ended", "wplivechat"); }
315
- if (!isset($wplc_settings['wplc_pro_sst2'])) { $wplc_settings["wplc_pro_sst2"] = __("Connecting. Please be patient...", "wplivechat"); }
316
- if (!isset($wplc_settings['wplc_pro_tst1'])) { $wplc_settings["wplc_pro_tst1"] = __("Reactivating your previous chat...", "wplivechat"); }
317
- if (!isset($wplc_settings['wplc_user_welcome_chat'])) { $wplc_settings["wplc_user_welcome_chat"] = __("Welcome. How may I help you?", "wplivechat"); }
318
- if (!isset($wplc_settings['wplc_welcome_msg'])) { $wplc_settings['wplc_welcome_msg'] = __("Please standby for an agent. While you wait for the agent you may type your message.","wplivechat"); }
319
- if (!isset($wplc_settings['wplc_user_enter'])) { $wplc_settings["wplc_user_enter"] = __("Press ENTER to send your message", "wplivechat"); }
320
- if (!isset($wplc_settings['wplc_close_btn_text'])) { $wplc_settings["wplc_close_btn_text"] = __("close", "wplivechat"); }
321
-
322
-
323
- if (!isset($wplc_settings['wplc_powered_by_link'])) { $wplc_settings["wplc_powered_by_link"] = "0"; }
324
-
325
-
326
-
327
- /* users who are updating will stay on the existing theme */
328
- if (get_option("WPLC_V8_FIRST_TIME")) {} else {
329
- if (!isset($wplc_settings['wplc_newtheme'])) { $wplc_settings["wplc_newtheme"] = "theme-2"; }
330
- }
331
-
332
-
333
- if (!isset($wplc_settings['wplc_settings_color1'])) { $wplc_settings["wplc_settings_color1"] = "ED832F"; }
334
- if (!isset($wplc_settings['wplc_settings_color2'])) { $wplc_settings["wplc_settings_color2"] = "FFFFFF"; }
335
- if (!isset($wplc_settings['wplc_settings_color3'])) { $wplc_settings["wplc_settings_color3"] = "EEEEEE"; }
336
- if (!isset($wplc_settings['wplc_settings_color4'])) { $wplc_settings["wplc_settings_color4"] = "666666"; }
337
-
338
-
339
-
340
- if (!isset($wplc_settings['wplc_settings_align'])) { $wplc_settings["wplc_settings_align"] = 2; }
341
-
342
- if (!isset($wplc_settings['wplc_settings_enabled'])) { $wplc_settings["wplc_settings_enabled"] = 1; }
343
-
344
- if (!isset($wplc_settings['wplc_settings_fill'])) { $wplc_settings["wplc_settings_fill"] = "ed832f"; }
345
-
346
- if (!isset($wplc_settings['wplc_settings_font'])) { $wplc_settings["wplc_settings_font"] = "FFFFFF"; }
347
-
348
- if (!isset($wplc_settings['wplc_preferred_gif_provider'])) { $wplc_settings["wplc_preferred_gif_provider"] = 1; }
349
- if (!isset($wplc_settings['wplc_giphy_api_key'])) { $wplc_settings["wplc_giphy_api_key"] = ""; }
350
- if (!isset($wplc_settings['wplc_tenor_api_key'])) { $wplc_settings["wplc_tenor_api_key"] = ""; }
351
-
352
- wplc_handle_db();
353
- update_option("wplc_current_version", $wplc_version);
354
-
355
-
356
- if (!isset($wplc_settings['wplc_require_user_info'])) { $wplc_settings['wplc_require_user_info'] = "1"; }
357
- if (!isset($wplc_settings['wplc_user_default_visitor_name'])) {
358
- $wplc_default_visitor_name = __( "Guest", "wplivechat" );
359
- $wplc_settings['wplc_user_default_visitor_name'] = $wplc_default_visitor_name;
360
- }
361
- if (!isset($wplc_settings['wplc_loggedin_user_info'])) { $wplc_settings['wplc_loggedin_user_info'] = "1"; }
362
- if (!isset($wplc_settings['wplc_user_alternative_text'])) {
363
- $wplc_alt_text = __("Please click \'Start Chat\' to initiate a chat with an agent", "wplivechat");
364
- $wplc_settings['wplc_user_alternative_text'] = $wplc_alt_text;
365
- }
366
- if (!isset($wplc_settings['wplc_enabled_on_mobile'])) { $wplc_settings['wplc_enabled_on_mobile'] = "1"; }
367
- if(!isset($wplc_settings['wplc_record_ip_address'])){ $wplc_settings['wplc_record_ip_address'] = "0"; }
368
- if(!isset($wplc_settings['wplc_enable_msg_sound'])){ $wplc_settings['wplc_enable_msg_sound'] = "1"; }
369
- if(!isset($wplc_settings['wplc_enable_font_awesome'])){ $wplc_settings['wplc_enable_font_awesome'] = "1"; }
370
- if(!isset($wplc_settings['wplc_using_localization_plugin'])){ $wplc_settings['wplc_using_localization_plugin'] = 0; }
371
-
372
- $wplc_settings = apply_filters('wplc_update_settings_between_versions_hook', $wplc_settings); //Added in 8.0.09
373
-
374
- update_option("WPLC_SETTINGS", $wplc_settings);
375
-
376
- do_action("wplc_update_hook");
377
- }
378
-
379
-
380
-
381
- }
382
-
383
- add_action("wplc_hook_set_transient","wplc_hook_control_set_transient",10);
384
- function wplc_hook_control_set_transient() {
385
- $should_set_transient = apply_filters("wplc_filter_control_set_transient",true);
386
- if ($should_set_transient) {
387
- set_transient("wplc_is_admin_logged_in", "1", 70);
388
- }
389
- }
390
-
391
- add_action("wplc_hook_remove_transient","wplc_hook_control_remove_transient",10);
392
- function wplc_hook_control_remove_transient() {
393
- delete_transient('wplc_is_admin_logged_in');
394
- }
395
-
396
- function wplc_action_callback() {
397
- global $wpdb;
398
- global $wplc_tblname_chats;
399
- $check = check_ajax_referer('wplc', 'security');
400
-
401
- if ($check == 1) {
402
-
403
- if( $_POST['action'] == 'wplc_a2a_dismiss' ){
404
- $uid = get_current_user_id();
405
- update_user_meta($uid, 'wplc_a2a_upsell', 1);
406
- }
407
-
408
- if( $_POST['action'] == 'delete_offline_message' ){
409
-
410
- global $wplc_tblname_offline_msgs;
411
-
412
- $mid = sanitize_text_field( $_POST['mid'] );
413
-
414
- $sql = "DELETE FROM `$wplc_tblname_offline_msgs` WHERE `id` = '$mid'";
415
- $query = $wpdb->Query($sql);
416
-
417
- if( $query ){
418
-
419
- echo 1;
420
-
421
- }
422
-
423
- }
424
-
425
- if ($_POST['action'] == "wplc_user_send_offline_message") {
426
- if(function_exists('wplc_send_offline_msg')){ wplc_send_offline_msg($_POST['name'], $_POST['email'], $_POST['msg'], $_POST['cid']); }
427
- if(function_exists('wplc_store_offline_message')){ wplc_store_offline_message($_POST['name'], $_POST['email'], $_POST['msg']); }
428
- do_action("wplc_hook_offline_message",array(
429
- "cid"=>$_POST['cid'],
430
- "name"=>$_POST['name'],
431
- "email"=>$_POST['email'],
432
- "url"=>get_site_url(),
433
- "msg"=>$_POST['msg']
434
- )
435
- );
436
- }
437
- if ($_POST['action'] == "wplc_admin_set_transient") {
438
- do_action("wplc_hook_set_transient");
439
-
440
- }
441
- if ($_POST['action'] == "wplc_admin_remove_transient") {
442
- do_action("wplc_hook_remove_transient");
443
-
444
- }
445
- if ($_POST['action'] == 'wplc_hide_ftt') {
446
- update_option("WPLC_FIRST_TIME_TUTORIAL",true);
447
- }
448
- do_action("wplc_hook_action_callback");
449
- }
450
- die(); // this is required to return a proper result
451
- }
452
-
453
-
454
-
455
- /**
456
- * Decide who gets to see the various main menus (left navigation)
457
- * @return array
458
- * @since 6.0.00
459
- * @author Nick Duncan <nick@codecabin.co.za>
460
- */
461
- add_filter("wplc_ma_filter_menu_control","wplc_filter_control_menu_control",10,1);
462
- function wplc_filter_control_menu_control() {
463
- $array = array(
464
- 0 => 'read', /* main menu */
465
- 1 => 'read', /* settings */
466
- 2 => 'read', /* history */
467
- 3 => 'read', /* missed chats */
468
- 4 => 'read', /* offline messages */
469
- 5 => 'read', /* feedback */
470
- 6 => 'read' /* surveys */
471
- );
472
- return $array;
473
- }
474
-
475
- if (isset($_GET['page'])) {
476
- if ($_GET['page'] === 'wplivechat-menu') {
477
- // check if we are overriding this redirect because the user pressed the "Chat now" button in the dashboard
478
- if (isset($_GET['subaction']) && $_GET['subaction'] == 'override') { } else {
479
- if(!isset($_COOKIE['wplcfirstsession'])) {
480
- @setcookie("wplcfirstsession", true, time() + (60 * 10)); // 60 seconds ( 1 minute) * 20 = 20 minutes
481
- @Header("Location: ./admin.php?page=wplivechat-menu-dashboard");
482
- exit();
483
- }
484
- }
485
-
486
- }
487
- }
488
-
489
- function wplc_admin_menu() {
490
-
491
- $cap = apply_filters("wplc_ma_filter_menu_control",array());
492
- if ( get_option("wplc_seen_surveys") ) { $survey_new = ""; } else { $survey_new = ' <span class="update-plugins"><span class="plugin-count">New</span></span>'; }
493
-
494
- $wplc_current_user = get_current_user_id();
495
-
496
- /* If user is either an agent or an admin, access the page. */
497
- if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true ) || current_user_can("wplc_ma_agent")){
498
- $wplc_mainpage = add_menu_page('WP Live Chat', __('Live Chat', 'wplivechat'), $cap[0], 'wplivechat-menu', 'wplc_admin_menu_layout', 'dashicons-format-chat');
499
- add_submenu_page('wplivechat-menu', __('Dashboard', 'wplivechat'), __('Dashboard', 'wplivechat'), $cap[1], 'wplivechat-menu-dashboard', 'wplc_admin_dashboard_layout');
500
- add_submenu_page('wplivechat-menu', __('Settings', 'wplivechat'), __('Settings', 'wplivechat'), $cap[1], 'wplivechat-menu-settings', 'wplc_admin_settings_layout');
501
- add_submenu_page('wplivechat-menu', __('Surveys', 'wplivechat'), __('Surveys', 'wplivechat'). $survey_new, $cap[2], 'wplivechat-menu-survey', 'wplc_admin_survey_layout');
502
- }
503
-
504
- //Only if pro is not active
505
- if(!function_exists("wplc_pro_reporting_page")){
506
- add_submenu_page('wplivechat-menu', __('Reporting', 'wplivechat'), __('Reporting', 'edit_posts') . ' <span class="update-plugins"><span class="plugin-count">Pro</span></span>', $cap[0], 'wplc-basic-reporting', 'wplc_basic_reporting_page');
507
- }
508
-
509
-
510
- //Only if pro is not active
511
- if(!function_exists("wplc_pro_triggers_page")){
512
- add_submenu_page('wplivechat-menu', __('Triggers', 'wplivechat'), __('Triggers', 'edit_posts') . ' <span class="update-plugins"><span class="plugin-count">Pro</span></span>', $cap[0], 'wplc-basic-triggers', 'wplc_basic_triggers_page');
513
- }
514
-
515
- /* only if user is both an agent and an admin that has the cap assigned, can they access these pages */
516
- if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true ) && current_user_can("wplc_ma_agent")){
517
-
518
- add_submenu_page('wplivechat-menu', __('History', 'wplivechat'), __('History', 'wplivechat'), $cap[2], 'wplivechat-menu-history', 'wplc_admin_history_layout');
519
- add_submenu_page('wplivechat-menu', __('Missed Chats', 'wplivechat'), __('Missed Chats', 'wplivechat'), $cap[3], 'wplivechat-menu-missed-chats', 'wplc_admin_missed_chats');
520
-
521
- /* TO DO
522
- Add a hook here so that the other plugins can add to the menu
523
- Also make sure the function below is controled differently as the pro will not longer exist
524
- */
525
-
526
- if (function_exists("wplc_admin_menu_pro")) {
527
- global $wplc_pro_version;
528
- if (intval(str_replace(".","",$wplc_pro_version)) <= 5100) {
529
- /* do nothing as they have the pro active and their version of the pro makes use of offline messages */
530
-
531
- } else {
532
- add_submenu_page('wplivechat-menu', __('Offline Messages', 'wplivechat'), __('Offline Messages', 'wplivechat'), $cap[4], 'wplivechat-menu-offline-messages', 'wplc_admin_offline_messages');
533
- }
534
- } else {
535
- add_submenu_page('wplivechat-menu', __('Offline Messages', 'wplivechat'), __('Offline Messages', 'wplivechat'), $cap[4], 'wplivechat-menu-offline-messages', 'wplc_admin_offline_messages');
536
-
537
- }
538
- do_action("wplc_hook_menu_mid",$cap);
539
-
540
-
541
- add_submenu_page('wplivechat-menu', __('Support', 'wplivechat'), __('Support', 'wplivechat'), 'manage_options', 'wplivechat-menu-support-page', 'wplc_support_menu');
542
- add_submenu_page('wplivechat-menu', __('Extensions', 'wplivechat'), __('Extensions', 'wplivechat'), 'manage_options', 'wplivechat-menu-extensions-page', 'wplc_extensions_menu');
543
- }
544
- do_action("wplc_hook_menu");
545
- }
546
-
547
-
548
- add_action("wplc_hook_menu","wplc_hook_control_menu");
549
- function wplc_hook_control_menu() {
550
- $check = apply_filters("wplc_filter_menu_api",0);
551
- if ($check > 0) {
552
- add_submenu_page('wplivechat-menu', __('API Keys', 'wplivechat'), __('API Keys', 'wplivechat'), 'manage_options', 'wplivechat-menu-api-keys-page', 'wplc_api_keys_menu');
553
- }
554
- }
555
-
556
-
557
- function wplc_api_keys_menu() {
558
- $page_content = "<h1>".__("Premium Extension API Keys","wplivechat")."</h3>";
559
- $page_content .= "<p>".__("To find and manage your premium API keys, please visit your <a target='_BLANK' href='https://wp-livechat.com/my-account/'>my account</a> page.","")."</p>";
560
-
561
- $page_content .= "<hr />";
562
- $page_content = apply_filters("wplc_filter_api_page",$page_content);
563
-
564
-
565
- echo $page_content;
566
- }
567
-
568
-
569
- add_action("wp_head","wplc_load_user_js",0);
570
-
571
-
572
- function wplc_load_user_js () {
573
- if (!is_admin()) {
574
- if (in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) {
575
- return false;
576
- }
577
-
578
-
579
- if(function_exists('wplc_display_chat_contents')){
580
- $display_contents = wplc_display_chat_contents();
581
- } else {
582
- $display_contents = 1;
583
- }
584
-
585
- if(function_exists('wplc_is_user_banned_basic')){
586
- $user_banned = wplc_is_user_banned_basic();
587
- } else {
588
- $user_banned = 0;
589
- }
590
- $display_contents = apply_filters("wplc_filter_display_contents",$display_contents);
591
-
592
- if($display_contents && $user_banned == 0){
593
-
594
- /* do not show if pro is outdated */
595
- global $wplc_pro_version;
596
- if (isset($wplc_pro_version)) {
597
- $float_version = floatval($wplc_pro_version);
598
- if ($float_version < 4 || $wplc_pro_version == "4.1.0" || $wplc_pro_version == "4.1.1") {
599
- return;
600
- }
601
- }
602
-
603
- $wplc_settings = get_option("WPLC_SETTINGS");
604
- if (!class_exists('Mobile_Detect')) {
605
- require_once (plugin_dir_path(__FILE__) . 'includes/Mobile_Detect.php');
606
- }
607
- $wplc_detect_device = new Mobile_Detect;
608
- $wplc_is_mobile = $wplc_detect_device->isMobile();
609
-
610
- if ($wplc_is_mobile && isset($wplc_settings['wplc_enabled_on_mobile']) && $wplc_settings['wplc_enabled_on_mobile'] == '0') {
611
- return;
612
- }
613
-
614
- if (function_exists("wplc_register_pro_version")) {
615
- if (function_exists('wplc_basic_hide_chat_when_offline')) {
616
- $wplc_hide_chat = wplc_basic_hide_chat_when_offline();
617
- if (!$wplc_hide_chat) {
618
- if (function_exists("wplc_push_js_to_front_pro")) {
619
- wplc_push_js_to_front_pro();
620
- }
621
- }
622
- } else {
623
- if (function_exists("wplc_push_js_to_front_pro")) {
624
- wplc_push_js_to_front_pro();
625
- }
626
- }
627
- } else {
628
- wplc_push_js_to_front_basic();
629
- }
630
- }
631
- }
632
-
633
-
634
-
635
-
636
-
637
- }
638
-
639
- function wplc_push_js_to_front_basic() {
640
- global $wplc_is_mobile;
641
- global $wplc_version;
642
-
643
- wp_register_script('wplc-user-jquery-cookie', plugins_url('/js/jquery-cookie.js', __FILE__), array('jquery'),false, false);
644
- wp_enqueue_script('wplc-user-jquery-cookie');
645
-
646
- wp_enqueue_script('jquery');
647
-
648
- $wplc_settings = get_option("WPLC_SETTINGS");
649
- $wplc_acbc_data = get_option("WPLC_ACBC_SETTINGS");
650
- $wplc_ga_enabled = get_option("WPLC_GA_SETTINGS");
651
-
652
- if (isset($wplc_settings['wplc_display_to_loggedin_only']) && $wplc_settings['wplc_display_to_loggedin_only'] == 1) {
653
- /* Only show to users that are logged in */
654
- if (!is_user_logged_in()) {
655
- return;
656
- }
657
- }
658
-
659
- /* is the chat enabled? */
660
- if ($wplc_settings["wplc_settings_enabled"] == 2) { return; }
661
-
662
- wp_register_script('wplc-md5', plugins_url('/js/md5.js', __FILE__),array('wplc-user-script'),$wplc_version);
663
- wp_enqueue_script('wplc-md5');
664
- if (isset($wplc_settings['wplc_display_name']) && $wplc_settings['wplc_display_name'] == 1) {
665
- $wplc_display = 'display';
666
- } else {
667
- $wplc_display = 'hide';
668
- }
669
-
670
-
671
- if (isset($wplc_settings['wplc_enable_msg_sound']) && intval($wplc_settings['wplc_enable_msg_sound']) == 1) { $wplc_ding = '1'; } else { $wplc_ding = '0'; }
672
-
673
- $ajax_nonce = wp_create_nonce("wplc");
674
- if (!function_exists("wplc_register_pro_version")) {
675
- $ajaxurl = admin_url('admin-ajax.php');
676
- $wplc_ajaxurl = $ajaxurl;
677
- }
678
-
679
-
680
- wp_register_script('wplc-server-script', plugins_url('/js/wplc_server.js', __FILE__), array('jquery'), $wplc_version);
681
- wp_enqueue_script('wplc-server-script');
682
-
683
- wp_localize_script( 'wplc-server-script', 'wplc_datetime_format', array(
684
- 'date_format' => get_option( 'date_format' ),
685
- 'time_format' => get_option( 'time_format' ),
686
- ) );
687
-
688
- if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
689
- wp_localize_script('wplc-server-script', 'wplc_use_node_server', "true");
690
-
691
- $wplc_node_token = get_option("wplc_node_server_secret_token");
692
- if(!$wplc_node_token){
693
- if(function_exists("wplc_node_server_token_regenerate")){
694
- wplc_node_server_token_regenerate();
695
- $wplc_node_token = get_option("wplc_node_server_secret_token");
696
- }
697
- }
698
- wp_localize_script('wplc-server-script', 'bleeper_api_key', $wplc_node_token);
699
-
700
-
701
-
702
- $wplc_end_point_override = get_option("wplc_end_point_override");
703
- if($wplc_end_point_override !== false && $wplc_end_point_override !== ""){
704
- $bleeper_url = $wplc_end_point_override; //Use the override URL
705
- } else {
706
- $bleeper_url = BLEEPER_NODE_SERVER_URL;
707
- }
708
- //wp_register_script('wplc-node-server-script', trailingslashit( $bleeper_url ) . "socket.io/socket.io.js", array('jquery'), $wplc_version);
709
- wp_register_script('wplc-node-server-script', "https://bleeper.io/app/assets/js/vendor/socket.io/socket.io.slim.js", array('jquery'), $wplc_version);
710
-
711
-
712
- //wp_register_script('wplc-node-server-script', 'http://localhost:3000/socket.io/socket.io.js', array('jquery'), $wplc_version);
713
- wp_enqueue_script('wplc-node-server-script');
714
- wp_register_script('wplc-user-events-script', plugins_url('/js/wplc_u_node_events.js', __FILE__),array('jquery', 'wplc-server-script'),$wplc_version);
715
-
716
- wp_localize_script('wplc-server-script', 'bleeper_override_upload_url', rest_url( 'wp_live_chat_support/v1/remote_upload' ) );
717
-
718
- /** DEPRECATED BY GDPR */
719
- /*if(isset($wplc_settings['wplc_record_ip_address']) && $wplc_settings['wplc_record_ip_address'] == 1) {
720
- $ip_address = false;
721
- if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != '') { $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip_address = $_SERVER['REMOTE_ADDR']; }
722
-
723
- if($ip_address !== false){
724
- wp_localize_script('wplc-server-script', 'bleeper_user_ip_address', $ip_address);
725
- }
726
- }*/
727
-
728
- $wplc_server_location = get_option( "wplc_server_location" );
729
- $wplc_server_location = apply_filters('wplc_node_server_default_selection_override', $wplc_server_location, $wplc_settings);
730
-
731
- if( $wplc_server_location !== false && $wplc_server_location !== "" && $wplc_server_location !== "auto" ){
732
- if ( $wplc_server_location === "us1") { $wplc_server_location = "0"; }
733
- else if ( $wplc_server_location === "us2") { $wplc_server_location = "3"; }
734
- else if ( $wplc_server_location === "eu1") { $wplc_server_location = "1"; }
735
- else if ( $wplc_server_location === "eu2") { $wplc_server_location = "2"; }
736
- else { $wplc_server_location = "0"; }
737
- wp_localize_script( 'wplc-server-script', 'bleeper_server_location', $wplc_server_location );
738
- }
739
-
740
-
741
- $wplc_end_point_override = get_option("wplc_end_point_override");
742
- if($wplc_end_point_override !== false && $wplc_end_point_override !== ""){
743
- wp_localize_script( 'wplc-server-script', 'bleeper_end_point_override', $wplc_end_point_override );
744
- }
745
- //For node verification
746
- if(function_exists("wplc_pro_activate")){
747
- wp_localize_script('wplc-server-script', 'bleeper_pro_auth', get_option('wp-live-chat-support-pro_key', "false"));
748
- } else {
749
- wp_localize_script('wplc-server-script', 'bleeper_pro_auth', 'false');
750
- }
751
-
752
-
753
-
754
- //Emoji Libs
755
- if(empty($wplc_settings['wplc_disable_emojis'])) {
756
- //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);
757
- //wp_enqueue_script('wplc-user-js-emoji');
758
- //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);
759
- //wp_enqueue_script('wplc-user-js-emoji-bundle');
760
-
761
- 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);
762
- wp_enqueue_script('wplc-user-js-emoji-concat');
763
-
764
- wp_register_style( 'wplc-admin-style-emoji', "https://bleeper.io/app/assets/wdt-emoji/wdt-emoji-bundle.css", false, $wplc_version );
765
- wp_enqueue_style( 'wplc-admin-style-emoji' );
766
- }
767
-
768
- } else {
769
- /* not using the node server, load traditional event handler JS */
770
- wp_register_script('wplc-user-events-script', plugins_url('/js/wplc_u_events.js', __FILE__),array('jquery', 'wplc-server-script'),$wplc_version);
771
- }
772
-
773
-
774
-
775
-
776
- wp_register_script('wplc-user-script', plugins_url('/js/wplc_u.js', __FILE__),array('jquery', 'wplc-server-script'),$wplc_version);
777
-
778
-
779
- /**
780
- * No longer in use as of 6.2.11 as using the minified file causes issues on sites that are minified.
781
- * @deprecated 6.2.11
782
- */
783
- // wp_register_script('wplc-user-script', plugins_url('/js/wplc_u.min.js', __FILE__),array('jquery'),$wplc_version);
784
-
785
- wp_enqueue_script('wplc-user-script');
786
- wp_enqueue_script('wplc-user-events-script');
787
-
788
- if (isset($wplc_settings['wplc_newtheme'])) { $wplc_newtheme = $wplc_settings['wplc_newtheme']; } else { $wplc_newtheme = "theme-2"; }
789
- if (isset($wplc_newtheme)) {
790
- if($wplc_newtheme == 'theme-1') {
791
- wp_register_script('wplc-theme-classic', plugins_url('/js/themes/classic.js', __FILE__),array('wplc-user-script'),$wplc_version);
792
- wp_enqueue_script('wplc-theme-classic');
793
- $avatars = wplc_all_avatars();
794
- wp_localize_script('wplc-theme-classic', 'wplc_user_avatars', $avatars);
795
-
796
- }
797
- else if($wplc_newtheme == 'theme-2') {
798
- wp_register_script('wplc-theme-modern', plugins_url('/js/themes/modern.js', __FILE__),array('wplc-user-script'),$wplc_version);
799
- wp_enqueue_script('wplc-theme-modern');
800
- $avatars = wplc_all_avatars();
801
- wp_localize_script('wplc-theme-modern', 'wplc_user_avatars', $avatars);
802
- }
803
- } else {
804
- wp_register_script('wplc-theme-classic', plugins_url('/js/themes/classic.js', __FILE__),array('wplc-user-script'),$wplc_version);
805
- wp_enqueue_script('wplc-theme-classic');
806
- $avatars = wplc_all_avatars();
807
- wp_localize_script('wplc-theme-classic', 'wplc_user_avatars', $avatars);
808
- }
809
-
810
- $ajax_url = admin_url('admin-ajax.php');
811
- $home_ajax_url = $ajax_url;
812
-
813
- $wplc_ajax_url = apply_filters("wplc_filter_ajax_url",$ajax_url);
814
- wp_localize_script('wplc-admin-chat-js', 'wplc_ajaxurl', $wplc_ajax_url);
815
- wp_localize_script('wplc-ma-js', 'wplc_home_ajaxurl', $home_ajax_url);
816
-
817
- //Added rest security nonces
818
- if(class_exists("WP_REST_Request")) {
819
- wp_localize_script('wplc-user-script', 'wplc_restapi_enabled', '1');
820
- wp_localize_script('wplc-user-script', 'wplc_restapi_token', get_option('wplc_api_secret_token'));
821
- wp_localize_script('wplc-user-script', 'wplc_restapi_endpoint', rest_url('wp_live_chat_support/v1'));
822
- wp_localize_script('wplc-user-script', 'wplc_restapi_nonce', wp_create_nonce( 'wp_rest' ));
823
- } else {
824
- wp_localize_script('wplc-user-script', 'wplc_restapi_enabled', '0');
825
- wp_localize_script('wplc-user-script', 'wplc_restapi_nonce', "false");
826
- }
827
-
828
-
829
- if (isset($wplc_ga_enabled['wplc_enable_ga']) && $wplc_ga_enabled['wplc_enable_ga'] == '1') {
830
- wp_localize_script('wplc-user-script', 'wplc_enable_ga', '1');
831
- }
832
-
833
- $wplc_ding_file = apply_filters( 'wplc_filter_message_sound', '' );
834
- if ( ! empty( $wplc_ding_file ) ) {
835
- wp_localize_script( 'wplc-user-script', 'bleeper_message_override', $wplc_ding_file );
836
- }
837
-
838
- $wplc_detect_device = new Mobile_Detect;
839
- $wplc_is_mobile = $wplc_detect_device->isMobile() ? 'true' : 'false';
840
- wp_localize_script('wplc-user-script', 'wplc_is_mobile', $wplc_is_mobile);
841
-
842
-
843
- wp_localize_script('wplc-user-script', 'wplc_ajaxurl', $wplc_ajax_url);
844
- wp_localize_script('wplc-user-script', 'wplc_ajaxurl_site', admin_url('admin-ajax.php'));
845
- wp_localize_script('wplc-user-script', 'wplc_nonce', $ajax_nonce);
846
- wp_localize_script('wplc-user-script', 'wplc_plugin_url', WPLC_BASIC_PLUGIN_URL);
847
-
848
- $wplc_display = false;
849
-
850
- $wplc_images = apply_filters( 'wplc_get_images_to_preload', array(), $wplc_acbc_data );
851
- wp_localize_script( 'wplc-user-script', 'wplc_preload_images', $wplc_images );
852
-
853
-
854
-
855
-
856
- if( isset($wplc_settings['wplc_show_name']) && $wplc_settings['wplc_show_name'] == '1' ){ $wplc_show_name = true; } else { $wplc_show_name = false; }
857
- if( isset($wplc_settings['wplc_show_avatar']) && $wplc_settings['wplc_show_avatar'] ){ $wplc_show_avatar = true; } else { $wplc_show_avatar = false; }
858
- if( isset($wplc_settings['wplc_show_date']) && $wplc_settings['wplc_show_date'] == '1' ){ $wplc_show_date = true; } else { $wplc_show_date = false; }
859
- if( isset($wplc_settings['wplc_show_time']) && $wplc_settings['wplc_show_time'] == '1' ){ $wplc_show_time = true; } else { $wplc_show_time = false; }
860
-
861
- $wplc_chat_detail = array( 'name' => $wplc_show_name, 'avatar' => $wplc_show_avatar, 'date' => $wplc_show_date, 'time' => $wplc_show_time );
862
-
863
-
864
-
865
- if( $wplc_display !== FALSE && $wplc_display !== 'hide' ){
866
- wp_localize_script('wplc-user-script', 'wplc_display_name', $wplc_display);
867
- } else {
868
- wp_localize_script( 'wplc-user-script', 'wplc_show_chat_detail', $wplc_chat_detail );
869
- }
870
-
871
-
872
-
873
- /**
874
- * Create a JS object for all Agent ID's and Gravatar MD5's
875
- */
876
- $user_array = get_users(array(
877
- 'meta_key' => 'wplc_ma_agent',
878
- ));
879
-
880
- $a_array = array();
881
- if ($user_array) {
882
- foreach ($user_array as $user) {
883
- $a_array[$user->ID] = array();
884
- $a_array[$user->ID]['name'] = apply_filters( "wplc_decide_agents_name", $user->display_name, $wplc_acbc_data );
885
- $a_array[$user->ID]['md5'] = md5( $user->user_email );
886
- }
887
- }
888
- wp_localize_script('wplc-user-script', 'wplc_agent_data', $a_array);
889
-
890
-
891
- $wplc_error_messages = array(
892
- 'valid_name' => __( "Please enter your name", "wplivechat" ),
893
- 'valid_email' => __( "Please enter your email address", "wplivechat" ),
894
- 'server_connection_lost' => __("Connection to server lost. Please reload this page. Error: ", "wplivechat"),
895
- 'chat_ended_by_operator' => ( empty( $wplc_settings['wplc_text_chat_ended'] ) ) ? __("The chat has been ended by the operator.", "wplivechat") : esc_attr( $wplc_settings['wplc_text_chat_ended'] ) ,
896
- 'empty_message' => __( "Please enter a message", "wplivechat" ),
897
- 'disconnected_message' => __("Disconnected, attempting to reconnect...", "wplivechat"),
898
- );
899
-
900
- $wplc_error_messages = apply_filters( "wplc_user_error_messages_filter", $wplc_error_messages );
901
-
902
- wp_localize_script('wplc-user-script', 'wplc_error_messages', $wplc_error_messages);
903
- wp_localize_script('wplc-user-script', 'wplc_enable_ding', $wplc_ding);
904
- $wplc_run_override = "0";
905
- $wplc_run_override = apply_filters("wplc_filter_run_override",$wplc_run_override);
906
- wp_localize_script('wplc-user-script', 'wplc_filter_run_override', $wplc_run_override);
907
-
908
- if (!isset($wplc_settings['wplc_pro_offline1'])) { $wplc_settings["wplc_pro_offline1"] = __("We are currently offline. Please leave a message and we'll get back to you shortly.", "wplivechat"); }
909
- if (!isset($wplc_settings['wplc_pro_offline2'])) { $wplc_settings["wplc_pro_offline2"] = __("Sending message...", "wplivechat"); }
910
- if (!isset($wplc_settings['wplc_pro_offline3'])) { $wplc_settings["wplc_pro_offline3"] = __("Thank you for your message. We will be in contact soon.", "wplivechat"); }
911
-
912
-
913
- wp_localize_script('wplc-user-script', 'wplc_offline_msg', __(stripslashes($wplc_settings['wplc_pro_offline2']), 'wplivechat'));
914
- wp_localize_script('wplc-user-script', 'wplc_offline_msg3',__(stripslashes($wplc_settings['wplc_pro_offline3']), 'wplivechat'));
915
- wp_localize_script('wplc-user-script', 'wplc_welcome_msg', __(stripslashes($wplc_settings['wplc_welcome_msg']), 'wplivechat'));
916
- wp_localize_script('wplc-user-script', 'wplc_pro_sst1', __(stripslashes($wplc_settings['wplc_pro_sst1']), 'wplivechat') );
917
- wp_localize_script('wplc-user-script', 'wplc_pro_offline_btn_send', __(stripslashes($wplc_settings['wplc_pro_offline_btn_send']), 'wplivechat') );
918
- wp_localize_script('wplc-user-script', 'wplc_user_default_visitor_name', __(stripslashes($wplc_settings['wplc_user_default_visitor_name']), 'wplivechat') );
919
-
920
- if( isset( $wplc_acbc_data['wplc_use_wp_name'] ) && $wplc_acbc_data['wplc_use_wp_name'] == '1' ){
921
- if( isset( $_COOKIE['wplc_cid'] ) ){
922
- $chat_data = wplc_get_chat_data( $_COOKIE['wplc_cid'] );
923
- if ( isset($chat_data->agent_id ) ) {
924
- $user_info = get_userdata( intval( $chat_data->agent_id ) );
925
- if( $user_info ){
926
- $agent = $user_info->display_name;
927
- } else {
928
- $agent = "agent";
929
- }
930
- } else {
931
- $agent = 'agent';
932
- }
933
- } else {
934
- $agent = 'agent';
935
- }
936
-
937
- } else {
938
- if (!empty($wplc_acbc_data['wplc_chat_name'])) {
939
- $agent = $wplc_acbc_data['wplc_chat_name'];
940
- } else {
941
- $agent = 'agent';
942
- }
943
- }
944
- wp_localize_script('wplc-user-script', 'wplc_localized_string_is_typing', $agent . __(" is typing...","wplivechat"));
945
- wp_localize_script('wplc-user-script', 'wplc_localized_string_is_typing_single', __(" is typing...","wplivechat"));
946
-
947
- $bleeper_string_array = array(
948
- __(" has joined.","wplivechat"),
949
- __(" has left.","wplivechat"),
950
- __(" has ended the chat.", "wplivechat"),
951
- __(" has disconnected.", "wplivechat"),
952
- __("(edited)", "wplivechat"),
953
- __("Type here","wplivechat")
954
- );
955
-
956
- wp_localize_script('wplc-user-script', 'bleeper_localized_strings', $bleeper_string_array );
957
-
958
- if( isset( $wplc_settings['wplc_elem_trigger_id'] ) && trim( $wplc_settings['wplc_elem_trigger_id'] ) !== "" ) {
959
- if( isset( $wplc_settings['wplc_elem_trigger_action'] ) ){
960
- wp_localize_script( 'wplc-user-script', 'wplc_elem_trigger_action', stripslashes( $wplc_settings['wplc_elem_trigger_action'] ) );
961
- }
962
- if( isset( $wplc_settings['wplc_elem_trigger_type'] ) ){
963
- wp_localize_script( 'wplc-user-script', 'wplc_elem_trigger_type', stripslashes( $wplc_settings['wplc_elem_trigger_type'] ) );
964
- }
965
- wp_localize_script( 'wplc-user-script', 'wplc_elem_trigger_id', stripslashes( $wplc_settings['wplc_elem_trigger_id'] ) );
966
- }
967
-
968
- $extra_data_array = array("object_switch" => true);
969
- $extra_data_array = apply_filters("wplc_filter_front_js_extra_data",$extra_data_array);
970
- wp_localize_script('wplc-user-script', 'wplc_extra_data',$extra_data_array);
971
-
972
-
973
- if (isset($_COOKIE['wplc_email']) && $_COOKIE['wplc_email'] != "") { $wplc_user_gravatar = sanitize_text_field(md5(strtolower(trim($_COOKIE['wplc_email'])))); } else {$wplc_user_gravatar = ""; }
974
-
975
- if ($wplc_user_gravatar != "") { $wplc_grav_image = "<img src='//www.gravatar.com/avatar/$wplc_user_gravatar?s=30' class='wplc-user-message-avatar' />";} else { $wplc_grav_image = "";}
976
-
977
- if ( ! empty( $wplc_grav_image ) ) {
978
- wp_localize_script('wplc-user-script', 'wplc_gravatar_image', $wplc_grav_image);
979
- }
980
-
981
- $wplc_hide_chat = "";
982
- if (get_option('WPLC_HIDE_CHAT') == TRUE) { $wplc_hide_chat = "yes"; } else { $wplc_hide_chat = null; }
983
- wp_localize_script('wplc-user-script', 'wplc_hide_chat', $wplc_hide_chat);
984
-
985
- if(isset($wplc_settings['wplc_redirect_to_thank_you_page']) && isset($wplc_settings['wplc_redirect_thank_you_url']) && $wplc_settings['wplc_redirect_thank_you_url'] !== "" && $wplc_settings['wplc_redirect_thank_you_url'] !== " "){
986
- wp_localize_script('wplc-user-script', 'wplc_redirect_thank_you', urldecode($wplc_settings['wplc_redirect_thank_you_url']));
987
- }
988
-
989
- wp_enqueue_script('jquery-ui-core',false,array('wplc-user-script'),false,false);
990
- wp_enqueue_script('jquery-ui-draggable',false,array('wplc-user-script'),false,false);
991
-
992
- do_action("wplc_hook_push_js_to_front");
993
-
994
- }
995
- if (function_exists('wplc_pro_user_top_js')) {
996
- add_action('wp_head', 'wplc_pro_user_top_js');
997
-
998
- } else {
999
- add_action('wp_head', 'wplc_user_top_js');
1000
-
1001
- }
1002
-
1003
-
1004
-
1005
- /**
1006
- * Add to the array to determine which images need to be preloaded via JS on the front end.
1007
- *
1008
- * @param array $images Array of images to be preloaded
1009
- * @return array
1010
- */
1011
- add_filter( "wplc_get_images_to_preload", "wplc_filter_control_get_images_to_preload", 10, 2 );
1012
- function wplc_filter_control_get_images_to_preload( $images, $wplc_acbc_data ) {
1013
- $icon = plugins_url('images/iconRetina.png', __FILE__);
1014
- $close_icon = plugins_url('images/iconCloseRetina.png', __FILE__);
1015
- array_push( $images, $icon );
1016
- array_push( $images, $close_icon );
1017
- return $images;
1018
- }
1019
-
1020
-
1021
-
1022
- function wplc_user_top_js() {
1023
-
1024
- if(function_exists('wplc_display_chat_contents')){
1025
- $display_contents = wplc_display_chat_contents();
1026
- } else {
1027
- $display_contents = 1;
1028
- }
1029
- if($display_contents >= 1){
1030
- /*echo "<!-- DEFINING DO NOT CACHE -->";
1031
- if (!defined('DONOTCACHEPAGE')) {
1032
- define('DONOTCACHEPAGE', true);
1033
- }
1034
- if (!defined('DONOTCACHEDB')) {
1035
- define('DONOTCACHEDB', true);
1036
- }
1037
- */
1038
- $ajax_nonce = wp_create_nonce("wplc");
1039
- $wplc_settings = get_option("WPLC_SETTINGS");
1040
- $ajax_url = admin_url('admin-ajax.php');
1041
- $wplc_ajax_url = apply_filters("wplc_filter_ajax_url",$ajax_url);
1042
- ?>
1043
-
1044
- <script type="text/javascript">
1045
- <?php if (!function_exists("wplc_register_pro_version")) { ?>
1046
- var wplc_ajaxurl = '<?php echo $wplc_ajax_url; ?>';
1047
- <?php } ?>
1048
- var wplc_nonce = '<?php echo $ajax_nonce; ?>';
1049
- </script>
1050
-
1051
-
1052
-
1053
-
1054
- <?php
1055
-
1056
- $wplc_settings = get_option('WPLC_SETTINGS');
1057
- if (isset($wplc_settings['wplc_theme'])) { $wplc_theme = $wplc_settings['wplc_theme']; } else { $wplc_theme = "theme-default"; }
1058
- if (isset($wplc_theme)) {
1059
-
1060
- if($wplc_theme == 'theme-6') {
1061
- /* custom */
1062
-
1063
- if (isset($wplc_settings["wplc_settings_color1"])) { $wplc_settings_color1 = $wplc_settings["wplc_settings_color1"]; } else { $wplc_settings_color1 = "ED832F"; }
1064
- if (isset($wplc_settings["wplc_settings_color2"])) { $wplc_settings_color2 = $wplc_settings["wplc_settings_color2"]; } else { $wplc_settings_color2 = "FFFFFF"; }
1065
- if (isset($wplc_settings["wplc_settings_color3"])) { $wplc_settings_color3 = $wplc_settings["wplc_settings_color3"]; } else { $wplc_settings_color3 = "EEEEEE"; }
1066
- if (isset($wplc_settings["wplc_settings_color4"])) { $wplc_settings_color4 = $wplc_settings["wplc_settings_color4"]; } else { $wplc_settings_color4 = "666666"; }
1067
-
1068
-
1069
- ?>
1070
- <style>
1071
- .wplc-color-1 { color: #<?php echo $wplc_settings_color1; ?> !important; }
1072
- .wplc-color-2 { color: #<?php echo $wplc_settings_color2; ?> !important; }
1073
- .wplc-color-3 { color: #<?php echo $wplc_settings_color3; ?> !important; }
1074
- .wplc-color-4 { color: #<?php echo $wplc_settings_color4; ?> !important; }
1075
- .wplc-color-bg-1 { background-color: #<?php echo $wplc_settings_color1; ?> !important; }
1076
- .wplc-color-bg-2 { background-color: #<?php echo $wplc_settings_color2; ?> !important; }
1077
- .wplc-color-bg-3 { background-color: #<?php echo $wplc_settings_color3; ?> !important; }
1078
- .wplc-color-bg-4 { background-color: #<?php echo $wplc_settings_color4; ?> !important; }
1079
- .wplc-color-border-1 { border-color: #<?php echo $wplc_settings_color1; ?> !important; }
1080
- .wplc-color-border-2 { border-color: #<?php echo $wplc_settings_color2; ?> !important; }
1081
- .wplc-color-border-3 { border-color: #<?php echo $wplc_settings_color3; ?> !important; }
1082
- .wplc-color-border-4 { border-color: #<?php echo $wplc_settings_color4; ?> !important; }
1083
- .wplc-color-border-1:before { border-color: transparent #<?php echo $wplc_settings_color1; ?> !important; }
1084
- .wplc-color-border-2:before { border-color: transparent #<?php echo $wplc_settings_color2; ?> !important; }
1085
- .wplc-color-border-3:before { border-color: transparent #<?php echo $wplc_settings_color3; ?> !important; }
1086
- .wplc-color-border-4:before { border-color: transparent #<?php echo $wplc_settings_color4; ?> !important; }
1087
- </style>
1088
-
1089
- <?php
1090
-
1091
-
1092
- }
1093
- }
1094
-
1095
-
1096
- }
1097
- }
1098
-
1099
-
1100
-
1101
-
1102
- /**
1103
- * Detect if the user is using blocked in the live chat settings 'blocked IP' section
1104
- * @return void
1105
- * @since 6.0.00
1106
- * @author Nick Duncan <nick@codecabin.co.za>
1107
- */
1108
- function wplc_hook_control_banned_users() {
1109
- if (function_exists('wplc_is_user_banned_basic')){
1110
- $user_banned = wplc_is_user_banned_basic();
1111
- } else {
1112
- $user_banned = 0;
1113
- }
1114
- if ($user_banned) {
1115
- remove_action("wplc_hook_output_box_body","wplc_hook_control_show_chat_box");
1116
- remove_action("wplc_hook_output_box_footer","wplc_action_control_hook_output_box_footer");
1117
- }
1118
- }
1119
-
1120
- /**
1121
- * Detect if the user is using a mobile phone or not and decides to show the chat box depending on the admins settings
1122
- * @return void
1123
- * @since 6.0.00
1124
- * @author Nick Duncan <nick@codecabin.co.za>
1125
- */
1126
- function wplc_hook_control_check_mobile() {
1127
- $wplc_settings = get_option("WPLC_SETTINGS");
1128
-
1129
- $draw_box = false;
1130
-
1131
- if (!class_exists('Mobile_Detect')) {
1132
- require_once (plugin_dir_path(__FILE__) . 'includes/Mobile_Detect.php');
1133
- }
1134
-
1135
- $wplc_detect_device = new Mobile_Detect;
1136
- $wplc_is_mobile = $wplc_detect_device->isMobile();
1137
-
1138
- if ($wplc_is_mobile && !isset($wplc_settings['wplc_enabled_on_mobile']) && $wplc_settings['wplc_enabled_on_mobile'] != 1) {
1139
- return "";
1140
- }
1141
-
1142
- if (function_exists('wplc_basic_hide_chat_when_offline')) {
1143
- $wplc_hide_chat = wplc_basic_hide_chat_when_offline();
1144
- if (!$wplc_hide_chat) {
1145
- $draw_box = true;
1146
- }
1147
- } else {
1148
- $draw_box = true;
1149
- }
1150
- if (!$draw_box) {
1151
- remove_action("wplc_hook_output_box_body","wplc_hook_control_show_chat_box");
1152
- remove_action("wplc_hook_output_box_footer","wplc_action_control_hook_output_box_footer");
1153
- }
1154
-
1155
- }
1156
-
1157
-
1158
- add_action("wplc_hook_output_box_footer","wplc_action_control_hook_output_box_footer",10,1);
1159
- function wplc_action_control_hook_output_box_footer() {
1160
- /* nothing here */
1161
- }
1162
-
1163
- /**
1164
- * Decides whether or not to show the chat box based on the main setting in the settings page
1165
- * @return void
1166
- * @since 6.0.00
1167
- */
1168
- function wplc_hook_control_is_chat_enabled() {
1169
- $wplc_settings = get_option("WPLC_SETTINGS");
1170
- if ($wplc_settings["wplc_settings_enabled"] == 2) {
1171
- remove_action("wplc_hook_output_box_body","wplc_hook_control_show_chat_box");
1172
- remove_action("wplc_hook_output_box_footer","wplc_action_control_hook_output_box_footer");
1173
- }
1174
- }
1175
-
1176
- /**
1177
- * Backwards compatibility for the control of the chat box
1178
- * @return string
1179
- * @since 6.0.00
1180
- * @author Nick Duncan - nick@codecabin.co.za
1181
- */
1182
- function wplc_hook_control_show_chat_box($cid) {
1183
- if (function_exists("wplc_pro_version_control")) {
1184
- global $wplc_pro_version;
1185
- if (intval(str_replace(".","",$wplc_pro_version)) < 5100) {
1186
-
1187
- echo wplc_output_box_ajax();
1188
-
1189
- } else {
1190
- echo wplc_output_box_ajax_new($cid);
1191
- }
1192
- } else {
1193
- echo wplc_output_box_ajax_new($cid);
1194
-
1195
- }
1196
-
1197
- }
1198
-
1199
- /* basic */
1200
- add_action("wplc_hook_output_box_header","wplc_hook_control_banned_users");
1201
- add_action("wplc_hook_output_box_header","wplc_hook_control_check_mobile");
1202
- add_action("wplc_hook_output_box_header","wplc_hook_control_is_chat_enabled");
1203
-
1204
- add_action("wplc_hook_output_box_body","wplc_hook_control_show_chat_box",10,1);
1205
-
1206
- /**
1207
- * Build the chat box
1208
- * @return void
1209
- * @since 6.0.00
1210
- * @author Nick Duncan <nick@codecabin.co.za>
1211
- */
1212
- function wplc_output_box_5100($cid = null) {
1213
- wplc_string_check();
1214
- do_action("wplc_hook_output_box_header",$cid);
1215
- do_action("wplc_hook_output_box_body",$cid);
1216
- do_action("wplc_hook_output_box_footer",$cid);
1217
- }
1218
-
1219
-
1220
-
1221
- /**
1222
- * Filter to control the top MAIN DIV of the chat box
1223
- * @param array $wplc_settings Live chat settings array
1224
- * @return string
1225
- * @since 6.0.00
1226
- * @author Nick Duncan <nick@codecabin.co.za>
1227
- */
1228
- function wplc_filter_control_live_chat_box_html_main_div_top($wplc_settings,$logged_in,$wplc_using_locale) {
1229
- $ret_msg = "";
1230
- $wplc_class = "";
1231
- // $wplc_settings = get_option("WPLC_SETTINGS");
1232
-
1233
- if ($wplc_settings["wplc_settings_align"] == 1) {
1234
- $original_pos = "bottom_left";
1235
- } else if ($wplc_settings["wplc_settings_align"] == 2) {
1236
- $original_pos = "bottom_right";
1237
- } else if ($wplc_settings["wplc_settings_align"] == 3) {
1238
- $original_pos = "left";
1239
- $wplc_class = "wplc_left";
1240
- } else if ($wplc_settings["wplc_settings_align"] == 4) {
1241
- $original_pos = "right";
1242
- $wplc_class = "wplc_right";
1243
- }
1244
-
1245
-
1246
- $animations = wplc_return_animations_basic();
1247
- if ($animations) {
1248
- isset($animations['animation']) ? $wplc_animation = $animations['animation'] : $wplc_animation = 'animation-4';
1249
- isset($animations['starting_point']) ? $wplc_starting_point = $animations['starting_point'] : $wplc_starting_point = 'display: none;';
1250
- isset($animations['box_align']) ? $wplc_box_align = $animations['box_align'] : $wplc_box_align = '';
1251
- }
1252
- else {
1253
-
1254
- if ($wplc_settings["wplc_settings_align"] == 1) {
1255
- $original_pos = "bottom_left";
1256
- $wplc_box_align = "left:20px; bottom:0px;";
1257
- } else if ($wplc_settings["wplc_settings_align"] == 2) {
1258
- $original_pos = "bottom_right";
1259
- $wplc_box_align = "right:20px; bottom:0px;";
1260
- } else if ($wplc_settings["wplc_settings_align"] == 3) {
1261
- $original_pos = "left";
1262
- $wplc_box_align = "left:0; bottom:100px;";
1263
- $wplc_class = "wplc_left";
1264
- } else if ($wplc_settings["wplc_settings_align"] == 4) {
1265
- $original_pos = "right";
1266
- $wplc_box_align = "right:0; bottom:100px;";
1267
- $wplc_class = "wplc_right";
1268
- }
1269
- }
1270
-
1271
-
1272
- $wplc_extra_attr = apply_filters("wplc_filter_chat_header_extra_attr","");
1273
- if (isset($wplc_settings['wplc_newtheme'])) { $wplc_newtheme = $wplc_settings['wplc_newtheme']; } else { $wplc_newtheme = "theme-2"; }
1274
- if (isset($wplc_newtheme)) {
1275
- if($wplc_newtheme == 'theme-1') { $wplc_theme_type = "classic"; }
1276
- else if($wplc_newtheme == 'theme-2') { $wplc_theme_type = "modern"; }
1277
- else { $wplc_theme_type = "modern"; }
1278
- }
1279
-
1280
- if(!isset($wplc_settings['wplc_newtheme'])){ $wplc_settings['wplc_newtheme'] = "theme-2"; }
1281
- if (isset($wplc_settings['wplc_newtheme']) && $wplc_settings['wplc_newtheme'] == "theme-2") {
1282
- $hovercard_content = "<div class='wplc_hovercard_content_left'>".apply_filters("wplc_filter_modern_theme_hovercard_content_left","")."</div><div class='wplc_hovercard_content_right'>".apply_filters("wplc_filter_live_chat_box_html_1st_layer",wplc_filter_control_live_chat_box_html_1st_layer($wplc_settings,$logged_in,$wplc_using_locale,'wplc-color-4'))."</div>";
1283
- $hovercard_content = apply_filters("wplc_filter_hovercard_content", $hovercard_content);
1284
-
1285
- $ret_msg .= "<div id='wplc_hovercard' style='display:none' class='".$wplc_theme_type."'>";
1286
- //$ret_msg .= "<div id='wplc_hovercard_min' class='wplc_button_standard wplc-color-border-1 wplc-color-bg-1'>".stripslashes( $wplc_settings['wplc_close_btn_text'] )."</div>";
1287
- $ret_msg .= "<div id='wplc_hovercard_content'>".apply_filters("wplc_filter_live_chat_box_pre_layer1","").$hovercard_content."</div>";
1288
- $ret_msg .= "<div id='wplc_hovercard_bottom'>".apply_filters("wplc_filter_hovercard_bottom_before","").apply_filters("wplc_filter_live_chat_box_hover_html_start_chat_button","",$wplc_settings,$logged_in,$wplc_using_locale)."</div>";
1289
- $ret_msg .= "</div>";
1290
-
1291
- } else if (isset($wplc_settings['wplc_newtheme']) && $wplc_settings['wplc_newtheme'] == "theme-1"){
1292
- $hovercard_content = "<div class='wplc_hovercard_content_right'>".apply_filters("wplc_filter_live_chat_box_html_1st_layer",wplc_filter_control_live_chat_box_html_1st_layer($wplc_settings,$logged_in,$wplc_using_locale, "wplc-color-2"))."</div>";
1293
- $hovercard_content = apply_filters("wplc_filter_hovercard_content", $hovercard_content);
1294
-
1295
- $ret_msg .= "<div id='wplc_hovercard' style='display:none' class='".$wplc_theme_type."'>";
1296
- //$ret_msg .= "<div id='wplc_hovercard_min' class='wplc_button_standard wplc-color-border-1 wplc-color-bg-1'>".__("close", "wplivechat")."</div>";
1297
- $ret_msg .= "<div id='wplc_hovercard_content'>".apply_filters("wplc_filter_live_chat_box_pre_layer1","").$hovercard_content."</div>";
1298
- $ret_msg .= "<div id='wplc_hovercard_bottom'>".apply_filters("wplc_filter_hovercard_bottom_before","").apply_filters("wplc_filter_live_chat_box_hover_html_start_chat_button","",$wplc_settings,$logged_in,$wplc_using_locale)."</div>";
1299
- $ret_msg .= "</div>";
1300
- }
1301
-
1302
- $ret_msg .= "<div id=\"wp-live-chat\" wplc_animation=\"".$wplc_animation."\" style=\"".$wplc_starting_point." ".$wplc_box_align.";\" class=\"".$wplc_theme_type." ".$wplc_class." wplc_close\" original_pos=\"".$original_pos."\" ".$wplc_extra_attr." > ";
1303
- return $ret_msg;
1304
- }
1305
-
1306
-
1307
-
1308
- add_filter("wplc_filter_modern_theme_hovercard_content_left","wplc_filter_control_modern_theme_hovercard_content_left",10,1);
1309
- function wplc_filter_control_modern_theme_hovercard_content_left($msg) {
1310
-
1311
- $msg .= "<div class='wplc_left_logo' style='background:url(".plugins_url('images/iconmicro.png', __FILE__).") no-repeat; background-size: cover;'></div>";
1312
- $msg = apply_filters("wplc_filter_microicon",$msg);
1313
- return $msg;
1314
- }
1315
-
1316
- /**
1317
- * Filter to control the top HEADER DIV of the chat box
1318
- * @param array $wplc_settings Live chat settings array
1319
- * @return string
1320
- * @since 6.0.00
1321
- * @author Nick Duncan <nick@codecabin.co.za>
1322
- */
1323
- function wplc_filter_control_live_chat_box_html_header_div_top($wplc_settings) {
1324
-
1325
- $ret_msg = "";
1326
-
1327
- $current_theme = isset($wplc_settings['wplc_newtheme']) ? $wplc_settings['wplc_newtheme'] : "theme-2";
1328
- if($current_theme === "theme-1"){
1329
- $ret_msg .= apply_filters("wplc_filter_chat_header_above","", $wplc_settings); //Ratings/Social Icon Filter
1330
- }
1331
-
1332
- $ret_msg .= "<div id=\"wp-live-chat-header\" class='wplc-color-bg-1 wplc-color-2'>";
1333
- $ret_msg .= apply_filters("wplc_filter_chat_header_under","",$wplc_settings);
1334
- return $ret_msg;
1335
- }
1336
-
1337
-
1338
- add_filter("wplc_filter_chat_header_under","wplc_filter_control_chat_header_under",1,2);
1339
- function wplc_filter_control_chat_header_under($ret_msg,$wplc_settings) {
1340
- $current_theme = isset($wplc_settings['wplc_newtheme']) ? $wplc_settings['wplc_newtheme'] : "theme-2";
1341
- if($current_theme === "theme-2"){
1342
-
1343
- if (function_exists("wplc_acbc_filter_control_chat_header_under")) {
1344
- remove_filter("wplc_filter_chat_header_under","wplc_acbc_filter_control_chat_header_under");
1345
- }
1346
- }
1347
-
1348
- return $ret_msg;
1349
-
1350
- }
1351
-
1352
-
1353
-
1354
- /**
1355
- * Filter to control the user details section - custom fields coming soon
1356
- * @param array $wplc_settings Live chat settings array
1357
- * @return string
1358
- * @since 6.0.00
1359
- * @author Nick Duncan <nick@codecabin.co.za>
1360
- */
1361
- function wplc_filter_control_live_chat_box_html_ask_user_detail($wplc_settings) {
1362
- $ret_msg = "";
1363
- if (isset($wplc_settings['wplc_loggedin_user_info']) && $wplc_settings['wplc_loggedin_user_info'] == 1) {
1364
- $wplc_use_loggedin_user_details = 1;
1365
- } else {
1366
- $wplc_use_loggedin_user_details = 0;
1367
- }
1368
-
1369
- if (isset($wplc_settings['wplc_require_user_info']) && ( $wplc_settings['wplc_require_user_info'] == 1 || $wplc_settings['wplc_require_user_info'] == 'name' )) {
1370
- $wplc_ask_user_details = 1;
1371
- } else {
1372
- $wplc_ask_user_details = 0;
1373
- }
1374
-
1375
- $wplc_loggedin_user_name = "";
1376
- $wplc_loggedin_user_email = "";
1377
-
1378
- if ($wplc_use_loggedin_user_details == 1 && is_user_logged_in()) {
1379
- global $current_user;
1380
-
1381
- if ($current_user->data != null) {
1382
- //Logged in. Get name and email
1383
- $wplc_loggedin_user_name = $current_user->user_nicename;
1384
- $wplc_loggedin_user_email = $current_user->user_email;
1385
- }
1386
- } else {
1387
- if ( $wplc_ask_user_details == 0 ) {
1388
- $wplc_loggedin_user_name = stripslashes( $wplc_settings['wplc_user_default_visitor_name'] );
1389
- }
1390
- }
1391
-
1392
- if (isset($wplc_settings['wplc_require_user_info']) && $wplc_settings['wplc_require_user_info'] == 1) {
1393
- //Ask the user to enter name and email
1394
-
1395
- $ret_msg .= "<input type=\"text\" name=\"wplc_name\" id=\"wplc_name\" value='" . $wplc_loggedin_user_name . "' placeholder=\"" . __( "Name", "wplivechat" ) . "\" />";
1396
- $ret_msg .= "<input type=\"text\" name=\"wplc_email\" id=\"wplc_email\" wplc_hide=\"0\" value=\"" . $wplc_loggedin_user_email . "\" placeholder=\"" . __( "Email", "wplivechat" ) . "\" />";
1397
- $ret_msg .= apply_filters( "wplc_start_chat_user_form_after_filter", "" );
1398
-
1399
- } elseif (isset($wplc_settings['wplc_require_user_info']) && $wplc_settings['wplc_require_user_info'] == 'email') {
1400
- /*$ret_msg .= "<div style=\"padding: 7px; text-align: center;\">";
1401
- if (isset($wplc_settings['wplc_user_alternative_text'])) {
1402
- $ret_msg .= html_entity_decode( stripslashes($wplc_settings['wplc_user_alternative_text']) );
1403
- }
1404
- $ret_msg .= '</div>';*/
1405
-
1406
- $wplc_random_user_number = rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9);
1407
- if ($wplc_loggedin_user_name != '') { $wplc_lin = $wplc_loggedin_user_name; } else { $wplc_lin = 'user' . $wplc_random_user_number; }
1408
- $ret_msg .= "<input type=\"hidden\" name=\"wplc_name\" id=\"wplc_name\" value=\"".$wplc_lin."\" />";
1409
- $ret_msg .= "<input type=\"text\" name=\"wplc_email\" id=\"wplc_email\" wplc_hide=\"0\" value=\"" . $wplc_loggedin_user_email . "\" placeholder=\"" . __( "Email", "wplivechat" ) . "\" />";
1410
- $ret_msg .= apply_filters("wplc_start_chat_user_form_after_filter", "");
1411
- } elseif (isset($wplc_settings['wplc_require_user_info']) && $wplc_settings['wplc_require_user_info'] == 'name') {
1412
- /*
1413
- $ret_msg .= "<div style=\"padding: 7px; text-align: center;\">";
1414
- if (isset($wplc_settings['wplc_user_alternative_text'])) {
1415
- $ret_msg .= html_entity_decode( stripslashes($wplc_settings['wplc_user_alternative_text']) );
1416
- }
1417
- $ret_msg .= '</div>';*/
1418
-
1419
- $wplc_random_user_number = rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9);
1420
- if ($wplc_loggedin_user_email != '' && $wplc_loggedin_user_email != null) { $wplc_lie = $wplc_loggedin_user_email; } else { $wplc_lie = $wplc_random_user_number . '@' . $wplc_random_user_number . '.com'; }
1421
- $ret_msg .= "<input type=\"text\" name=\"wplc_name\" id=\"wplc_name\" value='" . $wplc_loggedin_user_name . "' placeholder=\"" . __( "Name", "wplivechat" ) . "\" />";
1422
- $ret_msg .= "<input type=\"hidden\" name=\"wplc_email\" id=\"wplc_email\" wplc_hide=\"1\" value=\"".$wplc_lie."\" />";
1423
- $ret_msg .= apply_filters("wplc_start_chat_user_form_after_filter", "");
1424
- } else {
1425
- //Dont ask the user
1426
-
1427
- $ret_msg .= "<div style=\"padding: 7px; text-align: center;\">";
1428
- if (isset($wplc_settings['wplc_user_alternative_text'])) {
1429
- $ret_msg .= html_entity_decode( stripslashes($wplc_settings['wplc_user_alternative_text']) );
1430
- }
1431
- $ret_msg .= '</div>';
1432
-
1433
- $wplc_random_user_number = rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9);
1434
- //$wplc_loggedin_user_email = $wplc_random_user_number."@".$wplc_random_user_number.".com";
1435
- if ($wplc_loggedin_user_name != '') { $wplc_lin = $wplc_loggedin_user_name; } else { $wplc_lin = 'user' . $wplc_random_user_number; }
1436
- if ($wplc_loggedin_user_email != '' && $wplc_loggedin_user_email != null) { $wplc_lie = $wplc_loggedin_user_email; } else { $wplc_lie = $wplc_random_user_number . '@' . $wplc_random_user_number . '.com'; }
1437
- $ret_msg .= "<input type=\"hidden\" name=\"wplc_name\" id=\"wplc_name\" value=\"".$wplc_lin."\" />";
1438
- $ret_msg .= "<input type=\"hidden\" name=\"wplc_email\" id=\"wplc_email\" wplc_hide=\"1\" value=\"".$wplc_lie."\" />";
1439
- $ret_msg .= apply_filters("wplc_start_chat_user_form_after_filter", "");
1440
- }
1441
- return $ret_msg;
1442
- }
1443
-
1444
-
1445
- /**
1446
- * Filter to control the start chat button
1447
- * @param array $wplc_settings Live chat settings array
1448
- * @return string
1449
- * @since 6.0.00
1450
- * @author Nick Duncan <nick@codecabin.co.za>
1451
- */
1452
- function wplc_filter_control_live_chat_box_html_start_chat_button($wplc_settings,$wplc_using_locale ) {
1453
- $wplc_sst_1 = __('Start chat', 'wplivechat');
1454
- if (!isset($wplc_settings['wplc_pro_sst1']) || $wplc_settings['wplc_pro_sst1'] == "") { $wplc_settings['wplc_pro_sst1'] = $wplc_sst_1; }
1455
- $text = ($wplc_using_locale ? $wplc_sst_1 : stripslashes($wplc_settings['wplc_pro_sst1']));
1456
- $custom_attr = apply_filters('wplc_start_button_custom_attributes_filter', "", $wplc_settings);
1457
- return "<button id=\"wplc_start_chat_btn\" type=\"button\" class='wplc-color-bg-1 wplc-color-2' $custom_attr>$text</button>";
1458
- }
1459
-
1460
-
1461
-
1462
-
1463
- /**
1464
- * Filter to control the hover card start chat button
1465
- * @param array $wplc_settings Live chat settings array
1466
- * @return string
1467
- * @since 6.1.00
1468
- * @author Nick Duncan <nick@codecabin.co.za>
1469
- */
1470
- add_filter("wplc_filter_live_chat_box_hover_html_start_chat_button","wplc_filter_control_live_chat_box_html_hovercard_chat_button",10,4);
1471
- function wplc_filter_control_live_chat_box_html_hovercard_chat_button($content,$wplc_settings,$logged_in,$wplc_using_locale ) {
1472
- if ($logged_in) {
1473
- $wplc_sst_1 = __('Start chat', 'wplivechat');
1474
-
1475
- if (!isset($wplc_settings['wplc_pro_sst1']) || $wplc_settings['wplc_pro_sst1'] == "") { $wplc_settings['wplc_pro_sst1'] = $wplc_sst_1; }
1476
- $text = ($wplc_using_locale ? $wplc_sst_1 : stripslashes($wplc_settings['wplc_pro_sst1']));
1477
- return "<button id=\"speeching_button\" type=\"button\" class='wplc-color-bg-1 wplc-color-2'>$text</button>";
1478
- } else {
1479
- $wplc_sst_1 = stripslashes($wplc_settings['wplc_pro_offline_btn']);
1480
- return "<button id=\"speeching_button\" type=\"button\" class='wplc-color-bg-1 wplc-color-2'>$wplc_sst_1</button>";
1481
-
1482
- }
1483
- }
1484
-
1485
- /**
1486
- * Filter to control the offline message button
1487
- * @param array $wplc_settings Live chat settings array
1488
- * @return string
1489
- * @since 6.0.00
1490
- * @author Nick Duncan <nick@codecabin.co.za>
1491
- */
1492
- function wplc_filter_control_live_chat_box_html_send_offline_message_button($wplc_settings) {
1493
- $wplc_settings = get_option('WPLC_SETTINGS');
1494
- if (isset($wplc_settings['wplc_theme'])) { $wplc_theme = $wplc_settings['wplc_theme']; } else { }
1495
-
1496
- if (isset($wplc_theme)) {
1497
- if($wplc_theme == 'theme-1') {
1498
- $wplc_settings_fill = "#DB0000";
1499
- $wplc_settings_font = "#FFFFFF";
1500
- } else if ($wplc_theme == 'theme-2'){
1501
- $wplc_settings_fill = "#000000";
1502
- $wplc_settings_font = "#FFFFFF";
1503
- } else if ($wplc_theme == 'theme-3'){
1504
- $wplc_settings_fill = "#DB30B3";
1505
- $wplc_settings_font = "#FFFFFF";
1506
- } else if ($wplc_theme == 'theme-4'){
1507
- $wplc_settings_fill = "#1A14DB";
1508
- $wplc_settings_font = "#F7FF0F";
1509
- } else if ($wplc_theme == 'theme-5'){
1510
- $wplc_settings_fill = "#3DCC13";
1511
- $wplc_settings_font = "#FF0808";
1512
- } else if ($wplc_theme == 'theme-6'){
1513
- if ($wplc_settings["wplc_settings_fill"]) {
1514
- $wplc_settings_fill = "#" . $wplc_settings["wplc_settings_fill"];
1515
- } else {
1516
- $wplc_settings_fill = "#ec832d";
1517
- }
1518
- if ($wplc_settings["wplc_settings_font"]) {
1519
- $wplc_settings_font = "#" . $wplc_settings["wplc_settings_font"];
1520
- } else {
1521
- $wplc_settings_font = "#FFFFFF";
1522
- }
1523
- } else {
1524
- if ($wplc_settings["wplc_settings_fill"]) {
1525
- $wplc_settings_fill = "#" . $wplc_settings["wplc_settings_fill"];
1526
- } else {
1527
- $wplc_settings_fill = "#ec832d";
1528
- }
1529
- if ($wplc_settings["wplc_settings_font"]) {
1530
- $wplc_settings_font = "#" . $wplc_settings["wplc_settings_font"];
1531
- } else {
1532
- $wplc_settings_font = "#FFFFFF";
1533
- }
1534
- }
1535
- } else {
1536
- if ($wplc_settings["wplc_settings_fill"]) {
1537
- $wplc_settings_fill = "#" . $wplc_settings["wplc_settings_fill"];
1538
- } else {
1539
- $wplc_settings_fill = "#ec832d";
1540
- }
1541
- if ($wplc_settings["wplc_settings_font"]) {
1542
- $wplc_settings_font = "#" . $wplc_settings["wplc_settings_font"];
1543
- } else {
1544
- $wplc_settings_font = "#FFFFFF";
1545
- }
1546
- }
1547
- $custom_attr = apply_filters('wplc_offline_message_button_custom_attributes_filter', "", $wplc_settings);
1548
- $ret_msg = "<input id=\"wplc_na_msg_btn\" type=\"button\" value=\"".stripslashes($wplc_settings['wplc_pro_offline_btn_send'])."\" style=\"background: ".$wplc_settings_fill." !important; background-color: ".$wplc_settings_fill." !important; color: ".$wplc_settings_font." !important;\" $custom_attr/>";
1549
- return $ret_msg;
1550
- }
1551
-
1552
-
1553
-
1554
- /**
1555
- * Filter to control the 2nd layer of the chat window (online/offline)
1556
- * @param array $wplc_settings Live chat settings array
1557
- * @param bool $logged_in Is the user logged in or not
1558
- * @return string
1559
- * @since 6.0.00
1560
- * @author Nick Duncan <nick@codecabin.co.za>
1561
- */
1562
- function wplc_filter_control_live_chat_box_html_2nd_layer($wplc_settings,$logged_in,$wplc_using_locale, $cid) {
1563
-
1564
- if ($logged_in) {
1565
- $wplc_intro = __('Hello. Please input your details so that I may help you.', 'wplivechat');
1566
- if (!isset($wplc_settings['wplc_pro_intro']) || $wplc_settings['wplc_pro_intro'] == "") { $wplc_settings['wplc_pro_intro'] = $wplc_intro; }
1567
- $text = ($wplc_using_locale ? $wplc_intro : stripslashes($wplc_settings['wplc_pro_intro']));
1568
-
1569
- $ret_msg = "<div id=\"wp-live-chat-2-inner\">";
1570
- $ret_msg .= " <div id=\"wp-live-chat-2-info\" class='wplc-color-4'>";
1571
- $ret_msg .= apply_filters("wplc_filter_intro_text_heading", $text, $wplc_settings);
1572
- $ret_msg .= " </div>";
1573
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_ask_user_details",wplc_filter_control_live_chat_box_html_ask_user_detail($wplc_settings));
1574
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_start_chat_button",wplc_filter_control_live_chat_box_html_start_chat_button($wplc_settings,$wplc_using_locale ), $cid);
1575
- $ret_msg .= "</div>";
1576
- } else {
1577
- if ( isset( $wplc_settings['wplc_loggedin_user_info'] ) && $wplc_settings['wplc_loggedin_user_info'] == 1 ) {
1578
- $wplc_use_loggedin_user_details = 1;
1579
- } else {
1580
- $wplc_use_loggedin_user_details = 0;
1581
- }
1582
-
1583
- $wplc_loggedin_user_name = '';
1584
- $wplc_loggedin_user_email = '';
1585
-
1586
- if ( $wplc_use_loggedin_user_details == 1 ) {
1587
- global $current_user;
1588
-
1589
- if ( $current_user->data != null ) {
1590
- if ( is_user_logged_in() ) {
1591
- //Logged in. Get name and email
1592
- $wplc_loggedin_user_name = $current_user->user_nicename;
1593
- $wplc_loggedin_user_email = $current_user->user_email;
1594
- } else {
1595
- $wplc_loggedin_user_name = stripslashes( $wplc_settings['wplc_user_default_visitor_name'] );
1596
- }
1597
- }
1598
- } else {
1599
- $wplc_loggedin_user_name = '';
1600
- $wplc_loggedin_user_email = '';
1601
- }
1602
-
1603
- /* admin not logged in, show offline messages */
1604
- $wplc_offline = __("We are currently offline. Please leave a message and we'll get back to you shortly.", "wplivechat");
1605
- $text = ($wplc_using_locale ? $wplc_offline : stripslashes($wplc_settings['wplc_pro_offline1']));
1606
-
1607
- $ret_msg = "<div id=\"wp-live-chat-2-info\" class=\"wplc-color-bg-1 wplc-color-2\">";
1608
- $ret_msg .= $text;
1609
- $ret_msg .= "</div>";
1610
- $ret_msg .= "<div id=\"wplc_message_div\">";
1611
- $ret_msg .= "<input type=\"text\" name=\"wplc_name\" id=\"wplc_name\" value=\"$wplc_loggedin_user_name\" placeholder=\"".__("Name", "wplivechat")."\" />";
1612
- $ret_msg .= "<input type=\"text\" name=\"wplc_email\" id=\"wplc_email\" value=\"$wplc_loggedin_user_email\" placeholder=\"".__("Email", "wplivechat")."\" />";
1613
- $ret_msg .= "<textarea name=\"wplc_message\" id=\"wplc_message\" placeholder=\"".__("Message", "wplivechat")."\"></textarea>";
1614
-
1615
- if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != '') {
1616
- $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
1617
- } else {
1618
- $ip_address = $_SERVER['REMOTE_ADDR'];
1619
- }
1620
-
1621
- /** DEPRECATED BY GDPR */
1622
- /*if(isset($wplc_settings['wplc_record_ip_address']) && $wplc_settings['wplc_record_ip_address'] == 1) { $offline_ip_address = $ip_address; } else { $offline_ip_address = ""; }*/
1623
-
1624
- $offline_ip_address = "";
1625
-
1626
- $ret_msg .= "<input type=\"hidden\" name=\"wplc_ip_address\" id=\"wplc_ip_address\" value=\"".$offline_ip_address."\" />";
1627
- $ret_msg .= "<input type=\"hidden\" name=\"wplc_domain_offline\" id=\"wplc_domain_offline\" value=\"".site_url()."\" />";
1628
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_send_offline_message_button",wplc_filter_control_live_chat_box_html_send_offline_message_button($wplc_settings));
1629
- $ret_msg .= "</div>";
1630
-
1631
-
1632
-
1633
- }
1634
- $data = array(
1635
- 'ret_msg' => $ret_msg,
1636
- 'wplc_settings' => $wplc_settings,
1637
- 'logged_in' => $logged_in,
1638
- 'wplc_using_locale' => $wplc_using_locale
1639
- );
1640
-
1641
-
1642
- $ret_msg = apply_filters( "wplc_filter_2nd_layer_modify" , $data );
1643
- if( is_array( $ret_msg ) ){
1644
- /* if nothing uses this filter is comes back as an array, so return the original message in that array */
1645
- return $ret_msg['ret_msg'];
1646
- } else {
1647
- return $ret_msg;
1648
- }
1649
- }
1650
-
1651
- /**
1652
- * Filter to control the 3rd layer of the chat window
1653
- * @param array $wplc_settings live chat settings array
1654
- * @return string
1655
- * @since 6.0.00
1656
- * @author Nick Duncan <nick@codecabin.co.za>
1657
- */
1658
- function wplc_filter_control_live_chat_box_html_3rd_layer($wplc_settings,$wplc_using_locale) {
1659
-
1660
- $wplc_sst_2 = __('Connecting. Please be patient...', 'wplivechat');
1661
- if (!isset($wplc_settings['wplc_pro_sst2']) || $wplc_settings['wplc_pro_sst2'] == "") { $wplc_settings['wplc_pro_sst2'] = $wplc_sst_2; }
1662
- $text = ($wplc_using_locale ? $wplc_sst_2 : stripslashes($wplc_settings['wplc_pro_sst2']));
1663
-
1664
- $ret_msg = "<p class=''wplc-color-4>".$text."</p>";
1665
- return $ret_msg;
1666
- }
1667
-
1668
- add_filter("wplc_filter_intro_text_heading", "wplc_filter_control_intro_text_heading", 10, 2);
1669
- /**
1670
- * Filters intro text
1671
- */
1672
- function wplc_filter_control_intro_text_heading($content, $wplc_settings){
1673
-
1674
- if (isset($wplc_settings['wplc_require_user_info']) && $wplc_settings['wplc_require_user_info'] == 1) {
1675
-
1676
- } elseif (isset($wplc_settings['wplc_require_user_info']) && $wplc_settings['wplc_require_user_info'] == 'email') {
1677
-
1678
- } elseif (isset($wplc_settings['wplc_require_user_info']) && $wplc_settings['wplc_require_user_info'] == 'name') {
1679
-
1680
- } else {
1681
- $content = "";
1682
- }
1683
-
1684
- return $content;
1685
- }
1686
-
1687
-
1688
- add_filter("wplc_filter_live_chat_box_above_main_div","wplc_filter_control_live_chat_box_above_main_div",10,3);
1689
- function wplc_filter_control_live_chat_box_above_main_div( $msg, $wplc_settings, $cid ) {
1690
- if(!isset($wplc_settings['wplc_newtheme'])){ $wplc_settings['wplc_newtheme'] = "theme-2"; }
1691
- if (isset($wplc_settings['wplc_newtheme']) && $wplc_settings['wplc_newtheme'] == "theme-2") {
1692
-
1693
- $agent_info = '';
1694
- $cbox_header_bg = '';
1695
- $agent_tagline = '';
1696
- $agent_bio = '';
1697
-
1698
- $a_twitter = '';
1699
- $a_linkedin = '';
1700
- $a_facebook = '';
1701
- $a_website = '';
1702
- $social_links = '';
1703
- $agent_string = '';
1704
-
1705
- if(isset($wplc_settings['wplc_use_node_server']) && intval($wplc_settings['wplc_use_node_server']) == 1) {} else {
1706
- if ( $cid ) {
1707
- $cid = wplc_return_chat_id_by_rel($cid);
1708
- $chat_data = wplc_get_chat_data( $cid );
1709
-
1710
- if ( isset( $chat_data->agent_id ) ) {
1711
- $agent_id = intval( $chat_data->agent_id );
1712
- } else {
1713
- $agent_id = get_current_user_id();
1714
- }
1715
-
1716
- if ( $agent_id ) {
1717
-
1718
- $wplc_acbc_data = get_option("WPLC_ACBC_SETTINGS");
1719
- $user_info = get_userdata( $agent_id );
1720
-
1721
-
1722
- if( isset( $wplc_acbc_data['wplc_use_wp_name'] ) && $wplc_acbc_data['wplc_use_wp_name'] == '1' ){
1723
-
1724
- $agent = $user_info->display_name;
1725
- } else {
1726
- if (!empty($wplc_acbc_data['wplc_chat_name'])) {
1727
- $agent = $wplc_acbc_data['wplc_chat_name'];
1728
- } else {
1729
- $agent = 'Admin';
1730
- }
1731
- }
1732
- $cbox_header_bg = "style='background-image:url(https://www.gravatar.com/avatar/".md5($user_info->user_email)."?s=380); no-repeat; cover;'";
1733
-
1734
- $extra = apply_filters( "wplc_filter_further_live_chat_box_above_main_div", '', $wplc_settings, $cid, $chat_data, $agent );
1735
-
1736
- $agent_string = '
1737
- <p style="text-align:center;">
1738
- <img class="img-thumbnail img-circle wplc_thumb32 wplc_agent_involved" style="max-width:inherit;" id="agent_grav_'.$agent_id.'" title="'.$agent.'" src="https://www.gravatar.com/avatar/'.md5($user_info->user_email).'?s=60" /><br />
1739
- <span class="wplc_agent_name wplc-color-2">'.$agent.'</span>
1740
- '.$extra.'
1741
- <span class="bleeper_pullup down"><i class="fa fa-angle-up"></i></span>
1742
- </p>';
1743
-
1744
- }
1745
- }
1746
-
1747
- }
1748
-
1749
- $msg .= "<div id='wplc_chatbox_header_bg' ".$cbox_header_bg."><div id='wplc_chatbox_header' class='wplc-color-bg-1 wplc-color-4'><div class='wplc_agent_info'>".$agent_string."</div></div></div>";
1750
-
1751
- }
1752
- return $msg;
1753
- }
1754
-
1755
- /**
1756
- * Filter to control the 4th layer of the chat window
1757
- * @param array $wplc_settings live chat settings array
1758
- * @return string
1759
- * @since 6.0.00
1760
- * @author Nick Duncan <nick@codecabin.co.za>
1761
- */
1762
- function wplc_filter_control_live_chat_box_html_4th_layer($wplc_settings,$wplc_using_locale, $cid ) {
1763
- $wplc_enter = __('Connecting. Please be patient...', 'wplivechat');
1764
- if (!isset($wplc_settings['wplc_user_enter']) || $wplc_settings['wplc_user_enter'] == "") { $wplc_settings['wplc_pro_sst2'] = $wplc_enter; }
1765
- $text = ($wplc_using_locale ? $wplc_enter : stripslashes($wplc_settings['wplc_user_enter']));
1766
-
1767
- $wplc_welcome = __('Welcome. How may I help you?', 'wplivechat');
1768
- if (!isset($wplc_settings['wplc_user_welcome_chat']) || $wplc_settings['wplc_user_welcome_chat'] == "") { $wplc_settings['wplc_user_welcome_chat'] = $wplc_welcome; }
1769
- $text2 = ($wplc_using_locale ? $wplc_welcome : stripslashes($wplc_settings['wplc_user_welcome_chat']));
1770
-
1771
-
1772
-
1773
-
1774
-
1775
- $ret_msg = "";
1776
- if(!isset($wplc_settings['wplc_newtheme'])){ $wplc_settings['wplc_newtheme'] = "theme-2"; }
1777
- if (isset($wplc_settings['wplc_newtheme']) && $wplc_settings['wplc_newtheme'] == 'theme-1') {
1778
- $ret_msg .= apply_filters("wplc_filter_typing_control_div","");
1779
- }
1780
-
1781
- $ret_msg .= apply_filters("wplc_filter_inner_live_chat_box_4th_layer","", $wplc_settings);
1782
-
1783
- $ret_msg .= "<div id=\"wplc_sound_update\" style=\"height:0; width:0; display:none; border:0;\"></div>";
1784
-
1785
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_above_main_div","",$wplc_settings, $cid);
1786
-
1787
-
1788
- $ret_msg .= "<div id=\"wplc_chatbox\">";
1789
- // $ret_msg .= "<span class='wplc-admin-message'>";
1790
- // $ret_msg .= $text2;
1791
- // $ret_msg .= "</span>";
1792
- // $ret_msg .= "<br />";
1793
- // $ret_msg .= "<div class='wplc-clear-float-message'></div>";
1794
- $ret_msg .= "</div>";
1795
-
1796
- $ret_msg .= "<div id='bleeper_chat_ended' style='display:none;'></div>";
1797
- $ret_msg .= "<div id='wplc_user_message_div'>";
1798
-
1799
- $ret_msg .= "<p id='wplc_msg_notice'>".$text."</p>";
1800
-
1801
- //Editor Controls
1802
- $ret_msg .= apply_filters("wplc_filter_chat_text_editor","");
1803
-
1804
- $ret_msg .= "<p>";
1805
- $placeholder = __('Type here','wplivechat');
1806
- $ret_msg .= "<textarea type=\"text\" name=\"wplc_chatmsg\" id=\"wplc_chatmsg\" placeholder=\"".$placeholder."\" onclick=\"jQuery(this).select();\" class='wdt-emoji-bundle-enabled'></textarea>";
1807
- if(!isset($wplc_settings['wplc_newtheme'])){ $wplc_settings['wplc_newtheme'] = "theme-2"; }
1808
- if (isset($wplc_settings['wplc_newtheme']) && $wplc_settings['wplc_newtheme'] == 'theme-2') {
1809
- $ret_msg .= apply_filters("wplc_filter_typing_control_div_theme_2","");
1810
- }
1811
-
1812
- //Upload Controls
1813
- $ret_msg .= apply_filters("wplc_filter_chat_upload","");
1814
-
1815
- $ret_msg .= "<input type=\"hidden\" name=\"wplc_cid\" id=\"wplc_cid\" value=\"\" />";
1816
- $ret_msg .= "<input id=\"wplc_send_msg\" type=\"button\" value=\"".__("Send", "wplivechat")."\" style=\"display:none;\" />";
1817
- $ret_msg .= "</p>";
1818
-
1819
- $ret_msg .= function_exists("wplc_emoji_selector_div") ? wplc_emoji_selector_div() : "";
1820
-
1821
- $current_theme = isset($wplc_settings['wplc_newtheme']) ? $wplc_settings['wplc_newtheme'] : "theme-2";
1822
- if($current_theme === "theme-2"){
1823
- $ret_msg .= apply_filters("wplc_filter_chat_4th_layer_below_input","", $wplc_settings); //Ratings/Social Icon Filter
1824
- }
1825
-
1826
- $ret_msg .= "</div>";
1827
- $ret_msg .= "</div>";
1828
- return $ret_msg;
1829
- }
1830
-
1831
- /**
1832
- * Filter to control the 1st layer of the chat window
1833
- * @param array $wplc_settings live chat settings array
1834
- * @param bool $logged_in Is the admin logged in or not
1835
- * @param bool $wplc_using_locale Are they using a localization plugin
1836
- * @return string
1837
- * @since 6.0.00
1838
- * @author Nick Duncan <nick@codecabin.co.za>
1839
- */
1840
- function wplc_filter_control_live_chat_box_html_1st_layer($wplc_settings,$logged_in,$wplc_using_locale, $class_override = false) {
1841
-
1842
- $ret_msg = "<div id='wplc_first_message'>";
1843
-
1844
- if(!isset($wplc_settings['wplc_newtheme'])){ $wplc_settings['wplc_newtheme'] = "theme-2"; }
1845
-
1846
- if ($logged_in) {
1847
- $wplc_fst_1 = __('Questions?', 'wplivechat');
1848
- $wplc_fst_2 = __('Chat with us', 'wplivechat');
1849
- if (isset($wplc_settings['wplc_newtheme']) && $wplc_settings['wplc_newtheme'] == "theme-2") {
1850
- $coltheme = "wplc-color-4";
1851
- } else {
1852
- $coltheme = "wplc-color-2";
1853
- }
1854
-
1855
- if($class_override){
1856
- //Override color class
1857
- $coltheme = $class_override;
1858
- }
1859
-
1860
- $wplc_tl_msg = "<div class='$coltheme'><strong>" . ($wplc_using_locale ? $wplc_fst_1 : stripslashes($wplc_settings['wplc_pro_fst1'])) . "</strong> " . ( $wplc_using_locale ? $wplc_fst_2 : stripslashes($wplc_settings['wplc_pro_fst2'])) ."</div>";
1861
-
1862
- $ret_msg .= $wplc_tl_msg;
1863
- } else {
1864
-
1865
-
1866
- $wplc_na = __('Chat offline. Leave a message', 'wplivechat');
1867
- $wplc_tl_msg = "<span class='wplc_offline'>" . ($wplc_using_locale ? $wplc_na : stripslashes($wplc_settings['wplc_pro_na'])) . "</span>";
1868
- $ret_msg .= $wplc_tl_msg;
1869
- }
1870
- $ret_msg .= "</div>";
1871
-
1872
-
1873
-
1874
- return $ret_msg;
1875
-
1876
- }
1877
-
1878
- /**
1879
- * Build the initiate teaser
1880
- * @return void
1881
- * @since 6.0.00
1882
- * @author Nick Duncan <nick@codecabin.co.za>
1883
- */
1884
- add_filter( 'wplc_filter_list_chats_actions', 'wplc_initiate_chat_button', 12, 3);
1885
- function wplc_initiate_chat_button($actions,$result,$post_data) {
1886
-
1887
-
1888
- if(intval($result->status) == 5 ){
1889
- $actions = "<a href=\"javascript:void(0);\" id=\"wplc_initiate_chat\" class=\"wplc_initiate_chat button button-secondary\">".__("Initiate Chat","wplivechat")."</a>";
1890
- }
1891
- return $actions;
1892
- }
1893
-
1894
-
1895
- add_filter("wplc_loggedin_filter","wplc_filter_control_loggedin",10,1);
1896
- function wplc_filter_control_loggedin($logged_in) {
1897
- $wplc_is_admin_logged_in = get_transient("wplc_is_admin_logged_in");
1898
-
1899
- if (!function_exists("wplc_register_pro_version") && $wplc_is_admin_logged_in != 1) {
1900
- $logged_in = false;
1901
- } else {
1902
- $logged_in = true;
1903
- }
1904
-
1905
- $logged_in_checks = apply_filters("wplc_filter_is_admin_logged_in",array());
1906
-
1907
- /* if we are logged in ANYWHERE, set this to true */
1908
- foreach($logged_in_checks as $key => $val) {
1909
- if ($val) { $logged_in = true; break; }
1910
- }
1911
- $logged_in_via_app = false;
1912
- if (isset($logged_in_checks['app']) && $logged_in_checks['app'] == true) { $logged_in_via_app = true; }
1913
-
1914
- $logged_in = apply_filters("wplc_final_loggedin_control",$logged_in,$logged_in_via_app);
1915
-
1916
- /* admin is using the basic version and is logged in */
1917
- if ($wplc_is_admin_logged_in) { $logged_in = true; }
1918
-
1919
- return $logged_in;
1920
- }
1921
-
1922
- function wplc_shortenurl($url) {
1923
- if ( strlen($url) > 45) {
1924
- return substr($url, 0, 30)."[...]".substr($url, -15);
1925
- } else {
1926
- return $url;
1927
- }
1928
- }
1929
-
1930
-
1931
- /**
1932
- * The function that builds the chat box
1933
- * @since 6.0.00
1934
- * @author Nick Duncan <nick@codecabin.co.za>
1935
- * @return JSON encoded HTML
1936
- */
1937
- function wplc_output_box_ajax_new($cid = null) {
1938
-
1939
-
1940
- $ret_msg = array();
1941
- $logged_in = false;
1942
-
1943
- $wplc_settings = get_option("WPLC_SETTINGS");
1944
-
1945
- if(isset($wplc_settings['wplc_using_localization_plugin']) && $wplc_settings['wplc_using_localization_plugin'] == 1){ $wplc_using_locale = true; } else { $wplc_using_locale = false; }
1946
-
1947
-
1948
- $logged_in = apply_filters("wplc_loggedin_filter",false);
1949
-
1950
- $ret_msg['cbox'] = apply_filters("wplc_theme_control",$wplc_settings,$logged_in,$wplc_using_locale,$cid);
1951
-
1952
- $ret_msg['online'] = $logged_in;
1953
-
1954
- global $wplc_pro_version;
1955
- $wplc_ver = str_replace('.', '', $wplc_pro_version);
1956
- $checker = intval($wplc_ver);
1957
-
1958
- if ($cid !== null && $cid !== '') {
1959
- $ret_msg['cid'] = $cid;
1960
- $chat_data = wplc_get_chat_data( $cid );
1961
- wplc_record_chat_notification('user_loaded',$cid,array('uri' => $_SERVER['HTTP_REFERER'], 'chat_data' => $chat_data ));
1962
-
1963
-
1964
-
1965
- if ( !isset($chat_data) || !$chat_data->agent_id ) {
1966
- $ret_msg['type'] = 'new';
1967
- } else {
1968
- $ret_msg['type'] = 'returning';
1969
-
1970
- if(isset($wplc_settings['wplc_use_node_server']) && intval($wplc_settings['wplc_use_node_server']) == 1) {
1971
- //This is using node, we shouldn't generate the header data as part of the chat box.
1972
- //We will do this dynamically on the front end
1973
-
1974
- //var_dump("NOPEEE");
1975
-
1976
- } else {
1977
- /* build the AGENT DATA array */
1978
- $wplc_acbc_data = get_option("WPLC_ACBC_SETTINGS");
1979
- $user_info = get_userdata( intval( $chat_data->agent_id ) );
1980
-
1981
- $agent_tagline = '';
1982
- $agent_bio = '';
1983
- $a_twitter = '';
1984
- $a_linkedin = '';
1985
- $a_facebook = '';
1986
- $a_website = '';
1987
- $social_links = '';
1988
-
1989
- if( isset( $wplc_acbc_data['wplc_use_wp_name'] ) && $wplc_acbc_data['wplc_use_wp_name'] == '1' ){
1990
-
1991
- $agent = $user_info->display_name;
1992
- } else {
1993
- if (!empty($wplc_acbc_data['wplc_chat_name'])) {
1994
- $agent = $wplc_acbc_data['wplc_chat_name'];
1995
- } else {
1996
- $agent = 'Admin';
1997
- }
1998
- }
1999
-
2000
- if( !isset( $data ) ){ $data = false; }
2001
-
2002
- $agent_tagline = apply_filters( "wplc_filter_agent_data_agent_tagline", $agent_tagline, $cid, $chat_data, $agent, $wplc_acbc_data, $user_info, $data );
2003
- $agent_bio = apply_filters( "wplc_filter_agent_data_agent_bio", $agent_bio, $cid, $chat_data, $agent, $wplc_acbc_data, $user_info, $data );
2004
- $social_links = apply_filters( "wplc_filter_agent_data_social_links", $social_links, $cid, $chat_data, $agent, $wplc_acbc_data, $user_info, $data);
2005
-
2006
- $ret_msg['agent_data'] = array(
2007
- 'email' => md5($user_info->user_email),
2008
- 'name' => $agent,
2009
- 'aid' => $user_info->ID,
2010
- 'agent_tagline' => $agent_tagline,
2011
- 'agent_bio' => $agent_bio,
2012
- "social_links" => $social_links
2013
- );
2014
- }
2015
-
2016
- }
2017
-
2018
-
2019
- } else {
2020
- $ret_msg['type'] = 'new';
2021
- }
2022
-
2023
-
2024
- if (function_exists("wplc_pro_version_control")) {
2025
- if ($checker < 6000) {
2026
- /* backwards compatibilitty for the old pro version */
2027
- return json_encode($ret_msg['cbox']);
2028
- } else {
2029
- return json_encode($ret_msg);
2030
- }
2031
-
2032
- } else {
2033
- return json_encode($ret_msg);
2034
- }
2035
-
2036
-
2037
-
2038
-
2039
-
2040
-
2041
- }
2042
- function wplc_return_default_theme($wplc_settings,$logged_in,$wplc_using_locale,$cid) {
2043
- $ret_msg = apply_filters("wplc_filter_live_chat_box_html_main_div_top",wplc_filter_control_live_chat_box_html_main_div_top($wplc_settings,$logged_in,$wplc_using_locale));
2044
- $ret_msg .= "<div class=\"wp-live-chat-wraper\">";
2045
- $ret_msg .= "<div id='bleeper_bell' class='wplc-color-bg-1 wplc-color-2' style='display:none;'><i class='fa fa-bell'></i></div>";
2046
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_header_div_top",wplc_filter_control_live_chat_box_html_header_div_top($wplc_settings));
2047
- $ret_msg .= " <i id=\"wp-live-chat-minimize\" class=\"fa fa-minus wplc-color-bg-2 wplc-color-1\" style=\"display:none;\"></i>";
2048
- $ret_msg .= " <i id=\"wp-live-chat-close\" class=\"fa fa-times\" style=\"display:none;\" ></i>";
2049
- $ret_msg .= " <div id=\"wp-live-chat-1\" >";
2050
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_1st_layer",wplc_filter_control_live_chat_box_html_1st_layer($wplc_settings,$logged_in,$wplc_using_locale,'wplc-color-2'));
2051
- $ret_msg .= " </div>";
2052
- $ret_msg .= '<div id="wplc-chat-alert" class="wplc-chat-alert wplc-chat-alert--' . $wplc_settings["wplc_theme"] . '"></div>';
2053
- $ret_msg .= " </div>";
2054
- $ret_msg .= " <div id=\"wp-live-chat-2\" style=\"display:none;\">";
2055
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_survey","");
2056
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_2nd_layer",wplc_filter_control_live_chat_box_html_2nd_layer($wplc_settings,$logged_in,$wplc_using_locale,$cid), $cid);
2057
- $ret_msg .= " </div>";
2058
- $ret_msg .= " <div id=\"wp-live-chat-3\" style=\"display:none;\">";
2059
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_3rd_layer",wplc_filter_control_live_chat_box_html_3rd_layer($wplc_settings,$wplc_using_locale));
2060
- $ret_msg .= " </div>";
2061
- $ret_msg .= " <div id=\"wp-live-chat-react\" style=\"display:none;\">";
2062
- $ret_msg .= " <p>".__("Reactivating your previous chat...", "wplivechat")."</p>";
2063
- $ret_msg .= " </div>";
2064
- $ret_msg .= " <div id=\"wplc-extra-div\" style=\"display:none;\">";
2065
- $ret_msg .= apply_filters("wplc_filter_wplc_extra_div","",$wplc_settings,$wplc_using_locale);
2066
- $ret_msg .= "</div>";
2067
- $ret_msg .= "</div>";
2068
- $ret_msg .= " <div id=\"wp-live-chat-4\" style=\"display:none;\">";
2069
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_4th_layer",wplc_filter_control_live_chat_box_html_4th_layer($wplc_settings,$wplc_using_locale, $cid));
2070
- $ret_msg .= "</div>";
2071
- return $ret_msg;
2072
- }
2073
-
2074
-
2075
- add_filter("wplc_theme_control","wplc_theme_control_function",10,4);
2076
- function wplc_theme_control_function($wplc_settings,$logged_in,$wplc_using_locale, $cid) {
2077
-
2078
- if (!$wplc_settings) { return ""; }
2079
- if (isset($wplc_settings['wplc_newtheme'])) { $wplc_newtheme = $wplc_settings['wplc_newtheme']; } else { $wplc_newtheme = "theme-2"; }
2080
-
2081
- $default_theme = wplc_return_default_theme($wplc_settings,$logged_in,$wplc_using_locale, $cid);
2082
- if (isset($wplc_newtheme)) {
2083
-
2084
-
2085
-
2086
-
2087
-
2088
-
2089
-
2090
- if($wplc_newtheme == 'theme-1') {
2091
- $ret_msg = $default_theme;
2092
-
2093
- }
2094
- else if($wplc_newtheme == 'theme-2') {
2095
- $ret_msg = apply_filters("wplc_filter_live_chat_box_html_main_div_top",wplc_filter_control_live_chat_box_html_main_div_top($wplc_settings,$logged_in,$wplc_using_locale));
2096
- $ret_msg .= "<div class=\"wp-live-chat-wraper\">";
2097
- $ret_msg .= "<div id='bleeper_bell' class='wplc-color-bg-1 wplc-color-2' style='display:none;'><i class='fa fa-bell'></i></div>";
2098
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_header_div_top",wplc_filter_control_live_chat_box_html_header_div_top($wplc_settings));
2099
- $ret_msg .= " </div>";
2100
- $ret_msg .= '<div id="wplc-chat-alert" class="wplc-chat-alert wplc-chat-alert--' . $wplc_settings["wplc_theme"] . '"></div>';
2101
- $ret_msg .= " <div id=\"wp-live-chat-2\" style=\"display:none;\">";
2102
- $ret_msg .= " <i id=\"wp-live-chat-minimize\" class=\"fa fa-minus wplc-color-bg-2 wplc-color-1\" style=\"display:none;\" ></i>";
2103
- $ret_msg .= " <i id=\"wp-live-chat-close\" class=\"fa fa-times\" style=\"display:none;\" ></i>";
2104
- $ret_msg .= " <div id=\"wplc-extra-div\" style=\"display:none;\">";
2105
- $ret_msg .= apply_filters("wplc_filter_wplc_extra_div","",$wplc_settings,$wplc_using_locale);
2106
- $ret_msg .= " </div>";
2107
- $ret_msg .= " <div id='wp-live-chat-inner-container'>";
2108
- $ret_msg .= " <div id='wp-live-chat-inner'>";
2109
- $ret_msg .= " <div id=\"wp-live-chat-1\" class=\"wplc-color-2 wplc-color-bg-1\" >";
2110
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_1st_layer",wplc_filter_control_live_chat_box_html_1st_layer($wplc_settings,$logged_in,$wplc_using_locale,'wplc-color-2'));
2111
- $ret_msg .= " </div>";
2112
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_2nd_layer",wplc_filter_control_live_chat_box_html_2nd_layer($wplc_settings,$logged_in,$wplc_using_locale, $cid), $cid);
2113
- $ret_msg .= " </div>";
2114
- $ret_msg .= " <div id=\"wp-live-chat-react\" style=\"display:none;\">";
2115
- $ret_msg .= " <p>".__("Reactivating your previous chat...", "wplivechat")."</p>";
2116
- $ret_msg .= " </div>";
2117
- $ret_msg .= " </div>";
2118
- $ret_msg .= " <div id=\"wp-live-chat-3\" style=\"display:none;\">";
2119
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_3rd_layer",wplc_filter_control_live_chat_box_html_3rd_layer($wplc_settings,$wplc_using_locale));
2120
- $ret_msg .= " </div>";
2121
- $ret_msg .= " </div>";
2122
- $ret_msg .= " <div id=\"wp-live-chat-4\" style=\"display:none;\">";
2123
- $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_4th_layer",wplc_filter_control_live_chat_box_html_4th_layer($wplc_settings,$wplc_using_locale, $cid));
2124
- $ret_msg .= " </div>";
2125
-
2126
- $ret_msg .= "</div>";
2127
-
2128
- } else {
2129
- $ret_msg = $default_theme;
2130
- }
2131
- } else {
2132
- $ret_msg = $default_theme;
2133
- }
2134
-
2135
- return $ret_msg;
2136
- }
2137
-
2138
-
2139
- /**
2140
- * THIS FUNCTION ONLY RUNS IF THE PRO VERSION IS LESS THAN 5.0.1
2141
- * The new method is being handled with ajax
2142
- * @return void
2143
- */
2144
- function wplc_display_box() {
2145
-
2146
- global $wplc_pro_version;
2147
- $wplc_ver = str_replace('.', '', $wplc_pro_version);
2148
- $checker = intval($wplc_ver);
2149
-
2150
- if (function_exists("wplc_pro_version_control") && ($checker <= 501 || $checker == 4410)) {
2151
- /* prior to latest pro version with ajax handling */
2152
-
2153
- if(function_exists('wplc_display_chat_contents')){
2154
- $display_contents = wplc_display_chat_contents();
2155
- } else {
2156
- $display_contents = 1;
2157
- }
2158
-
2159
- if(function_exists('wplc_is_user_banned_basic')){
2160
- $user_banned = wplc_is_user_banned_basic();
2161
- } else {
2162
- $user_banned = 0;
2163
- }
2164
- if($display_contents && $user_banned == 0){
2165
- $wplc_is_admin_logged_in = get_transient("wplc_is_admin_logged_in");
2166
- if ($wplc_is_admin_logged_in != 1) {
2167
- echo "<!-- wplc a-n-c -->";
2168
- }
2169
-
2170
- /* do not show if pro is outdated */
2171
- global $wplc_pro_version;
2172
- if (isset($wplc_pro_version)) {
2173
- $float_version = floatval($wplc_pro_version);
2174
- if ($float_version < 4 || $wplc_pro_version == "4.1.0" || $wplc_pro_version == "4.1.1") {
2175
- return;
2176
- }
2177
- }
2178
-
2179
- if (function_exists("wplc_register_pro_version")) {
2180
- $wplc_settings = get_option("WPLC_SETTINGS");
2181
- if (!class_exists('Mobile_Detect')) {
2182
- require_once (plugin_dir_path(__FILE__) . 'includes/Mobile_Detect.php');
2183
- }
2184
- $wplc_detect_device = new Mobile_Detect;
2185
- $wplc_is_mobile = $wplc_detect_device->isMobile();
2186
- if ($wplc_is_mobile && !isset($wplc_settings['wplc_enabled_on_mobile']) && $wplc_settings['wplc_enabled_on_mobile'] != 1) {
2187
- return;
2188
- }
2189
- if (function_exists('wplc_basic_hide_chat_when_offline')) {
2190
- $wplc_hide_chat = wplc_basic_hide_chat_when_offline();
2191
- if (!$wplc_hide_chat) {
2192
- wplc_pro_draw_user_box();
2193
- }
2194
- } else {
2195
- wplc_pro_draw_user_box();
2196
- }
2197
- } else {
2198
- wplc_draw_user_box();
2199
- }
2200
- }
2201
- }
2202
- }
2203
- function wplc_display_box_ajax() {
2204
-
2205
- if(function_exists('wplc_display_chat_contents')){
2206
- $display_contents = wplc_display_chat_contents();
2207
- } else {
2208
- $display_contents = 1;
2209
- }
2210
-
2211
- if(function_exists('wplc_is_user_banned')){
2212
- $user_banned = wplc_is_user_banned();
2213
- } else if (function_exists('wplc_is_user_banned')){
2214
- $user_banned = wplc_is_user_banned_basic();
2215
- } else {
2216
- $user_banned = 0;
2217
- }
2218
- if($display_contents && $user_banned == 0){
2219
- $wplc_is_admin_logged_in = get_transient("wplc_is_admin_logged_in");
2220
- if ($wplc_is_admin_logged_in != 1) {
2221
- return "";
2222
- }
2223
-
2224
- /* do not show if pro is outdated */
2225
- global $wplc_pro_version;
2226
- if (isset($wplc_pro_version)) {
2227
- $float_version = floatval($wplc_pro_version);
2228
- if ($float_version < 4 || $wplc_pro_version == "4.1.0" || $wplc_pro_version == "4.1.1") {
2229
- return;
2230
- }
2231
- }
2232
-
2233
- if (function_exists("wplc_register_pro_version")) {
2234
- $wplc_settings = get_option("WPLC_SETTINGS");
2235
- if (!class_exists('Mobile_Detect')) {
2236
- require_once (plugin_dir_path(__FILE__) . 'includes/Mobile_Detect.php');
2237
- }
2238
- $wplc_detect_device = new Mobile_Detect;
2239
- $wplc_is_mobile = $wplc_detect_device->isMobile();
2240
- if ($wplc_is_mobile && !isset($wplc_settings['wplc_enabled_on_mobile']) && $wplc_settings['wplc_enabled_on_mobile'] != 1) {
2241
- return;
2242
- }
2243
- if (function_exists('wplc_basic_hide_chat_when_offline')) {
2244
- $wplc_hide_chat = wplc_basic_hide_chat_when_offline();
2245
- if (!$wplc_hide_chat) {
2246
- wplc_pro_draw_user_box();
2247
- }
2248
- } else {
2249
- wplc_pro_draw_user_box();
2250
- }
2251
- } else {
2252
- wplc_draw_user_box();
2253
- }
2254
- }
2255
- }
2256
-
2257
- function wplc_admin_display_chat($cid) {
2258
- global $wpdb;
2259
- global $wplc_tblname_msgs;
2260
- $results = $wpdb->get_results(
2261
- "
2262
- SELECT *
2263
- FROM $wplc_tblname_msgs
2264
- WHERE `chat_sess_id` = '$cid'
2265
- ORDER BY `timestamp` DESC
2266
- LIMIT 0, 100
2267
- "
2268
- );
2269
- foreach ($results as $result) {
2270
- $from = $result->msgfrom;
2271
- $msg = stripslashes($result->msg);
2272
- $msg_hist .= "$from: $msg<br />";
2273
- }
2274
- echo $msg_hist;
2275
- }
2276
-
2277
- function wplc_admin_accept_chat($cid) {
2278
- $user_ID = get_current_user_id();
2279
- wplc_change_chat_status(sanitize_text_field($cid), 3,$user_ID);
2280
- return true;
2281
- }
2282
-
2283
- add_action('admin_head', 'wplc_update_chat_statuses');
2284
-
2285
-
2286
- //add_action("wplc_hook_superadmin_head","wplc_hook_control_superadmin_head",10);
2287
- // Deprecated as this as now been added to wplc_heartbeat.js
2288
- function wplc_hook_control_superadmin_head() {
2289
- $wplc_current_user = get_current_user_id();
2290
-
2291
- if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true )) {
2292
- $ajax_nonce = wp_create_nonce("wplc");
2293
- ?>
2294
- <script type="text/javascript">
2295
- jQuery(function () {
2296
-
2297
-
2298
- var wplc_set_transient = null;
2299
-
2300
- wplc_set_transient = setInterval(function () {
2301
- wpcl_admin_set_transient();
2302
- }, 60000);
2303
- wpcl_admin_set_transient();
2304
- function wpcl_admin_set_transient() {
2305
- var data = {
2306
- action: 'wplc_admin_set_transient',
2307
- security: '<?php echo $ajax_nonce; ?>'
2308
-
2309
- };
2310
- jQuery.post(ajaxurl, data, function (response) {
2311
-
2312
- });
2313
- }
2314
-
2315
- });
2316
- </script>
2317
- <?php
2318
- }
2319
- }
2320
-
2321
-
2322
- function wplc_superadmin_javascript() {
2323
- $wplc_settings = get_option("WPLC_SETTINGS");
2324
-
2325
- if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1 && (!isset($_GET['action']) || $_GET['action'] !== "history") ){
2326
-
2327
- //Using node, remote scripts please
2328
- if ( isset( $wplc_settings['wplc_enable_all_admin_pages'] ) && $wplc_settings['wplc_enable_all_admin_pages'] === '1' ) {
2329
- /* Run admin JS on all admin pages */
2330
- if ( isset( $_GET['action'] ) && $_GET['action'] == "history" ) { }else {
2331
- wplc_admin_remote_dashboard_scripts($wplc_settings);
2332
- }
2333
- } else {
2334
- /* Only run admin JS on the chat dashboard page */
2335
- if ( isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu' && !isset( $_GET['action'] ) ) {
2336
- wplc_admin_remote_dashboard_scripts($wplc_settings);
2337
- }
2338
- }
2339
-
2340
- if( isset( $_GET['page'] ) && $_GET['page'] === "wplivechat-menu-offline-messages"){
2341
- wplc_admin_output_js();
2342
- }
2343
- } else {
2344
- do_action("wplc_hook_superadmin_head");
2345
-
2346
- if ( isset( $_GET['page'] ) && isset( $_GET['action'] ) && $_GET['page'] == "wplivechat-menu" && ( $_GET['action'] != 'welcome' && $_GET['action'] != 'credits' ) ) {
2347
- /* admin chat box page */
2348
- if (function_exists("wplc_register_pro_version")) {
2349
- wplc_return_pro_admin_chat_javascript(sanitize_text_field($_GET['cid']));
2350
- } else {
2351
-
2352
- /** set the global chat data here so we dont need to keep getting it from the DB or Cloud server */
2353
- global $admin_chat_data;
2354
- $admin_chat_data = wplc_get_chat_data($_GET['cid'], __LINE__);
2355
-
2356
- wplc_return_admin_chat_javascript(sanitize_text_field($_GET['cid']));
2357
-
2358
-
2359
- }
2360
- do_action("wplc_hook_admin_javascript_chat");
2361
- } else {
2362
- /* load this on every other admin page */
2363
- if (function_exists("wplc_register_pro_version")) {
2364
- wplc_pro_admin_javascript();
2365
- } else {
2366
- wplc_admin_javascript();
2367
- }
2368
- do_action("wplc_hook_admin_javascript");
2369
- }
2370
-
2371
-
2372
- ?>
2373
- <script type="text/javascript">
2374
-
2375
-
2376
- function wplc_desktop_notification() {
2377
- if (typeof Notification !== 'undefined') {
2378
- if (!Notification) {
2379
- return;
2380
- }
2381
- if (Notification.permission !== "granted")
2382
- Notification.requestPermission();
2383
-
2384
- var wplc_desktop_notification = new Notification('<?php _e('New chat received', 'wplivechat'); ?>', {
2385
- icon: wplc_notification_icon_url,
2386
- body: "<?php _e("A new chat has been received. Please go the 'Live Chat' page to accept the chat", "wplivechat"); ?>"
2387
- });
2388
- //Notification.close()
2389
- }
2390
- }
2391
-
2392
- </script>
2393
- <?php
2394
-
2395
- }
2396
- }
2397
-
2398
- function old_wplc_superadmin_javascript() {
2399
-
2400
- if (isset($_GET['page']) && ($_GET['page'] == 'wplivechat-menu' || $_GET['page'] == 'wplivechat-menu-settings' || $_GET['page'] == 'wplivechat-menu-offline-messages' || $_GET['page'] == 'wplc-pro-custom-fields' ) ) {
2401
-
2402
- if (!isset($_GET['action'])) {
2403
- if (function_exists("wplc_register_pro_version")) {
2404
- wplc_pro_admin_javascript();
2405
- } else {
2406
- wplc_admin_javascript();
2407
- }
2408
- do_action("wplc_hook_admin_javascript");
2409
- } // main page
2410
- else if ( isset($_GET['action']) && ( $_GET['action'] != 'welcome' && $_GET['action'] != 'credits' && $_GET['action'] != 'history' ) ) {
2411
- if (function_exists("wplc_register_pro_version")) {
2412
- wplc_return_pro_admin_chat_javascript(sanitize_text_field($_GET['cid']));
2413
- } else {
2414
-
2415
- /** set the global chat data here so we dont need to keep getting it from the DB or Cloud server */
2416
- global $admin_chat_data;
2417
- $admin_chat_data = wplc_get_chat_data($_GET['cid'], __LINE__);
2418
-
2419
- wplc_return_admin_chat_javascript(sanitize_text_field($_GET['cid']));
2420
-
2421
-
2422
- }
2423
- do_action("wplc_hook_admin_javascript_chat");
2424
- }
2425
- }
2426
-
2427
-
2428
- do_action("wplc_hook_superadmin_head");
2429
-
2430
- ?>
2431
- <script type="text/javascript">
2432
-
2433
-
2434
- function wplc_desktop_notification() {
2435
- if (typeof Notification !== 'undefined') {
2436
- if (!Notification) {
2437
- return;
2438
- }
2439
- if (Notification.permission !== "granted")
2440
- Notification.requestPermission();
2441
-
2442
- var wplc_desktop_notification = new Notification('<?php _e('New chat received', 'wplivechat'); ?>', {
2443
- icon: wplc_notification_icon_url,
2444
- body: "<?php _e("A new chat has been received. Please go the 'Live Chat' page to accept the chat", "wplivechat"); ?>"
2445
- });
2446
- //Notification.close()
2447
- }
2448
- }
2449
-
2450
- </script>
2451
- <?php
2452
- }
2453
-
2454
-
2455
- /**
2456
- * Admin JS set up
2457
- * @return void
2458
- * @since 6.0.00
2459
- * @author Nick Duncan <nick@codecabin.co.za>
2460
- */
2461
- function wplc_admin_javascript() {
2462
-
2463
- $wplc_settings = get_option("WPLC_SETTINGS");
2464
- if ( isset( $wplc_settings['wplc_enable_all_admin_pages'] ) && $wplc_settings['wplc_enable_all_admin_pages'] === '1' ) {
2465
- /* Run admin JS on all admin pages */
2466
- if ( isset( $_GET['action'] ) && $_GET['action'] == "history" ) { return; }
2467
- else {
2468
- wplc_admin_output_js();
2469
- }
2470
- } else {
2471
- /* Only run admin JS on the chat dashboard page */
2472
- if ( isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu' && !isset( $_GET['action'] ) ) {
2473
- wplc_admin_output_js();
2474
- }
2475
- }
2476
-
2477
-
2478
-
2479
-
2480
-
2481
-
2482
-
2483
- }
2484
-
2485
- /**
2486
- * Outputs the admin JS on to the relevant pages, controlled by wplc_admin_javascript();
2487
- *
2488
- * @return void
2489
- * @since 7.1.00
2490
- * @author Nick Duncan
2491
- */
2492
- function wplc_admin_output_js() {
2493
- $continue = apply_filters( "wplc_version_check_continue", true );
2494
- if ($continue === true) {
2495
-
2496
-
2497
- $ajax_nonce = wp_create_nonce("wplc");
2498
- global $wplc_version;
2499
-
2500
- $wplc_current_user = get_current_user_id();
2501
- if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true )) {
2502
-
2503
- wp_register_script('wplc-admin-js', plugins_url('js/wplc_u_admin.js', __FILE__), false, $wplc_version, false);
2504
- wp_enqueue_script('wplc-admin-js');
2505
- $not_icon = plugins_url('/images/wplc_notification_icon.png', __FILE__);
2506
-
2507
- $wplc_wav_file = plugins_url('/ring.wav', __FILE__);
2508
- $wplc_wav_file = apply_filters("wplc_filter_wav_file",$wplc_wav_file);
2509
- wp_localize_script('wplc-admin-js', 'wplc_wav_file', $wplc_wav_file);
2510
-
2511
- wp_localize_script('wplc-admin-js', 'wplc_ajax_nonce', $ajax_nonce);
2512
-
2513
- wp_localize_script('wplc-admin-js', 'wplc_notification_icon', $not_icon);
2514
-
2515
- $extra_data = apply_filters("wplc_filter_admin_javascript",array());
2516
- wp_localize_script('wplc-admin-js', 'wplc_extra_data', $extra_data);
2517
-
2518
- $ajax_url = admin_url('admin-ajax.php');
2519
- $wplc_ajax_url = apply_filters("wplc_filter_ajax_url",$ajax_url);
2520
- wp_localize_script('wplc-admin-js', 'wplc_ajaxurl', $wplc_ajax_url);
2521
- wp_localize_script('wplc-admin-js', 'wplc_ajaxurl_home', admin_url( 'admin-ajax.php' ) );
2522
-
2523
- $wpc_ma_js_strings = array(
2524
- 'remove_agent' => __('Remove', 'wplivechat'),
2525
- 'nonce' => wp_create_nonce("wplc"),
2526
- 'user_id' => get_current_user_id(),
2527
- 'typing_string' => __('Typing...', 'wplivechat')
2528
-
2529
- );
2530
- wp_localize_script('wplc-admin-js', 'wplc_admin_strings', $wpc_ma_js_strings);
2531
-
2532
- }
2533
- }
2534
- }
2535
-
2536
- function wplc_admin_menu_layout() {
2537
-
2538
-
2539
-
2540
-
2541
- do_action("wplc_hook_admin_menu_layout");
2542
- if (function_exists("wplc_register_pro_version")) {
2543
- global $wplc_pro_version;
2544
- if (floatval($wplc_pro_version) < 4 || $wplc_pro_version == "4.1.0" || $wplc_pro_version == "4.1.1") {
2545
- ?>
2546
- <div class='error below-h1'>
2547
-
2548
- <p><?php _e("Dear Pro User", "wplivechat") ?><br /></p>
2549
- <p><?php _e("You are using an outdated version of <strong>WP Live Chat Support Pro</strong>. Please", "wplivechat") ?> <a href="https://wp-livechat.com/get-updated-version/" target=\"_BLANK\"><?php _e("update to at least version", "wplivechat") ?> 4.0</a> <?php _e("to ensure all functionality is in working order", "wplivechat") ?>.</p>
2550
- <p><strong><?php _e("You're live chat box on your website has been temporarily disabled until the Pro plugin has been updated. This is to ensure a smooth and hassle-free user experience for both yourself and your visitors.", "wplivechat") ?></strong></p>
2551
- <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>
2552
- <p><?php _e("If you are having difficulty updating the plugin, please contact", "wplivechat") ?> nick@wp-livechat.com</p>
2553
-
2554
- </div>
2555
- <?php
2556
- }
2557
- $wplc_ver = str_replace('.', '', $wplc_pro_version);
2558
- $wplc_ver = intval($wplc_ver);
2559
- if ($wplc_ver < 501) {
2560
- ?>
2561
- <div class='error below-h1'>
2562
-
2563
- <p><?php _e("Dear Pro User", "wplivechat") ?><br /></p>
2564
- <p><?php _e("You are using an outdated version of <strong>WP Live Chat Support Pro</strong>.", "wplivechat") ?></p>
2565
- <p>
2566
- <strong><?php _e("Please update to the latest version of WP Live Chat Support Pro", 'wplivechat'); ?>
2567
- <a href="https://wp-livechat.com/get-updated-version/" target=\"_BLANK\"> <?php _e("Version 5.0.1", "wplivechat"); ?></a>
2568
- <?php _e("to ensure everything is working correctly.", "wplivechat"); ?>
2569
- </strong>
2570
- </p>
2571
- <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>
2572
- <p><?php _e("If you are having difficulty updating the plugin, please contact", "wplivechat") ?> nick@wp-livechat.com</p>
2573
-
2574
- </div>
2575
- <?php
2576
- }
2577
- }
2578
- if ( ( get_option("WPLC_V8_FIRST_TIME") == true && !class_exists("APC_Object_Cache") ) || ( isset( $_GET['action'] ) && ( $_GET['action'] == 'welcome' || $_GET['action'] == 'credits' ) ) ){
2579
- include 'includes/welcome_page.php';
2580
- update_option('WPLC_V8_FIRST_TIME', false);
2581
- } else {
2582
-
2583
- update_option('WPLC_V8_FIRST_TIME', false);
2584
- $wplc_settings = get_option("WPLC_SETTINGS");
2585
- if ( isset( $wplc_settings['wplc_use_node_server'] ) && $wplc_settings['wplc_use_node_server'] == 1 ) {
2586
- //Node in use, load remote dashboard
2587
- if ( $_GET['page'] === 'wplivechat-menu') {
2588
- wplc_admin_dashboard_layout_node('dashboard');
2589
-
2590
- if( isset($_GET['action']) ){
2591
- wplc_admin_menu_layout_display();
2592
- }
2593
- } else {
2594
- // we'll control this in admin_footer
2595
- //wplc_admin_dashboard_layout_node('other');
2596
- }
2597
-
2598
- } else {
2599
- if (function_exists("wplc_register_pro_version")) {
2600
- wplc_pro_admin_menu_layout_display();
2601
- } else {
2602
- wplc_admin_menu_layout_display();
2603
- }
2604
- }
2605
- }
2606
- }
2607
-
2608
-
2609
-
2610
- function wplc_first_time_tutorial() {
2611
- if (!get_option('WPLC_FIRST_TIME_TUTORIAL')) {
2612
-
2613
- global $wplc_basic_plugin_url;
2614
- ?>
2615
-
2616
-
2617
- <div id="wplcftt" style='margin-top:30px; margin-bottom:20px; width: 65%; background-color: #FFF; box-shadow: 1px 1px 3px #ccc; display:block; padding:10px; text-align:center; margin-left:auto; margin-right:auto;'>
2618
- <img src='<?php echo $wplc_basic_plugin_url; ?>/images/wplc_notification_icon.png' width="130" align="center" />
2619
- <h1 style='font-weight: 300; font-size: 50px; line-height: 50px;'><strong style="color: #ec822c;"><?php _e("Congratulations","wplivechat"); ?></strong></h1>
2620
- <h2><strong><?php _e("You are now accepting live chat requests on your site.","wplivechat"); ?></strong></h2>
2621
- <p><?php _e("The live chat box has automatically been enabled on your website.","wplivechat"); ?></p>
2622
- <p><?php _e("Chat notifications will start appearing once visitors send a request.","wplivechat"); ?></p>
2623
- <p><?php _e("You may <a href='?page=wplivechat-menu-settings' target='_BLANK'>modify your chat box settings here.","wplivechat"); ?></a></p>
2624
- <p><?php _e("Experiencing issues?","wplivechat"); ?> <a href="https://wp-livechat.com/documentation/troubleshooting/" target="_BLANK" title=""><?php _e("Visit our troubleshooting section.","wplivechat"); ?></a></p>
2625
-
2626
- <p><button id="wplc_close_ftt" class="button button-secondary"><?php _e("Hide","wplivechat"); ?></button></p>
2627
-
2628
- </div>
2629
-
2630
- <?php }
2631
- }
2632
-
2633
-
2634
- /**
2635
- * Control the content below the visitor count
2636
- * @return void
2637
- * @since 6.0.00
2638
- * @author Nick Duncan <nick@codecabin.co.za>
2639
- */
2640
- add_filter("wplc_filter_chat_dahsboard_visitors_online_bottom","wplc_filter_control_chat_dashboard_visitors_online_bottom",10);
2641
- function wplc_filter_control_chat_dashboard_visitors_online_bottom($text) {
2642
- $text = "<hr />";
2643
- $text .= "<p class='wplc-agent-info' id='wplc-agent-info'>";
2644
- $text .= " <span class='wplc_agents_online'>1</span>";
2645
- $text .= " <a href='javascript:void(0);'>".__("Agent(s) online","wplivechat")."</a>";
2646
- $text .= "</p>";
2647
- return $text;
2648
- }
2649
-
2650
-
2651
- add_action("wplc_hook_chat_dashboard_bottom","wplc_hook_control_chat_dashboard_bottom",10);
2652
- /**
2653
- * Decides whether or not to show the available extensions for this area.
2654
- * @return void
2655
- * @since 6.0.00
2656
- * @author Nick Duncan <nick@codecabin.co.za>
2657
- */
2658
- function wplc_hook_control_chat_dashboard_bottom() {
2659
- echo "<p id='wplc_footer_message' style='display:none;'>";
2660
- ?>
2661
- <?php _e("With the Pro add-on of WP Live Chat Support, you can", "wplivechat"); ?>
2662
- <a href="http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate1" title="<?php _e("see who's online and initiate chats", "wplivechat"); ?>" target=\"_BLANK\">
2663
- <?php _e("initiate chats", "wplivechat"); ?>
2664
- </a> <?php _e("with your online visitors with the click of a button.", "wplivechat"); ?>
2665
- <a href="http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate2" title="<?php _e("Buy the Pro add-on now.", "wplivechat"); ?>" target=\"_BLANK\">
2666
- <strong>
2667
- <?php _e("Buy the Pro add-on now.", "wplivechat"); ?>
2668
- </strong>
2669
- </a>
2670
- <?php
2671
- echo "</p>";
2672
-
2673
-
2674
-
2675
- }
2676
-
2677
-
2678
- function wplc_admin_menu_layout_display() {
2679
-
2680
- $wplc_current_user = get_current_user_id();
2681
-
2682
- if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true ) ){
2683
- /*
2684
- -- modified in in 6.0.04 --
2685
-
2686
- if(current_user_can('wplc_ma_agent') || current_user_can('manage_options')){
2687
- */
2688
- do_action("wplc_hook_admin_menu_layout_display_top");
2689
-
2690
- wplc_stats("chat_dashboard");
2691
-
2692
- global $wplc_basic_plugin_url;
2693
- if (!isset($_GET['action'])) {
2694
- ?>
2695
- <style>
2696
- #wplc-support-tabs a.wplc-support-link {
2697
- background: url('<?php echo $wplc_basic_plugin_url; ?>/images/support.png');
2698
- right: 0px;
2699
- top: 250px;
2700
- height: 108px;
2701
- width: 45px;
2702
- margin: 0;
2703
- padding: 0;
2704
- position: fixed;
2705
- z-index: 9999;
2706
- display:block;
2707
- }
2708
- </style>
2709
- <div class='wplc_network_issue' style='display:none;'>
2710
-
2711
- </div>
2712
-
2713
- <div id="wplc-support-tabs">
2714
- <a class="wplc-support-link wplc-rotate" href="?page=wplivechat-menu-support-page"></a>
2715
- </div>
2716
- <div class='wplc_page_title'>
2717
- <img src='<?php echo WPLC_BASIC_PLUGIN_URL; ?>images/wplc-logo.png' class='wplc-logo' />
2718
- <?php wplc_first_time_tutorial(); ?>
2719
- <?php do_action("wplc_hook_chat_dashboard_above"); ?>
2720
-
2721
- <p><?php _e("Please note: This window must be open in order to receive new chat notifications.", "wplivechat"); ?></p>
2722
- </div>
2723
-
2724
- <?php
2725
- $continue = apply_filters( "wplc_version_check_continue", true );
2726
- if ($continue !== true) {
2727
-
2728
- echo "<hr />";
2729
- echo "<center>";
2730
- echo "<h1>".$continue."</h1>";
2731
- echo "<p>".sprintf( __( 'Need help? <a href="%s" target="_BLANK">contact us</a>.', 'wplivechat'),'https://wp-livechat.com/contact-us/')."</p>";
2732
- echo "</center>";
2733
-
2734
-
2735
- } else {
2736
-
2737
- ?>
2738
-
2739
-
2740
- <div id="wplc_sound"></div>
2741
-
2742
- <div id="wplc_admin_chat_holder">
2743
- <div id='wplc_admin_chat_info_new'>
2744
- <div class='wplc_chat_vis_count_box'>
2745
- <?php do_action("wplc_hook_chat_dahsboard_visitors_online_top"); ?>
2746
- <span class='wplc_vis_online'>0</span>
2747
- <span style='text-transform:uppercase;'>
2748
- <?php _e("Visitors online","wplivechat"); ?>
2749
- </span>
2750
- <?php echo apply_filters("wplc_filter_chat_dahsboard_visitors_online_bottom",""); ?>
2751
-
2752
-
2753
- </div>
2754
-
2755
- <?php do_action("wplc_after_chat_visitor_count_hook"); ?>
2756
-
2757
- </div>
2758
-
2759
- <div id="wplc_admin_chat_area_new">
2760
- <div style="display:block;padding:10px;">
2761
- <ul class='wplc_chat_ul_header'>
2762
- <li><span class='wplc_header_vh wplc_headerspan_v'><?php _e("Visitor","wplivechat"); ?></span></li>
2763
- <li><span class='wplc_header_vh wplc_headerspan_t'><?php _e("Time","wplivechat"); ?></span></li>
2764
- <li><span class='wplc_header_vh wplc_headerspan_nr'><?php _e("Type","wplivechat"); ?></span></li>
2765
- <li><span class='wplc_header_vh wplc_headerspan_dev'><?php _e("Device","wplivechat"); ?></span></li>
2766
- <li><span class='wplc_header_vh wplc_headerspan_d'><?php _e("Data","wplivechat"); ?></span></li>
2767
- <li><span class='wplc_header_vh wplc_headerspan_s'><?php _e("Status","wplivechat"); ?></span></li>
2768
- <li><span class='wplc_header_vh wplc_headerspan_a'><?php _e("Action","wplivechat"); ?></span></li>
2769
- </ul>
2770
- <ul id='wplc_chat_ul'>
2771
- </ul>
2772
- <br />
2773
- <hr />
2774
- <?php do_action("wplc_hook_chat_dashboard_bottom"); ?>
2775
-
2776
- </div>
2777
-
2778
- </div>
2779
- </div>
2780
- <?php } ?>
2781
-
2782
-
2783
-
2784
-
2785
- <?php
2786
- } else {
2787
- if (isset($_GET['aid'])) { $aid = $_GET['aid']; } else { $aid = null; }
2788
- do_action("wplc_hook_admin_menu_layout_display_1",$_GET['action'],$_GET['cid'],$aid);
2789
-
2790
- if (!is_null($aid)) {
2791
- do_action("wplc_hook_update_agent_id",$_GET['cid'],$aid);
2792
- }
2793
-
2794
- do_action("wplc_hook_admin_menu_layout_display_1",$_GET['action'],$_GET['cid'],$aid);
2795
-
2796
- if ($_GET['action'] == 'ac') {
2797
- do_action('wplc_hook_accept_chat',$_GET,$aid);
2798
- }
2799
- do_action("wplc_hook_admin_menu_layout_display",$_GET['action'],$_GET['cid'],$aid);
2800
- }
2801
- } else {
2802
- ?>
2803
-
2804
- <h1><?php _e("Chat Dashboard","wplivechat"); ?></h1>
2805
- <div id="welcome-panel" class="welcome-panel">
2806
- <div class="welcome-panel-content">
2807
- <h2><?php _e("Oh no!","wplivechat"); ?></h2>
2808
- <p class="about-description">
2809
- <?php _e(
2810
- "You do not have access to this page as <strong>you are not a chat agent</strong>.",
2811
- "wplivechat"
2812
- ); ?>
2813
- </p>
2814
- <p>Users with access to this page are as follows:</p>
2815
- <p>
2816
- <?php
2817
- $user_array = get_users(array(
2818
- 'meta_key' => 'wplc_ma_agent',
2819
- ));
2820
- echo "<ol>";
2821
- if ($user_array) {
2822
- foreach ($user_array as $user) {
2823
- echo "<li> ".$user->display_name . " (ID: ".$user->ID.")</li>";
2824
- }
2825
- }
2826
- echo "</ol>";
2827
- ?>
2828
- </p>
2829
- </div>
2830
- </div>
2831
- <?php
2832
- }
2833
- }
2834
-
2835
- add_action("wplc_hook_change_status_on_answer","wplc_hook_control_change_status_on_answer",10,2);
2836
- function wplc_hook_control_change_status_on_answer($get_data, $chat_data = false) {
2837
-
2838
- $user_ID = get_current_user_id();
2839
- wplc_change_chat_status(sanitize_text_field($get_data['cid']), 3,$user_ID );
2840
- wplc_record_chat_notification("joined",$get_data['cid'],array("aid"=>$user_ID));
2841
- }
2842
-
2843
-
2844
- add_action('wplc_hook_accept_chat','wplc_hook_control_accept_chat',10,2);
2845
- function wplc_hook_control_accept_chat($get_data,$aid) {
2846
-
2847
- global $admin_chat_data;
2848
-
2849
- if (!$admin_chat_data) {
2850
- $chat_data = wplc_get_chat_data($get_data['cid'], __LINE__);
2851
- } else {
2852
- if (isset($admin_chat_data->id) && intval($admin_chat_data->id) === intval($get_data['cid'])) {
2853
- $chat_data = $admin_chat_data;
2854
- } else {
2855
- /* chat ID's dont match, get the data for the correct chat ID */
2856
- $chat_data = wplc_get_chat_data($get_data['cid'], __LINE__);
2857
- }
2858
- }
2859
-
2860
-
2861
-
2862
-
2863
-
2864
- do_action("wplc_hook_accept_chat_url",$get_data, $chat_data);
2865
-
2866
- do_action("wplc_hook_change_status_on_answer",$get_data, $chat_data);
2867
-
2868
-
2869
- if (function_exists("wplc_register_pro_version")) {
2870
- /* backwards compatibility */
2871
- wplc_pro_draw_chat_area(sanitize_text_field($get_data['cid']));
2872
- } else {
2873
- do_action("wplc_hook_draw_chat_area",$get_data, $chat_data);
2874
-
2875
- }
2876
-
2877
-
2878
- }
2879
-
2880
- /**
2881
- * Hook to accept chat
2882
- *
2883
- * @since 7.1.00
2884
- * @param
2885
- * @return void
2886
- * @author Nick Duncan (nick@codecabin.co.za)
2887
- *
2888
- */
2889
- add_action( 'wplc_hook_accept_chat_url' , 'wplc_b_hook_control_accept_chat_url', 5, 2);
2890
- remove_action( 'wplc_hook_accept_chat_url' , 'wplc_ma_hook_control_accept_chat_url', 10, 2); /* remove the older Pro hook as this was moved now to the basic version in 7.1.00 */
2891
- function wplc_b_hook_control_accept_chat_url($get_data, $chat_data = false) {
2892
- if (!isset($get_data['agent_id'])) {
2893
- /* free version */
2894
- wplc_b_update_agent_id(sanitize_text_field($get_data['cid']), get_current_user_id());
2895
- } else {
2896
- wplc_b_update_agent_id(sanitize_text_field($get_data['cid']), sanitize_text_field($get_data['agent_id']));
2897
- }
2898
-
2899
- }
2900
-
2901
- /**
2902
- * Assign the chat to the agent
2903
- *
2904
- * Replaces the same function of a different name in the older pro version
2905
- *
2906
- * @since 7.1.00
2907
- * @param
2908
- * @return void
2909
- * @author Nick Duncan (nick@codecabin.co.za)
2910
- *
2911
- */
2912
- function wplc_b_update_agent_id($cid, $aid){
2913
- global $wpdb;
2914
- global $wplc_tblname_chats;
2915
- $sql = "SELECT * FROM `$wplc_tblname_chats` WHERE `id` = '$cid' LIMIT 1";
2916
- $result = $wpdb->get_row($sql);
2917
- if ($result) {
2918
- if(intval($result->status) != 3){
2919
- $update = "UPDATE `$wplc_tblname_chats` SET `agent_id` = '$aid' WHERE `id` = '$cid' LIMIT 1";
2920
- $wpdb->query($update);
2921
- }
2922
- }
2923
- }
2924
-
2925
-
2926
-
2927
- add_action("wplc_hook_chat_dashboard_bottom","wplc_hook_control_app_chat_dashboard_bottom",10);
2928
- function wplc_hook_control_app_chat_dashboard_bottom() {
2929
- //echo "<p>Tired of logging in to accept chats? Use our <a href='https://wp-livechat.com/extensions/mobile-desktop-app-extension/?utm_source=plugin&utm_medium=plugin&utm_campaign=main_app' target='_BLANK'>Android app</a> or <a href='https://wp-livechat.com/extensions/mobile-desktop-app-extension/?utm_source=plugin&utm_medium=plugin&utm_campaign=main_desktop' target='_BLANK'>desktop app</a> to monitor visitors, accept and initiate chats.</p>";
2930
- }
2931
-
2932
- add_action("wplc_hook_draw_chat_area","wplc_hook_control_draw_chat_area",10,2);
2933
- function wplc_hook_control_draw_chat_area($get_data, $chat_data = false) {
2934
-
2935
- wplc_draw_chat_area(sanitize_text_field($get_data['cid']), $chat_data);
2936
- }
2937
-
2938
- function wplc_draw_chat_area($cid, $chat_data = false) {
2939
-
2940
- global $wpdb;
2941
- global $wplc_tblname_chats;
2942
-
2943
- $results = $wpdb->get_results(
2944
- "
2945
- SELECT *
2946
- FROM $wplc_tblname_chats
2947
- WHERE `id` = '$cid'
2948
- LIMIT 1
2949
- "
2950
- );
2951
- if ($results) { } else { $results[0] = null; } /* if chat ID doesnt exist, create the variable anyway to avoid an error. Hopefully the Chat ID exists on the server..! */
2952
-
2953
-
2954
- $result = apply_filters("wplc_filter_chat_area_data", $results[0], $cid);
2955
-
2956
-
2957
- ?>
2958
- <style>
2959
-
2960
- .wplc-clear-float-message{
2961
- clear: both;
2962
- }
2963
-
2964
- .rating{
2965
- background-color: lightgray;
2966
- width: 80px;
2967
- padding: 2px;
2968
- border-radius: 4px;
2969
- text-align: center;
2970
- color: white;
2971
- display: inline-block;
2972
- float: right;
2973
- }
2974
-
2975
- .rating-bad {
2976
- background-color: #AF0B0B !important;
2977
- }
2978
-
2979
- .rating-good {
2980
- background-color: #368437 !important;
2981
- }
2982
-
2983
-
2984
- </style>
2985
- <?php
2986
-
2987
- $user_data = maybe_unserialize($result->ip);
2988
- $user_ip = isset($user_data['ip']) ? $user_data['ip'] : 'Unknown';
2989
- $browser = isset($user_data['user_agent']) ? wplc_return_browser_string($user_data['user_agent']) : "Unknown";
2990
- $browser_image = wplc_return_browser_image($browser, "16");
2991
-
2992
-
2993
- global $wplc_basic_plugin_url;
2994
- if ($result->status == 1) {
2995
- $status = __("Previous", "wplivechat");
2996
- } else {
2997
- $status = __("Active", "wplivechat");
2998
- }
2999
-
3000
- if($user_ip == ""){
3001
- $user_ip = __('IP Address not recorded', 'wplivechat');
3002
- } else {
3003
- $user_ip = "<a href='http://www.ip-adress.com/ip_tracer/" . $user_ip . "' title='".__('Whois for' ,'wplivechat')." ".$user_ip."' target='_BLANK'>".$user_ip."</a>";
3004
- }
3005
-
3006
- echo "<h2>$status " . __( 'Chat with', 'wplivechat' ) . " " . sanitize_text_field($result->name) . "</h2>";
3007
- if ( isset( $_GET['action'] ) && 'history' === $_GET['action'] ) {
3008
- echo "<span class='wplc-history__date'><strong>" . __( 'Starting Time:', 'wplivechat' ) . "</strong>" . date( 'Y-m-d H:i:s', current_time( strtotime( $result->timestamp ) ) ) . "</span>";
3009
- echo "<span class='wplc-history__date wplc-history__date-end'><strong>" . __( 'Ending Time:', 'wplivechat' ) . "</strong>" . date( 'Y-m-d H:i:s', current_time( strtotime( $result->last_active_timestamp ) ) ) . "</span>";
3010
- }
3011
- echo "<style>#adminmenuwrap { display:none; } #adminmenuback { display:none; } #wpadminbar { display:none; } #wpfooter { display:none; } .update-nag { display:none; }</style>";
3012
-
3013
- echo "<div class=\"end_chat_div\">";
3014
-
3015
- do_action("wplc_admin_chat_area_before_end_chat_button", $result);
3016
-
3017
- echo "<a href=\"javascript:void(0);\" class=\"wplc_admin_close_chat button\" id=\"wplc_admin_close_chat\">" . __("End chat", "wplivechat") . "</a>";
3018
-
3019
- do_action("wplc_admin_chat_area_after_end_chat_button", $result);
3020
-
3021
- echo "</div>";
3022
-
3023
- do_action("wplc_add_js_admin_chat_area", $cid, $chat_data);
3024
-
3025
- echo "<div id='admin_chat_box'>";
3026
-
3027
- $result->continue = true;
3028
-
3029
- do_action("wplc_hook_wplc_draw_chat_area",$result);
3030
-
3031
- if (!$result->continue) { return; }
3032
-
3033
- echo"<div class='admin_chat_box'><div class='admin_chat_box_inner' id='admin_chat_box_area_" . $result->id . "'>".apply_filters( "wplc_chat_box_draw_chat_box_inner", "", $cid)."</div><div class='admin_chat_box_inner_bottom'>" . wplc_return_chat_response_box($cid, $result) . "</div>";
3034
-
3035
-
3036
- echo "</div>";
3037
- echo "<div class='admin_visitor_info'>";
3038
- do_action("wplc_hook_admin_visitor_info_display_before",$cid);
3039
-
3040
-
3041
- echo " <div style='float:left; width:100px;'><img src=\"//www.gravatar.com/avatar/" . md5($result->email) . "\" class=\"admin_chat_img\" /></div>";
3042
- echo " <div style='float:left;'>";
3043
-
3044
- echo " <div class='admin_visitor_info_box1'>";
3045
- echo " <span class='admin_chat_name'>" . sanitize_text_field($result->name) . "</span>";
3046
- echo " <span class='admin_chat_email'>" . sanitize_text_field($result->email) . "</span>";
3047
- echo " </div>";
3048
- echo " </div>";
3049
-
3050
- echo " <div class='admin_visitor_advanced_info'>";
3051
- echo " <strong>" . __("Site Info", "wplivechat") . "</strong>";
3052
- echo " <hr />";
3053
- echo " <span class='part1'>" . __("Chat initiated on:", "wplivechat") . "</span> <span class='part2'>" . esc_url($result->url) . "</span>";
3054
- echo " </div>";
3055
-
3056
- echo " <div class='admin_visitor_advanced_info'>";
3057
- echo " <strong>" . __("Advanced Info", "wplivechat") . "</strong>";
3058
- echo " <hr />";
3059
- echo " <span class='part1'>" . __("Browser:", "wplivechat") . "</span><span class='part2'> $browser <img src='" . $wplc_basic_plugin_url . "/images/$browser_image' alt='$browser' title='$browser' /><br />";
3060
- echo " <span class='part1'>" . __("IP Address:", "wplivechat") . "</span><span class='part2'> ".sanitize_text_field($user_ip);
3061
- echo " </div>";
3062
- echo "<hr />";
3063
-
3064
- echo (apply_filters("wplc_filter_advanced_info","", sanitize_text_field($result->id), sanitize_text_field($result->name), $result));
3065
-
3066
- echo " <div id=\"wplc_sound_update\"></div>";
3067
-
3068
- echo "<div class='wplc_bottom_chat_info_container'>";
3069
- echo "<h3>".__("Add-ons","wplivechat")."</h3>";
3070
- do_action("wplc_hook_admin_visitor_info_display_after",$cid);
3071
- echo "<a href='".admin_url('admin.php?page=wplivechat-menu-extensions-page')."' class='button button-primary' target='_BLANK'>".__("Get more add-ons","wplivechat")."</a>";
3072
- echo "</div>";
3073
-
3074
- echo "</div>";
3075
-
3076
- if ($result->status != 1) {
3077
-
3078
- do_action("wplc_hook_admin_below_chat_box",$result);
3079
- }
3080
-
3081
- }
3082
-
3083
-
3084
- add_action("wplc_hook_admin_below_chat_box","wplc_hook_control_admin_below_chat_box",10);
3085
- function wplc_hook_control_admin_below_chat_box() {
3086
- echo "<div class='admin_chat_quick_controls'>";
3087
- echo " <p style=\"text-align:left; font-size:11px;\">" . __('Press ENTER to send your message', 'wplivechat') . "</p>";
3088
- echo " " . __("Assign Quick Response", "wplivechat") . " <select name='wplc_macros_select' class='wplc_macros_select' disabled><option>" . __('Select', 'wplivechat') . "</option></select> <a href='https://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=quick_resposnes' title='" . __('Add Quick Responses to your Live Chat', 'wplivechat') . "' target='_BLANK'>" . __("Pro version only", "wplivechat") . "</a>";
3089
- echo " </div>";
3090
- echo "</div>";
3091
-
3092
- }
3093
-
3094
- function wplc_return_chat_response_box($cid, $chat_data = false) {
3095
-
3096
- $ret = "<div class=\"chat_response_box\">";
3097
- $ret .= apply_filters("wplc_filter_typing_control_div","");
3098
- $ret .= "<input type='text' name='wplc_admin_chatmsg' id='wplc_admin_chatmsg' value='' placeholder='" . __("type here...", "wplivechat") . "' />";
3099
-
3100
- $ret .= apply_filters("wplc_filter_chat_upload","");
3101
- $ret .= (!function_exists("nifty_text_edit_div") ? apply_filters("wplc_filter_chat_text_editor_upsell","") : apply_filters("wplc_filter_chat_text_editor",""));
3102
-
3103
- $ret .= "<input id='wplc_admin_cid' type='hidden' value='$cid' />";
3104
- $ret .= "<input id='wplc_admin_send_msg' type='button' value='" . __("Send", "wplivechat") . "' style=\"display:none;\" />";
3105
- $ret .= "</div>";
3106
- return $ret;
3107
- }
3108
-
3109
- function wplc_return_admin_chat_javascript($cid) {
3110
- $ajax_nonce = wp_create_nonce("wplc");
3111
- global $wplc_version;
3112
-
3113
- $wplc_settings = get_option("WPLC_SETTINGS");
3114
-
3115
- wp_register_script('wplc-admin-chat-server', plugins_url('js/wplc_server.js', __FILE__), false, $wplc_version, false);
3116
- wp_enqueue_script('wplc-admin-chat-server');
3117
-
3118
- wp_localize_script( 'wplc-admin-chat-server', 'wplc_datetime_format', array(
3119
- 'date_format' => get_option( 'date_format' ),
3120
- 'time_format' => get_option( 'time_format' ),
3121
- ) );
3122
-
3123
- global $admin_chat_data;
3124
- if (!$admin_chat_data) {
3125
- $cdata = wplc_get_chat_data($cid, __LINE__);
3126
- } else {
3127
- /* copy the stored admin chat data variable - more efficient */
3128
- $cdata = $admin_chat_data;
3129
- }
3130
-
3131
- $other = maybe_unserialize($cdata->other);
3132
-
3133
- if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
3134
- if (isset($other['socket']) && ($other['socket'] == true || $other['socket'] == "true")) {
3135
- if ( isset( $_GET['action'] ) && $_GET['action'] === 'history') {
3136
- wp_localize_script('wplc-admin-chat-server', 'wplc_use_node_server', "false");
3137
- } else {
3138
- wp_localize_script('wplc-admin-chat-server', 'wplc_use_node_server', "true");
3139
- wp_localize_script('wplc-admin-chat-server', 'wplc_localized_string_is_typing_single', __(" is typing...","wplivechat"));
3140
- }
3141
-
3142
- $wplc_node_token = get_option("wplc_node_server_secret_token");
3143
- if(!$wplc_node_token){
3144
- if(function_exists("wplc_node_server_token_regenerate")){
3145
- wplc_node_server_token_regenerate();
3146
- $wplc_node_token = get_option("wplc_node_server_secret_token");
3147
- }
3148
- }
3149
- wp_localize_script('wplc-admin-chat-server', 'bleeper_api_key', $wplc_node_token);
3150
- }
3151
- }
3152
-
3153
- /**
3154
- * Create a JS object for all Agent ID's and Gravatar MD5's
3155
- */
3156
- $user_array = get_users(array(
3157
- 'meta_key' => 'wplc_ma_agent',
3158
- ));
3159
-
3160
- $a_array = array();
3161
- if ($user_array) {
3162
- foreach ($user_array as $user) {
3163
- $a_array[$user->ID] = array();
3164
- $a_array[$user->ID]['name'] = $user->display_name;
3165
- $a_array[$user->ID]['md5'] = md5( $user->user_email );
3166
- }
3167
- }
3168
- wp_localize_script('wplc-admin-chat-server', 'wplc_agent_data', $a_array);
3169
-
3170
- /**
3171
- * Get the CURRENT agent's data
3172
- */
3173
- if(isset($_GET['aid'])){
3174
- $agent_data = get_user_by('ID', intval($_GET['aid']));
3175
- wp_localize_script('wplc-admin-chat-server', 'wplc_admin_agent_name', $agent_data->display_name);
3176
- wp_localize_script('wplc-admin-chat-server', 'wplc_admin_agent_email', md5($agent_data->user_email));
3177
- } else {
3178
- $agent_data = get_user_by('ID', intval(get_current_user_id()));
3179
- wp_localize_script('wplc-admin-chat-server', 'wplc_admin_agent_name', $agent_data->display_name);
3180
- wp_localize_script('wplc-admin-chat-server', 'wplc_admin_agent_email', md5($agent_data->user_email));
3181
- }
3182
-
3183
-
3184
- wp_register_script('wplc-admin-chat-js', plugins_url('js/wplc_u_admin_chat.js', __FILE__), array('wplc-admin-chat-server'), $wplc_version, false);
3185
- wp_enqueue_script('wplc-admin-chat-js');
3186
-
3187
-
3188
- global $wplc_pro_version;
3189
- $wplc_ver = str_replace('.', '', $wplc_pro_version);
3190
- $checker = intval($wplc_ver);
3191
- if (isset($wplc_settings['wplc_theme'])) { $wplc_theme = $wplc_settings['wplc_theme']; } else { $wplc_theme = "theme-default"; }
3192
-
3193
- if ( (isset($wplc_theme) && $checker >= 6000 ) || (! function_exists("wplc_pro_version_control") ) ) {
3194
- if($wplc_theme == 'theme-default') {
3195
- wp_register_style('wplc-theme-palette-default', plugins_url('/css/themes/theme-default.css', __FILE__), array(), $wplc_version);
3196
- wp_enqueue_style('wplc-theme-palette-default');
3197
-
3198
- }
3199
- else if($wplc_theme == 'theme-1') {
3200
- wp_register_style('wplc-theme-palette-1', plugins_url('/css/themes/theme-1.css', __FILE__), array(), $wplc_version);
3201
- wp_enqueue_style('wplc-theme-palette-1');
3202
-
3203
- }
3204
- else if($wplc_theme == 'theme-2') {
3205
- wp_register_style('wplc-theme-palette-2', plugins_url('/css/themes/theme-2.css', __FILE__), array(), $wplc_version);
3206
- wp_enqueue_style('wplc-theme-palette-2');
3207
-
3208
- }
3209
- else if($wplc_theme == 'theme-3') {
3210
- wp_register_style('wplc-theme-palette-3', plugins_url('/css/themes/theme-3.css', __FILE__), array(), $wplc_version);
3211
- wp_enqueue_style('wplc-theme-palette-3');
3212
-
3213
- }
3214
- else if($wplc_theme == 'theme-4') {
3215
- wp_register_style('wplc-theme-palette-4', plugins_url('/css/themes/theme-4.css', __FILE__), array(), $wplc_version);
3216
- wp_enqueue_style('wplc-theme-palette-4');
3217
-
3218
- }
3219
- else if($wplc_theme == 'theme-5') {
3220
- wp_register_style('wplc-theme-palette-5', plugins_url('/css/themes/theme-5.css', __FILE__), array(), $wplc_version);
3221
- wp_enqueue_style('wplc-theme-palette-5');
3222
-
3223
- }
3224
- else if($wplc_theme == 'theme-6') {
3225
- /* custom */
3226
- /* handled elsewhere */
3227
-
3228
-
3229
-
3230
- }
3231
- }
3232
- $wplc_settings = get_option("WPLC_SETTINGS");
3233
- $wplc_user_data = get_user_by( 'id', get_current_user_id() );
3234
-
3235
- if (isset($cdata->agent_id)) {
3236
- $wplc_agent_data = get_user_by( 'id', intval( $cdata->agent_id ) );
3237
- }
3238
-
3239
-
3240
- if( isset($wplc_settings['wplc_show_name']) && $wplc_settings['wplc_show_name'] == '1' ){ $wplc_show_name = true; } else { $wplc_show_name = false; }
3241
- if( isset($wplc_settings['wplc_show_avatar']) && $wplc_settings['wplc_show_avatar'] ){ $wplc_show_avatar = true; } else { $wplc_show_avatar = false; }
3242
- if( isset($wplc_settings['wplc_show_date']) && $wplc_settings['wplc_show_date'] == '1' ){ $wplc_show_date = true; } else { $wplc_show_date = false; }
3243
- if( isset($wplc_settings['wplc_show_time']) && $wplc_settings['wplc_show_time'] == '1' ){ $wplc_show_time = true; } else { $wplc_show_time = false; }
3244
-
3245
- $wplc_chat_detail = array( 'name' => $wplc_show_name, 'avatar' => $wplc_show_avatar, 'date' => $wplc_show_date, 'time' => $wplc_show_time );
3246
-
3247
-
3248
- wp_enqueue_script('wplc-admin-chat-js');
3249
- wp_localize_script( 'wplc-admin-chat-js', 'wplc_show_chat_detail', $wplc_chat_detail );
3250
-
3251
-
3252
-
3253
- if (!empty( $wplc_agent_data ) ) {
3254
- wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_name', $wplc_agent_data->display_name );
3255
- wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_email', md5( $wplc_agent_data->user_email ) );
3256
- } else {
3257
- wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_name', ' ' );
3258
- wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_email', ' ' );
3259
- }
3260
-
3261
- wp_localize_script('wplc-admin-chat-js', 'wplc_chat_name', $cdata->name);
3262
- wp_localize_script('wplc-admin-chat-js', 'wplc_chat_email', md5($cdata->email));
3263
-
3264
- if(class_exists("WP_REST_Request")) {
3265
- wp_localize_script('wplc-admin-chat-js', 'wplc_restapi_enabled', '1');
3266
- wp_localize_script('wplc-admin-chat-js', 'wplc_restapi_token', get_option('wplc_api_secret_token'));
3267
- wp_localize_script('wplc-admin-chat-js', 'wplc_restapi_endpoint', rest_url('wp_live_chat_support/v1'));
3268
- } else {
3269
- wp_localize_script('wplc-admin-chat-js', 'wplc_restapi_enabled', '0');
3270
- }
3271
-
3272
-
3273
- if (function_exists("wplc_pro_get_admin_picture")) {
3274
- $src = wplc_pro_get_admin_picture();
3275
- if ($src) {
3276
- $image = "<img src=" . $src . " width='20px' id='wp-live-chat-2-img'/>";
3277
- } else {
3278
- $image = " ";
3279
- }
3280
- } else {
3281
- $image = " ";
3282
- }
3283
- $admin_pic = $image;
3284
- wp_localize_script('wplc-admin-chat-js', 'wplc_localized_string_is_typing', __("is typing...","wplivechat"));
3285
- wp_localize_script('wplc-user-script', 'wplc_localized_string_admin_name', apply_filters( 'wplc_filter_admin_name', 'Admin' ) );
3286
- wp_localize_script('wplc-admin-chat-js', 'wplc_ajax_nonce', $ajax_nonce);
3287
- wp_localize_script('wplc-admin-chat-js', 'admin_pic', $admin_pic);
3288
-
3289
- $wplc_ding_file = plugins_url('/ding.mp3', __FILE__);
3290
- $wplc_ding_file = apply_filters( 'wplc_filter_message_sound', $wplc_ding_file );
3291
- wp_localize_script('wplc-admin-chat-js', 'wplc_ding_file', $wplc_ding_file);
3292
-
3293
- $extra_data = apply_filters("wplc_filter_admin_javascript",array());
3294
- wp_localize_script('wplc-admin-chat-js', 'wplc_extra_data', $extra_data);
3295
-
3296
- if (isset($wplc_settings['wplc_display_name']) && $wplc_settings['wplc_display_name'] == 1) {
3297
- $display_name = 'display';
3298
- } else {
3299
- $display_name = 'hide';
3300
- }
3301
- if (isset($wplc_settings['wplc_enable_msg_sound']) && intval($wplc_settings['wplc_enable_msg_sound']) == 1) {
3302
- $enable_ding = '1';
3303
- } else {
3304
- $enable_ding = '0';
3305
- }
3306
- if (isset($_COOKIE['wplc_email']) && $_COOKIE['wplc_email'] != "") {
3307
- $wplc_user_email_address = sanitize_text_field($_COOKIE['wplc_email']);
3308
- } else {
3309
- $wplc_user_email_address = " ";
3310
- }
3311
-
3312
- wp_localize_script('wplc-admin-chat-js', 'wplc_name', $display_name);
3313
- wp_localize_script('wplc-admin-chat-js', 'wplc_enable_ding', $enable_ding);
3314
-
3315
- $ajax_url = admin_url('admin-ajax.php');
3316
- $home_ajax_url = $ajax_url;
3317
-
3318
- $wplc_ajax_url = apply_filters("wplc_filter_ajax_url",$ajax_url);
3319
- wp_localize_script('wplc-admin-chat-js', 'wplc_ajaxurl', $wplc_ajax_url);
3320
- wp_localize_script('wplc-admin-chat-js', 'wplc_home_ajaxurl', $home_ajax_url);
3321
-
3322
-
3323
-
3324
- $wplc_url = admin_url('admin.php?page=wplivechat-menu&action=ac&cid=' . $cid);
3325
- wp_localize_script('wplc-admin-chat-js', 'wplc_url', $wplc_url);
3326
-
3327
-
3328
- $wplc_string1 = __("User has opened the chat window", "wplivechat");
3329
- $wplc_string2 = __("User has minimized the chat window", "wplivechat");
3330
- $wplc_string3 = __("User has maximized the chat window", "wplivechat");
3331
- $wplc_string4 = __("The chat has been ended", "wplivechat");
3332
- wp_localize_script('wplc-admin-chat-js', 'wplc_string1', $wplc_string1);
3333
- wp_localize_script('wplc-admin-chat-js', 'wplc_string2', $wplc_string2);
3334
- wp_localize_script('wplc-admin-chat-js', 'wplc_string3', $wplc_string3);
3335
- wp_localize_script('wplc-admin-chat-js', 'wplc_string4', $wplc_string4);
3336
- wp_localize_script('wplc-admin-chat-js', 'wplc_cid', $cid);
3337
-
3338
-
3339
- do_action("wplc_hook_admin_chatbox_javascript");
3340
-
3341
- }
3342
-
3343
- function wplc_activate() {
3344
- wplc_handle_db();
3345
- if (!get_option("WPLC_SETTINGS")) {
3346
- $wplc_alt_text = __("Please click \'Start Chat\' to initiate a chat with an agent", "wplivechat");
3347
- $wplc_default_visitor_name = __( "Guest", "wplivechat" );
3348
- $wplc_admin_email = get_option('admin_email');
3349
-
3350
- $wplc_default_settings_array = array(
3351
- "wplc_settings_align" => "2",
3352
- "wplc_settings_enabled" => "1",
3353
- "wplc_powered_by_link" => "0",
3354
- "wplc_settings_fill" => "ed832f",
3355
- "wplc_settings_font" => "FFFFFF",
3356
- "wplc_settings_color1" => "ED832F",
3357
- "wplc_settings_color2" => "FFFFFF",
3358
- "wplc_settings_color3" => "EEEEEE",
3359
- "wplc_settings_color4" => "666666",
3360
- "wplc_theme" => "theme-default",
3361
- "wplc_newtheme" => "theme-2",
3362
- "wplc_require_user_info" => '1',
3363
- "wplc_loggedin_user_info" => '1',
3364
- "wplc_user_alternative_text" => $wplc_alt_text,
3365
- "wplc_user_default_visitor_name" => $wplc_default_visitor_name,
3366
- "wplc_enabled_on_mobile" => '1',
3367
- "wplc_display_name" => '1',
3368
- "wplc_record_ip_address" => '0',
3369
- "wplc_pro_chat_email_address" => $wplc_admin_email,
3370
- "wplc_pro_fst1" => __("Questions?", "wplivechat"),
3371
- "wplc_pro_fst2" => __("Chat with us", "wplivechat"),
3372
- "wplc_pro_fst3" => __("Start live chat", "wplivechat"),
3373
- "wplc_pro_sst1" => __("Start Chat", "wplivechat"),
3374
- "wplc_pro_sst1_survey" => __("Or chat to an agent now", "wplivechat"),
3375
- "wplc_pro_sst1e_survey" => __("Chat ended", "wplivechat"),
3376
- "wplc_pro_sst2" => __("Connecting. Please be patient...", "wplivechat"),
3377
- "wplc_pro_tst1" => __("Reactivating your previous chat...", "wplivechat"),
3378
- "wplc_pro_na" => __("Chat offline. Leave a message", "wplivechat"),
3379
- "wplc_pro_intro" => __("Hello. Please input your details so that I may help you.", "wplivechat"),
3380
- "wplc_pro_offline1" => __("We are currently offline. Please leave a message and we'll get back to you shortly.", "wplivechat"),
3381
- "wplc_pro_offline2" => __("Sending message...", "wplivechat"),
3382
- "wplc_pro_offline3" => __("Thank you for your message. We will be in contact soon.", "wplivechat"),
3383
- "wplc_pro_offline_btn" => __("Leave a message", "wplivechat"),
3384
- "wplc_pro_offline_btn_send" => __("Send message", "wplivechat"),
3385
- "wplc_user_enter" => __("Press ENTER to send your message", "wplivechat"),
3386
- "wplc_text_chat_ended" => __("The chat has been ended by the operator.", "wplivechat"),
3387
- "wplc_close_btn_text" => __("close", "wplivechat"),
3388
- "wplc_user_welcome_chat" => __("Welcome. How may I help you?", "wplivechat"),
3389
- 'wplc_welcome_msg' => __("Please standby for an agent. While you wait for the agent you may type your message.","wplivechat")
3390
-
3391
- );
3392
-
3393
- //Added V8: Default Settings array filter
3394
- $wplc_default_settings_array = apply_filters("wplc_activate_default_settings_array", $wplc_default_settings_array);
3395
-
3396
- add_option('WPLC_SETTINGS', $wplc_default_settings_array);
3397
- }
3398
-
3399
-
3400
-
3401
-
3402
-
3403
-
3404
- $admins = get_role('administrator');
3405
- if( $admins !== null ) { $admins->add_cap('wplc_ma_agent'); }
3406
-
3407
-
3408
- $uid = get_current_user_id();
3409
- update_user_meta($uid, 'wplc_ma_agent', 1);
3410
- update_user_meta($uid, "wplc_chat_agent_online", time());
3411
-
3412
- add_option("WPLC_HIDE_CHAT", "true");
3413
-
3414
-
3415
- do_action("wplc_activate_hook");
3416
- }
3417
-
3418
-
3419
-
3420
- function wplc_handle_db() {
3421
- global $wpdb;
3422
- global $wplc_version;
3423
- global $wplc_tblname_chats;
3424
- global $wplc_tblname_msgs;
3425
- global $wplc_tblname_offline_msgs;
3426
-
3427
- $sql = "
3428
- CREATE TABLE " . $wplc_tblname_chats . " (
3429
- id int(11) NOT NULL AUTO_INCREMENT,
3430
- timestamp datetime NOT NULL,
3431
- name varchar(700) NOT NULL,
3432
- email varchar(700) NOT NULL,
3433
- ip varchar(700) NOT NULL,
3434
- status int(11) NOT NULL,
3435
- session varchar(100) NOT NULL,
3436
- url varchar(700) NOT NULL,
3437
- last_active_timestamp datetime NOT NULL,
3438
- agent_id INT(11) NOT NULL,
3439
- other LONGTEXT NOT NULL,
3440
- rel varchar(40) NOT NULL,
3441
- PRIMARY KEY (id)
3442
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
3443
- ";
3444
-
3445
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
3446
- dbDelta($sql);
3447
-
3448
-
3449
-
3450
-
3451
- $sql = '
3452
- CREATE TABLE ' . $wplc_tblname_msgs . ' (
3453
- id int(11) NOT NULL AUTO_INCREMENT,
3454
- chat_sess_id int(11) NOT NULL,
3455
- msgfrom varchar(150) CHARACTER SET utf8 NOT NULL,
3456
- msg LONGTEXT CHARACTER SET utf8 NOT NULL,
3457
- timestamp datetime NOT NULL,
3458
- status INT(3) NOT NULL,
3459
- originates INT(3) NOT NULL,
3460
- other LONGTEXT NOT NULL,
3461
- rel varchar(40) NOT NULL,
3462
- afrom INT(10) NOT NULL,
3463
- ato INT(10) NOT NULL,
3464
- PRIMARY KEY (id)
3465
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
3466
- ';
3467
-
3468
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
3469
- @dbDelta($sql);
3470
-
3471
- /* check for previous versions containing 'from' instead of 'msgfrom' */
3472
- $results = $wpdb->get_results("DESC $wplc_tblname_msgs");
3473
- $founded = 0;
3474
- foreach ($results as $row ) {
3475
- if ($row->Field == "from") {
3476
- $founded++;
3477
- }
3478
- }
3479
-
3480
- if ($founded>0) { $wpdb->query("ALTER TABLE ".$wplc_tblname_msgs." CHANGE `from` `msgfrom` varchar(150)"); }
3481
-
3482
-
3483
- $sql2 = "
3484
- CREATE TABLE " . $wplc_tblname_offline_msgs . " (
3485
- id int(11) NOT NULL AUTO_INCREMENT,
3486
- timestamp datetime NOT NULL,
3487
- name varchar(700) NOT NULL,
3488
- email varchar(700) NOT NULL,
3489
- message varchar(700) NOT NULL,
3490
- ip varchar(700) NOT NULL,
3491
- user_agent varchar(700) NOT NULL,
3492
- PRIMARY KEY (id)
3493
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
3494
- ";
3495
-
3496
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
3497
- @dbDelta($sql2);
3498
-
3499
- add_option("wplc_db_version", $wplc_version);
3500
- update_option("wplc_db_version", $wplc_version);
3501
- }
3502
-
3503
- function wplc_add_user_stylesheet() {
3504
- global $wplc_version;
3505
- if(function_exists('wplc_display_chat_contents')){
3506
- $show_chat_contents = wplc_display_chat_contents();
3507
- } else {
3508
- $show_chat_contents = 1;
3509
- }
3510
- if($show_chat_contents >= 1){
3511
- $wplc_settings = get_option( 'WPLC_SETTINGS' );
3512
- if ( isset( $wplc_settings ) && isset( $wplc_settings['wplc_enable_font_awesome'] ) && '1' === $wplc_settings['wplc_enable_font_awesome'] ) {
3513
- wp_register_style( 'wplc-font-awesome', plugins_url( '/css/font-awesome.min.css', __FILE__ ) );
3514
-
3515
- wp_enqueue_style( 'wplc-font-awesome' );
3516
- }
3517
- wp_register_style('wplc-style', plugins_url('/css/wplcstyle.css', __FILE__), array(), $wplc_version);
3518
- wp_enqueue_style('wplc-style');
3519
-
3520
- if( isset( $wplc_settings['wplc_elem_trigger_id'] ) && trim( $wplc_settings['wplc_elem_trigger_id'] ) !== "" ) {
3521
- if( isset( $wplc_settings['wplc_elem_trigger_type'] ) ){
3522
- if ( $wplc_settings['wplc_elem_trigger_type'] === "0" ) {
3523
- /* class */
3524
- $wplc_elem_style_prefix = ".";
3525
- } else {
3526
- /* ID */
3527
- $wplc_elem_style_prefix = "#";
3528
- }
3529
- }
3530
-
3531
- $wplc_elem_inline_style = $wplc_elem_style_prefix.stripslashes( $wplc_settings['wplc_elem_trigger_id'] ).":hover { cursor:pointer; }";
3532
- wp_add_inline_style( 'wplc-style', stripslashes( $wplc_elem_inline_style ) );
3533
- }
3534
-
3535
- // Serve the icon up over HTTPS if needs be
3536
- //$icon = plugins_url('images/chaticon.png', __FILE__);
3537
- $icon = plugins_url('images/iconRetina.png', __FILE__);
3538
- $close_icon = plugins_url('images/iconCloseRetina.png', __FILE__);
3539
-
3540
-
3541
- if ( isset( $wplc_settings['wplc_settings_bg'] ) ) {
3542
- if ( $wplc_settings['wplc_settings_bg'] == "0" ) { $bg = false; } else { $bg = esc_attr( $wplc_settings['wplc_settings_bg'] ); }
3543
- } else { $bg = "cloudy.jpg"; }
3544
- if ($bg) {
3545
- $bg = plugins_url('images/bg/'.$bg, __FILE__);
3546
- $bg_string = "#wp-live-chat-4 { background:url('$bg') repeat; background-size: cover; }";
3547
- } else { $bg_string = "#wp-live-chat-4 { background-color: #fff; }"; }
3548
-
3549
- if( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] ){ $icon = preg_replace('/^http:\/\//', 'https:\/\/', $icon); }
3550
- if( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] ){ $close_icon = preg_replace('/^http:\/\//', 'https:\/\/', $close_icon); }
3551
- $icon = apply_filters("wplc_filter_chaticon",$icon);
3552
-
3553
- $close_icon = apply_filters("wplc_filter_chaticon_close",$close_icon);
3554
-
3555
- $wplc_elem_inline_style = "#wp-live-chat-header { background:url('$icon') no-repeat; background-size: cover; } #wp-live-chat-header.active { background:url('$close_icon') no-repeat; background-size: cover; } $bg_string";
3556
- wp_add_inline_style( 'wplc-style', stripslashes( $wplc_elem_inline_style ) );
3557
-
3558
-
3559
-
3560
- global $wplc_pro_version;
3561
- $wplc_ver = str_replace('.', '', $wplc_pro_version);
3562
- $checker = intval($wplc_ver);
3563
-
3564
- if (function_exists("wplc_pro_version_control") && $checker < 6000) {
3565
- /* old pro version backwards compatibility */
3566
- wp_register_style('wplc-style-pro', plugins_url('/css/wplcstyle_old.css', __FILE__));
3567
- wp_enqueue_style('wplc-style-pro');
3568
-
3569
-
3570
- }
3571
-
3572
-
3573
-
3574
- $wplc_settings = get_option('WPLC_SETTINGS');
3575
- if (isset($wplc_settings['wplc_theme'])) { $wplc_theme = $wplc_settings['wplc_theme']; } else { $wplc_theme = "theme-default"; }
3576
-
3577
- if ( (isset($wplc_theme) && $checker >= 6000 ) || (! function_exists("wplc_pro_version_control") ) ) {
3578
- if($wplc_theme == 'theme-default') {
3579
- wp_register_style('wplc-theme-palette-default', plugins_url('/css/themes/theme-default.css', __FILE__), array(), $wplc_version);
3580
- wp_enqueue_style('wplc-theme-palette-default');
3581
-
3582
- }
3583
- else if($wplc_theme == 'theme-1') {
3584
- wp_register_style('wplc-theme-palette-1', plugins_url('/css/themes/theme-1.css', __FILE__), array(), $wplc_version);
3585
- wp_enqueue_style('wplc-theme-palette-1');
3586
-
3587
- }
3588
- else if($wplc_theme == 'theme-2') {
3589
- wp_register_style('wplc-theme-palette-2', plugins_url('/css/themes/theme-2.css', __FILE__), array(), $wplc_version);
3590
- wp_enqueue_style('wplc-theme-palette-2');
3591
-
3592
- }
3593
- else if($wplc_theme == 'theme-3') {
3594
- wp_register_style('wplc-theme-palette-3', plugins_url('/css/themes/theme-3.css', __FILE__), array(), $wplc_version);
3595
- wp_enqueue_style('wplc-theme-palette-3');
3596
-
3597
- }
3598
- else if($wplc_theme == 'theme-4') {
3599
- wp_register_style('wplc-theme-palette-4', plugins_url('/css/themes/theme-4.css', __FILE__), array(), $wplc_version);
3600
- wp_enqueue_style('wplc-theme-palette-4');
3601
-
3602
- }
3603
- else if($wplc_theme == 'theme-5') {
3604
- wp_register_style('wplc-theme-palette-5', plugins_url('/css/themes/theme-5.css', __FILE__), array(), $wplc_version);
3605
- wp_enqueue_style('wplc-theme-palette-5');
3606
-
3607
- }
3608
- else if($wplc_theme == 'theme-6') {
3609
- /* custom */
3610
- /* handled elsewhere */
3611
-
3612
-
3613
-
3614
- }
3615
-
3616
-
3617
-
3618
-
3619
-
3620
- if (isset($wplc_settings['wplc_newtheme'])) { $wplc_newtheme = $wplc_settings['wplc_newtheme']; } else { $wplc_newtheme = "theme-2"; }
3621
- if (isset($wplc_newtheme)) {
3622
- if($wplc_newtheme == 'theme-1') {
3623
- wp_register_style('wplc-theme-classic', plugins_url('/css/themes/classic.css', __FILE__), array(), $wplc_version);
3624
- wp_enqueue_style('wplc-theme-classic');
3625
-
3626
- }
3627
- else if($wplc_newtheme == 'theme-2') {
3628
- wp_register_style('wplc-theme-modern', plugins_url('/css/themes/modern.css', __FILE__), array(), $wplc_version);
3629
- wp_enqueue_style('wplc-theme-modern');
3630
-
3631
- }
3632
- }
3633
-
3634
- if ($wplc_settings["wplc_settings_align"] == 1) {
3635
- wp_register_style('wplc-theme-position', plugins_url('/css/themes/position-bottom-left.css', __FILE__), array(), $wplc_version);
3636
- wp_enqueue_style('wplc-theme-position');
3637
- } else if ($wplc_settings["wplc_settings_align"] == 2) {
3638
- wp_register_style('wplc-theme-position', plugins_url('/css/themes/position-bottom-right.css', __FILE__), array(), $wplc_version);
3639
- wp_enqueue_style('wplc-theme-position');
3640
- } else if ($wplc_settings["wplc_settings_align"] == 3) {
3641
- wp_register_style('wplc-theme-position', plugins_url('/css/themes/position-left.css', __FILE__), array(), $wplc_version);
3642
- wp_enqueue_style('wplc-theme-position');
3643
- } else if ($wplc_settings["wplc_settings_align"] == 4) {
3644
- wp_register_style('wplc-theme-position', plugins_url('/css/themes/position-right.css', __FILE__), array(), $wplc_version);
3645
- wp_enqueue_style('wplc-theme-position');
3646
- } else {
3647
- wp_register_style('wplc-theme-position', plugins_url('/css/themes/position-bottom-right.css', __FILE__), array(), $wplc_version);
3648
- wp_enqueue_style('wplc-theme-position');
3649
- }
3650
-
3651
- }
3652
-
3653
- // Gutenberg template styles - user
3654
- wp_register_style( 'wplc-gutenberg-template-styles-user', plugins_url( '/includes/blocks/wplc-chat-box/wplc_gutenberg_template_styles.css', __FILE__ ) );
3655
- wp_enqueue_style( 'wplc-gutenberg-template-styles-user' );
3656
-
3657
- // GIF integration styles - user
3658
- wp_register_style( 'wplc-gif-integration-user', plugins_url( '/css/wplc_gif_integration.css', __FILE__ ) );
3659
- wp_enqueue_style( 'wplc-gif-integration-user' );
3660
- }
3661
- if(function_exists('wplc_ce_activate')){
3662
- if(function_exists('wplc_ce_load_user_styles')){
3663
- wplc_ce_load_user_styles();
3664
- }
3665
- }
3666
- }
3667
-
3668
-
3669
- add_action( 'init', 'wplc_online_check_script', 10 );
3670
- /**
3671
- * Load the JS that allows us to integrate into the WP Heartbeat
3672
- * @return void
3673
- */
3674
- function wplc_online_check_script() {
3675
- global $wplc_version;
3676
- if (esc_attr( get_the_author_meta( 'wplc_ma_agent', get_current_user_id() ) ) == "1"){
3677
- $ajax_nonce = wp_create_nonce("wplc");
3678
- wp_register_script( 'wplc-heartbeat', plugins_url( 'js/wplc_heartbeat.js', __FILE__ ), array( 'jquery' ), $wplc_version, true );
3679
- wp_enqueue_script( 'wplc-heartbeat' );
3680
- wp_localize_script( 'wplc-heartbeat', 'wplc_transient_nonce', $ajax_nonce );
3681
-
3682
- $wplc_ajax_url = apply_filters("wplc_filter_ajax_url", admin_url('admin-ajax.php'));
3683
- wp_localize_script('wplc-heartbeat', 'wplc_ajaxurl', $wplc_ajax_url);
3684
- }
3685
- }
3686
-
3687
- /**
3688
- * Heartbeat integrations
3689
- *
3690
- */
3691
- add_filter( 'heartbeat_received', 'wplc_heartbeat_receive', 10, 2 );
3692
- add_filter( 'heartbeat_nopriv_received', 'wplc_heartbeat_receive', 10, 2 );
3693
- function wplc_heartbeat_receive( $response, $data ) {
3694
- if ( $data['client'] == 'wplc_heartbeat' ) {
3695
- if (esc_attr( get_the_author_meta( 'wplc_ma_agent', get_current_user_id() ) ) == "1"){
3696
- update_user_meta(get_current_user_id(), "wplc_chat_agent_online", time());
3697
- wplc_hook_control_set_transient();
3698
- }
3699
- }
3700
- return $response;
3701
- }
3702
-
3703
-
3704
-
3705
- /**
3706
- * Loads the admin stylesheets for the chat dashboard and settings pages
3707
- * @return void
3708
- */
3709
- function wplc_add_admin_stylesheet() {
3710
- global $wplc_version;
3711
-
3712
- wp_register_style( 'wplc-ace-styles', plugins_url( '/css/ace.css', __FILE__ ) );
3713
- wp_enqueue_style( 'wplc-ace-styles' );
3714
-
3715
- wp_register_style( 'wplc-fontawesome-iconpicker', plugins_url( '/css/fontawesome-iconpicker.css', __FILE__ ) );
3716
- wp_enqueue_style( 'wplc-fontawesome-iconpicker' );
3717
-
3718
- $wplc_settings = get_option("WPLC_SETTINGS");
3719
- if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1 && (!isset($_GET['action']) || $_GET['action'] !== "history") ){
3720
- //if(isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu'){
3721
- //Using node, remote styles please
3722
- //Using node, remote scripts please
3723
- if ( isset( $wplc_settings['wplc_enable_all_admin_pages'] ) && $wplc_settings['wplc_enable_all_admin_pages'] === '1' ) {
3724
- /* Run admin JS on all admin pages */
3725
- wplc_admin_remote_dashboard_styles();
3726
- } else {
3727
- /* Only run admin JS on the chat dashboard page */
3728
- if ( isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu' && !isset( $_GET['action'] ) ) {
3729
- wplc_admin_remote_dashboard_styles();
3730
- }
3731
- }
3732
-
3733
- wp_register_style( 'wplc-admin-remote-addition-styles', plugins_url( '/css/remote_dash_styles.css', __FILE__ ), array(), $wplc_version );
3734
- wp_enqueue_style( 'wplc-admin-remote-addition-styles' );
3735
-
3736
- //}
3737
- }
3738
- //Special new check to see if we need to add the node history styling
3739
- if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1 && isset($_GET['action']) && $_GET['action'] == 'history'){
3740
- wp_register_style( 'wplc-admin-node-history-styles', plugins_url( '/css/node_history_styles.css', __FILE__ ) );
3741
- wp_enqueue_style( 'wplc-admin-node-history-styles' );
3742
- }
3743
-
3744
- if (isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu' && isset($_GET['action']) && ($_GET['action'] == "ac" || $_GET['action'] == "history" ) ) {
3745
- wp_register_style('wplc-admin-chat-box-style', plugins_url('/css/admin-chat-box-style.css', __FILE__ ), false, $wplc_version );
3746
- wp_enqueue_style('wplc-admin-chat-box-style');
3747
- }
3748
-
3749
- wp_register_style( 'wplc-font-awesome', plugins_url('css/font-awesome.min.css', __FILE__ ), false, $wplc_version );
3750
- wp_enqueue_style( 'wplc-font-awesome' );
3751
-
3752
- if (isset($_GET['page']) && ($_GET['page'] == 'wplivechat-menu' || $_GET['page'] == 'wplivechat-menu-api-keys-page' || $_GET['page'] == 'wplivechat-menu-extensions-page' || $_GET['page'] == 'wplivechat-menu-settings' || $_GET['page'] == 'wplivechat-menu-offline-messages' || $_GET['page'] == 'wplivechat-menu-history' || $_GET['page'] == 'wplivechat-menu-missed-chats' || $_GET['page'] == 'wplivechat-menu-dashboard')) {
3753
- wp_register_style( 'wplc-jquery-ui', plugins_url( '/css/jquery-ui.css', __FILE__ ), false, $wplc_version );
3754
- wp_enqueue_style( 'wplc-jquery-ui' );
3755
-
3756
- wp_enqueue_script( 'jquery-ui-core' );
3757
- wp_enqueue_script( 'jquery-effects-core' );
3758
-
3759
- // Gutenberg template styles - admin
3760
- wp_register_style( 'wplc-gutenberg-template-styles', plugins_url( '/includes/blocks/wplc-chat-box/wplc_gutenberg_template_styles.css', __FILE__ ) );
3761
- wp_enqueue_style( 'wplc-gutenberg-template-styles' );
3762
-
3763
- wp_register_style( 'wplc-admin-styles', plugins_url( '/css/admin_styles.css', __FILE__ ), false, $wplc_version );
3764
- wp_enqueue_style( 'wplc-admin-styles' );
3765
-
3766
- // Old admin chat style
3767
- if ((!isset($wplc_settings['wplc_use_node_server'])) || ($wplc_settings['wplc_use_node_server'] != 1)) {
3768
- wp_register_style( 'wplc-chat-style', plugins_url( '/css/chat-style.css', __FILE__ ), false, $wplc_version );
3769
- wp_enqueue_style( 'wplc-chat-style' );
3770
-
3771
- // New admin chat style
3772
- } else if (isset($wplc_settings['wplc_use_node_server']) && ($wplc_settings['wplc_use_node_server'] == 1)) {
3773
- wp_register_style( 'wplc-admin-chat-style', plugins_url( '/css/admin-chat-style.css', __FILE__ ), false, $wplc_version );
3774
- wp_enqueue_style( 'wplc-admin-chat-style' );
3775
- }
3776
- }
3777
-
3778
- // Gif Integration styles - admin
3779
- wp_register_style( 'wplc-gif-integration', plugins_url( '/css/wplc_gif_integration.css', __FILE__ ) );
3780
- wp_enqueue_style( 'wplc-gif-integration' );
3781
-
3782
- // This loads the chat styling on all admin pages as we are using the popout dashboard
3783
- if ( isset( $wplc_settings['wplc_use_node_server'] ) && ( $wplc_settings['wplc_use_node_server'] == 1 ) && ( isset( $wplc_settings['wplc_enable_all_admin_pages'] ) && $wplc_settings['wplc_enable_all_admin_pages'] === '1') ) {
3784
-
3785
- wp_register_style( 'wplc-admin-chat-style', plugins_url( '/css/admin-chat-style.css', __FILE__ ), false, $wplc_version );
3786
- wp_enqueue_style( 'wplc-admin-chat-style' );
3787
- }
3788
-
3789
- if (isset($_GET['page']) && $_GET['page'] == "wplivechat-menu-support-page") {
3790
- wp_register_style('fontawesome', plugins_url('css/font-awesome.min.css', __FILE__ ), false, $wplc_version );
3791
- wp_enqueue_style('fontawesome');
3792
- wp_register_style('wplc-support-page-css', plugins_url('css/support-css.css', __FILE__ ), false, $wplc_version );
3793
- wp_enqueue_style('wplc-support-page-css');
3794
- }
3795
-
3796
- if(isset($_GET['immersive_mode'])){
3797
- wp_add_inline_style( 'wplc-admin-style', "#wpcontent { margin-left: 0px !important;} #wpadminbar, #wpfooter, #adminmenumain {display: none !important;}" );
3798
- }
3799
- }
3800
-
3801
- if (isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu-settings') {
3802
- add_action('admin_print_scripts', 'wplc_admin_scripts_basic');
3803
- }
3804
-
3805
- /**
3806
- * Loads the admin scripts for the chat dashboard and settings pages
3807
- * @return void
3808
- */
3809
- function wplc_admin_scripts_basic() {
3810
-
3811
- $gutenberg_default_html = '<!-- Default HTML -->
3812
- <div class="wplc_block">
3813
- <span class="wplc_block_logo">{wplc_logo}</span>
3814
- <span class="wplc_block_text">{wplc_text}</span>
3815
- <span class="wplc_block_icon">{wplc_icon}</span>
3816
- </div>';
3817
-
3818
- if (isset($_GET['page']) && $_GET['page'] == "wplivechat-menu-settings") {
3819
- wp_enqueue_script('jquery');
3820
- wp_enqueue_script('jquery-ui-core');
3821
- wp_enqueue_script('jquery-ui-tooltip');
3822
- wp_register_script('my-wplc-color', plugins_url('js/jscolor.js', __FILE__), false, '1.4.1', false);
3823
- wp_enqueue_script('my-wplc-color');
3824
- wp_enqueue_script('jquery-ui-tabs');
3825
- wp_register_script('my-wplc-tabs', plugins_url('js/wplc_tabs.js', __FILE__), array('jquery-ui-core'), '', true);
3826
- wp_enqueue_script('my-wplc-tabs');
3827
- wp_enqueue_media();
3828
- wp_register_script('wplc-fontawesome-iconpicker', plugins_url('js/fontawesome-iconpicker.js', __FILE__), array('jquery'), '', true);
3829
- wp_enqueue_script('wplc-fontawesome-iconpicker');
3830
- wp_register_script('wplc-gutenberg', plugins_url('js/wplc_gutenberg.js', __FILE__), array('jquery'), '', true);
3831
- wp_enqueue_script('wplc-gutenberg');
3832
- wp_localize_script( 'wplc-gutenberg', 'default_html', $gutenberg_default_html );
3833
- }
3834
- }
3835
-
3836
- /**
3837
- * Loads basic version's settings page
3838
- * @return void
3839
- */
3840
- function wplc_admin_settings_layout() {
3841
- wplc_settings_page_basic();
3842
- }
3843
-
3844
- /**
3845
- * Loads the dashboard page
3846
- * @return void
3847
- */
3848
- function wplc_admin_dashboard_layout() {
3849
- include 'includes/dashboard_page.php';
3850
- }
3851
-
3852
- add_action("wplc_hook_history_draw_area","wplc_hook_control_history_draw_area",10,1);
3853
- /**
3854
- * Display normal history page
3855
- * @param int $cid Chat ID
3856
- * @return void
3857
- * @since 6.1.00
3858
- * @author Nick Duncan <nick@codecabin.co.za>
3859
- */
3860
- function wplc_hook_control_history_draw_area($cid) {
3861
- wplc_draw_chat_area($cid);
3862
- }
3863
-
3864
- /**
3865
- * What to display for the chat history
3866
- * @param int $cid Chat ID
3867
- * @return void
3868
- * @since 6.1.00
3869
- * @author Nick Duncan <nick@codecabin.co.za>
3870
- */
3871
- function wplc_admin_view_chat_history($cid) {
3872
- do_action("wplc_hook_history_draw_area",$cid);
3873
- }
3874
-
3875
-
3876
- add_action( 'wplc_hook_admin_menu_layout_display' , 'wplc_hook_control_history_get_control', 1, 3);
3877
- /**
3878
- * Control history GET calls
3879
- * @param string $action The GET action
3880
- * @param int $cid The chat id
3881
- * @param int $aid AID
3882
- * @return void
3883
- * @since 6.1.00
3884
- * @author Nick Duncan <nick@codecabin.co.za>
3885
- */
3886
- function wplc_hook_control_history_get_control($action,$cid,$aid) {
3887
-
3888
- if ($action == 'history') {
3889
- wplc_admin_view_chat_history(sanitize_text_field($cid));
3890
- } else if ($action == 'download_history'){
3891
-
3892
- //Moved into the init hook as of version 6.0.01 due to different functionality
3893
-
3894
- //wplc_admin_download_history(sanitize_text_field($_GET['type']), sanitize_text_field($cid));
3895
- }
3896
-
3897
-
3898
- }
3899
-
3900
-
3901
- add_action("wplc_hook_chat_history","wplc_hook_control_chat_history");
3902
- /**
3903
- * Renders the chat history content
3904
- * @return string
3905
- */
3906
- function wplc_hook_control_chat_history() {
3907
-
3908
- if (is_admin()) {
3909
-
3910
- global $wpdb;
3911
- global $wplc_tblname_chats;
3912
- global $wplc_tblname_msgs;
3913
-
3914
- if(isset($_GET['wplc_action']) && $_GET['wplc_action'] == 'remove_cid'){
3915
- if(isset($_GET['cid'])){
3916
- if(isset($_GET['wplc_confirm'])){
3917
- //Confirmed - delete
3918
- $delete_sql = "
3919
- DELETE FROM $wplc_tblname_chats
3920
- WHERE `id` = '".intval($_GET['cid'])."'
3921
- ";
3922
- $delete_messages = "
3923
- DELETE FROM $wplc_tblname_msgs
3924
- WHERE `chat_sess_id` = '".intval($_GET['cid'])."'
3925
- ";
3926
-
3927
- $wplc_was_error = false;
3928
-
3929
- $wpdb->query($delete_sql);
3930
- if ($wpdb->last_error) { $wplc_was_error = true; }
3931
- $wpdb->query($delete_messages);
3932
- if ($wpdb->last_error) { $wplc_was_error = true; }
3933
-
3934
- if ($wplc_was_error) {
3935
- echo "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>
3936
- ".__("Error: Could not delete chat", "wplivechat")."<br>
3937
- </div>";
3938
- } else {
3939
- echo "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;border-color:#67d552;'>
3940
- ".__("Chat Deleted", "wplivechat")."<br>
3941
- </div>";
3942
- }
3943
-
3944
- } else {
3945
- //Prompt
3946
- echo "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>
3947
- ".__("Are you sure you would like to delete this chat?", "wplivechat")."<br>
3948
- <a class='button' href='?page=wplivechat-menu-history&wplc_action=remove_cid&cid=".sanitize_text_field( $_GET['cid'] )."&wplc_confirm=1''>".__("Yes", "wplivechat")."</a> <a class='button' href='?page=wplivechat-menu-history'>".__("No", "wplivechat")."</a>
3949
- </div>";
3950
- }
3951
- }
3952
- }
3953
-
3954
- $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
3955
- $limit = 20; // number of rows in page
3956
- $offset = ( $pagenum - 1 ) * $limit;
3957
- $total = $wpdb->get_var( "SELECT COUNT(`id`) FROM $wplc_tblname_chats" );
3958
- $num_of_pages = ceil( $total / $limit );
3959
-
3960
- $results = $wpdb->get_results(
3961
- "
3962
- SELECT *
3963
- FROM $wplc_tblname_chats
3964
- WHERE `name` NOT LIKE 'agent-to-agent chat'
3965
- ORDER BY `timestamp` DESC
3966
- LIMIT $limit OFFSET $offset
3967
- "
3968
- );
3969
- echo "
3970
- <form method=\"post\" >
3971
- <input type=\"submit\" value=\"".__('Delete History', 'wplivechat')."\" class='button' name=\"wplc-delete-chat-history\" /><br /><br />
3972
- </form>
3973
-
3974
- <table class=\"wp-list-table wplc_list_table widefat fixed \" cellspacing=\"0\">
3975
- <thead>
3976
- <tr>
3977
- <th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><span>" . __("Date", "wplivechat") . "</span></th>
3978
- <th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><span>" . __("Name", "wplivechat") . "</span></th>
3979
- <th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\">" . __("Email", "wplivechat") . "</th>
3980
- <th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\">" . __("URL", "wplivechat") . "</th>
3981
- <th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\">" . __("Status", "wplivechat") . "</th>
3982
- <th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><span>" . __("Action", "wplivechat") . "</span></th>
3983
- </tr>
3984
- </thead>
3985
- <tbody id=\"the-list\" class='list:wp_list_text_link'>
3986
- ";
3987
- if (!$results) {
3988
- echo "<tr><td></td><td>" . __("No chats available at the moment", "wplivechat") . "</td></tr>";
3989
- } else {
3990
- foreach ($results as $result) {
3991
- unset($trstyle);
3992
- unset($actions);
3993
-
3994
- $tcid = sanitize_text_field( $result->id );
3995
-
3996
-
3997
- $url = admin_url('admin.php?page=wplivechat-menu&action=history&cid=' . $tcid);
3998
- $url2 = admin_url('admin.php?page=wplivechat-menu&action=download_history&type=csv&cid=' . $tcid);
3999
- $url3 = "?page=wplivechat-menu-history&wplc_action=remove_cid&cid=" . $tcid;
4000
- $actions = "
4001
- <a href='$url' class='button' title='".__('View Chat History', 'wplivechat')."' target='_BLANK' id=''><i class='fa fa-eye'></i></a> <a href='$url2' class='button' title='".__('Download Chat History', 'wplivechat')."' target='_BLANK' id=''><i class='fa fa-download'></i></a> <a href='$url3' class='button'><i class='fa fa-trash-o'></i></a>
4002
- ";
4003
- $trstyle = "style='height:30px;'";
4004
-
4005
- echo "<tr id=\"record_" . $tcid . "\" $trstyle>";
4006
- echo "<td class='chat_id column-chat_d'>" . date("Y-m-d H:i:s", current_time( strtotime( $result->timestamp ) ) ) . "</td>";
4007
- echo "<td class='chat_name column_chat_name' id='chat_name_" . $tcid . "'><img src=\"//www.gravatar.com/avatar/" . md5($result->email) . "?s=40\" /> " . sanitize_text_field($result->name) . "</td>";
4008
- echo "<td class='chat_email column_chat_email' id='chat_email_" . $tcid . "'><a href='mailto:" . sanitize_text_field($result->email) . "' title='Email " . ".$result->email." . "'>" . sanitize_text_field ($result->email) . "</a></td>";
4009
- echo "<td class='chat_name column_chat_url' id='chat_url_" . $tcid . "'>" . esc_url($result->url) . "</td>";
4010
- echo "<td class='chat_status column_chat_status' id='chat_status_" . $tcid . "'><strong>" . wplc_return_status($result->status) . "</strong></td>";
4011
- echo "<td class='chat_action column-chat_action' id='chat_action_" . $tcid . "'>$actions</td>";
4012
- echo "</tr>";
4013
- }
4014
- }
4015
- echo "</table>";
4016
-
4017
- $page_links = paginate_links( array(
4018
- 'base' => add_query_arg( 'pagenum', '%#%' ),
4019
- 'format' => '',
4020
- 'prev_text' => __( '&laquo;', 'wplivechat' ),
4021
- 'next_text' => __( '&raquo;', 'wplivechat' ),
4022
- 'total' => $num_of_pages,
4023
- 'current' => $pagenum
4024
- ) );
4025
-
4026
- if ( $page_links ) {
4027
- echo '<div class="tablenav"><div class="tablenav-pages" style="margin: 1em 0;float:none;text-align:center;">' . $page_links . '</div></div>';
4028
- }
4029
- }
4030
-
4031
-
4032
- }
4033
-
4034
- /**
4035
- * Loads the chat history layout to accommodate basic/pro versions
4036
- * @return string
4037
- */
4038
- function wplc_admin_history_layout() {
4039
- wplc_stats("history");
4040
- echo"<div class=\"wrap wplc_wrap\"><div id=\"icon-edit\" class=\"icon32 icon32-posts-post\"><br></div><h2>" . __("WP Live Chat History", "wplivechat") . "</h2>";
4041
-
4042
- do_action("wplc_before_history_table_hook");
4043
-
4044
- if(function_exists("wplc_ce_activate")){
4045
- wplc_ce_admin_display_history();
4046
- } else if (function_exists("wplc_register_pro_version")) {
4047
- wplc_pro_admin_display_history();
4048
- } else {
4049
- do_action("wplc_hook_chat_history");
4050
- }
4051
- }
4052
-
4053
-
4054
- add_action("wplc_hook_chat_missed","wplc_hook_control_missed_chats",10);
4055
- /**
4056
- * Loads missed chats contents
4057
- * @return string
4058
- */
4059
- function wplc_hook_control_missed_chats() {
4060
- if (function_exists('wplc_admin_display_missed_chats')) { wplc_admin_display_missed_chats(); }
4061
- }
4062
-
4063
- /**
4064
- * Loads the missed chats page wrapper
4065
- * @return string
4066
- */
4067
- function wplc_admin_missed_chats() {
4068
- wplc_stats("missed");
4069
- echo "<div class=\"wrap wplc_wrap\"><div id=\"icon-edit\" class=\"icon32 icon32-posts-post\"><br></div><h2>" . __("WP Live Chat Missed Chats", "wplivechat") . "</h2>";
4070
- do_action("wplc_hook_chat_missed");
4071
- }
4072
-
4073
- add_action("wplc_hook_offline_messages_display","wplc_hook_control_offline_messages_display",10);
4074
- /**
4075
- * Loads the offline messages page contents
4076
- * @return string
4077
- */
4078
- function wplc_hook_control_offline_messages_display() {
4079
- if (function_exists("wplc_admin_display_offline_messages_new")) { wplc_admin_display_offline_messages_new(); } else {
4080
- if (function_exists("wplc_register_pro_version")) {
4081
- if (function_exists('wplc_pro_admin_display_offline_messages')) {
4082
- wplc_pro_admin_display_offline_messages();
4083
- } else {
4084
- echo "<div class='updated'><p>" . __('Please update to the latest version of WP Live Chat Support Pro to start recording any offline messages.', 'wplivechat') . "</p></div>";
4085
- }
4086
- } else {
4087
- echo "<br /><br >" . _('This option is only available in the ', 'wplivechat') . "<a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=history1\" title=\"" . __("Pro Add-on", "wplivechat") . "\" target=\"_BLANK\">" . __('Pro Add-on', 'wplivechat') . "</a> of WP Live Chat. <a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=missed_chats2\" title=\"" . __("Pro Add-on", "wplivechat") . "\" target=\"_BLANK\"></a>";
4088
- }
4089
- }
4090
-
4091
- }
4092
-
4093
- /**
4094
- * Control who should see the offline messages
4095
- * @return void
4096
- */
4097
- function wplc_admin_offline_messages() {
4098
- wplc_stats("offline_messages");
4099
- echo"<div class=\"wrap wplc_wrap\"><div id=\"icon-edit\" class=\"icon32 icon32-posts-post\"><br></div><h2>" . __("WP Live Chat Offline Messages", "wplivechat") . "</h2>";
4100
- do_action("wplc_hook_offline_messages_display");
4101
- }
4102
-
4103
- /**
4104
- * Output the offline messages in an HTML table
4105
- * @return void
4106
- */
4107
- function wplc_admin_display_offline_messages_new() {
4108
-
4109
- global $wpdb;
4110
- global $wplc_tblname_offline_msgs;
4111
-
4112
- echo "
4113
- <table class=\"wp-list-table wplc_list_table widefat \" cellspacing=\"0\">
4114
- <thead>
4115
- <tr>
4116
- <th class='manage-column column-id'><span>" . __("Date", "wplivechat") . "</span></th>
4117
- <th scope='col' id='wplc_name_colum' class='manage-column column-id'><span>" . __("Name", "wplivechat") . "</span></th>
4118
- <th scope='col' id='wplc_email_colum' class='manage-column column-id'>" . __("Email", "wplivechat") . "</th>
4119
- <th scope='col' id='wplc_message_colum' class='manage-column column-id'>" . __("Message", "wplivechat") . "</th>
4120
- <th scope='col' id='wplc_message_colum' class='manage-column column-id'>" . __("Actions", "wplivechat") . "</th>
4121
- </tr>
4122
- </thead>
4123
- <tbody id=\"the-list\" class='list:wp_list_text_link'>";
4124
-
4125
- $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
4126
- $limit = 20; // number of rows in page
4127
- $offset = ( $pagenum - 1 ) * $limit;
4128
- $total = $wpdb->get_var( "SELECT COUNT(`id`) FROM $wplc_tblname_offline_msgs" );
4129
- $num_of_pages = ceil( $total / $limit );
4130
-
4131
- $sql = "SELECT * FROM $wplc_tblname_offline_msgs ORDER BY `timestamp` DESC LIMIT $limit OFFSET $offset";
4132
-
4133
- $results = $wpdb->get_results($sql);
4134
-
4135
- if (!$results) {
4136
- echo "<tr><td></td><td>" . __("You have not received any offline messages.", "wplivechat") . "</td></tr>";
4137
- } else {
4138
- foreach ($results as $result) {
4139
- echo "<tr id=\"record_" . $result->id . "\">";
4140
- echo "<td class='chat_id column-chat_d'>" . $result->timestamp . "</td>";
4141
- echo "<td class='chat_name column_chat_name' id='chat_name_" . $result->id . "'><img src=\"//www.gravatar.com/avatar/" . md5($result->email) . "?s=30\" /> " . $result->name . "</td>";
4142
- echo "<td class='chat_email column_chat_email' id='chat_email_" . $result->id . "'><a href='mailto:" . $result->email . "' title='Email " . ".$result->email." . "'>" . $result->email . "</a></td>";
4143
- echo "<td class='chat_name column_chat_url' id='chat_url_" . $result->id . "'>" . nl2br($result->message) . "</td>";
4144
- echo "<td class='chat_name column_chat_delete'><button class='button wplc_delete_message' title='".__('Delete Message', 'wplivechat')."' class='wplc_delete_message' mid='".$result->id."'><i class='fa fa-times'></i></button></td>";
4145
- echo "</tr>";
4146
- }
4147
- }
4148
-
4149
- echo "
4150
- </tbody>
4151
- </table>";
4152
-
4153
- $page_links = paginate_links( array(
4154
- 'base' => add_query_arg( 'pagenum', '%#%' ),
4155
- 'format' => '',
4156
- 'prev_text' => __( '&laquo;', 'wplivechat' ),
4157
- 'next_text' => __( '&raquo;', 'wplivechat' ),
4158
- 'total' => $num_of_pages,
4159
- 'current' => $pagenum
4160
- ) );
4161
-
4162
- if ( $page_links ) {
4163
- echo '<div class="tablenav"><div class="tablenav-pages" style="margin: 1em 0;float:none;text-align:center;">' . $page_links . '</div></div>';
4164
- }
4165
- }
4166
-
4167
- /**
4168
- * Loads the basic/pro version's settings pages
4169
- * @return string
4170
- */
4171
- function wplc_settings_page_basic() {
4172
- if (function_exists("wplc_register_pro_version")) {
4173
- wplc_settings_page_pro();
4174
- } else {
4175
- include 'includes/settings_page.php';
4176
- }
4177
- }
4178
-
4179
- /**
4180
- * Updates chat statistics
4181
- * @param string $sec Specify which array key of the stats you'd like access to
4182
- * @return void
4183
- */
4184
- function wplc_stats($sec) {
4185
- $wplc_stats = get_option("wplc_stats");
4186
- if ($wplc_stats) {
4187
- if (isset($wplc_stats[$sec]["views"])) {
4188
- $wplc_stats[$sec]["views"] = $wplc_stats[$sec]["views"] + 1;
4189
- $wplc_stats[$sec]["last_accessed"] = date("Y-m-d H:i:s");
4190
- } else {
4191
- $wplc_stats[$sec]["views"] = 1;
4192
- $wplc_stats[$sec]["last_accessed"] = date("Y-m-d H:i:s");
4193
- $wplc_stats[$sec]["first_accessed"] = date("Y-m-d H:i:s");
4194
- }
4195
-
4196
-
4197
- } else {
4198
-
4199
- $wplc_stats[$sec]["views"] = 1;
4200
- $wplc_stats[$sec]["last_accessed"] = date("Y-m-d H:i:s");
4201
- $wplc_stats[$sec]["first_accessed"] = date("Y-m-d H:i:s");
4202
-
4203
-
4204
- }
4205
- update_option("wplc_stats",$wplc_stats);
4206
-
4207
- }
4208
-
4209
-
4210
- add_action("wplc_hook_head","wplc_hook_control_head");
4211
- /**
4212
- * Deletes the chat history on submission of POST
4213
- * @return bool
4214
- */
4215
- function wplc_hook_control_head() {
4216
- if (isset($_POST['wplc-delete-chat-history'])) {
4217
- wplc_del_history();
4218
- }
4219
- }
4220
-
4221
- /**
4222
- * Deletes all chat history
4223
- * @return bool
4224
- */
4225
- function wplc_del_history(){
4226
- global $wpdb;
4227
- global $wplc_tblname_chats;
4228
- global $wplc_tblname_msgs;
4229
- $wpdb->query("TRUNCATE TABLE $wplc_tblname_chats");
4230
- $wpdb->query("TRUNCATE TABLE $wplc_tblname_msgs");
4231
- }
4232
-
4233
- add_filter("wplc_filter_chat_header_extra_attr","wplc_filter_control_chat_header_extra_attr",10,1);
4234
- /**
4235
- * Controls if the chat window should popup or not
4236
- * @param array $wplc_extra_attr Extra chat data passed
4237
- * @return string
4238
- */
4239
- function wplc_filter_control_chat_header_extra_attr($wplc_extra_attr) {
4240
- $wplc_acbc_data = get_option("WPLC_SETTINGS");
4241
- if (isset($wplc_acbc_data['wplc_auto_pop_up'])) { $extr_string = $wplc_acbc_data['wplc_auto_pop_up']; $wplc_extra_attr .= " wplc-auto-pop-up=\"".$extr_string."\""; }
4242
-
4243
- return $wplc_extra_attr;
4244
- }
4245
-
4246
- /**
4247
- * Admin side headers used to save settings
4248
- * @return string
4249
- */
4250
- function wplc_head_basic() {
4251
- global $wpdb;
4252
-
4253
- do_action("wplc_hook_head");
4254
-
4255
-
4256
- if (isset($_POST['wplc_save_settings'])) {
4257
-
4258
- do_action("wplc_hook_admin_settings_save");
4259
- if (isset($_POST['wplc_settings_align'])) { $wplc_data['wplc_settings_align'] = esc_attr($_POST['wplc_settings_align']); }
4260
- if (isset($_POST['wplc_settings_bg'])) { $wplc_data['wplc_settings_bg'] = esc_attr($_POST['wplc_settings_bg']); }
4261
- if (isset($_POST['wplc_environment'])) { $wplc_data['wplc_environment'] = esc_attr($_POST['wplc_environment']); }
4262
- if (isset($_POST['wplc_settings_fill'])) { $wplc_data['wplc_settings_fill'] = esc_attr($_POST['wplc_settings_fill']); }
4263
- if (isset($_POST['wplc_settings_font'])) { $wplc_data['wplc_settings_font'] = esc_attr($_POST['wplc_settings_font']); }
4264
-
4265
- if (isset($_POST['wplc_settings_color1'])) { $wplc_data['wplc_settings_color1'] = esc_attr($_POST['wplc_settings_color1']); /* backwards compatibility for pro */ $wplc_data['wplc_settings_fill'] = esc_attr($_POST['wplc_settings_color1']); }
4266
- if (isset($_POST['wplc_settings_color2'])) { $wplc_data['wplc_settings_color2'] = esc_attr($_POST['wplc_settings_color2']); /* backwards compatibility for pro */ $wplc_data['wplc_settings_font'] = esc_attr($_POST['wplc_settings_color2']); }
4267
- if (isset($_POST['wplc_settings_color3'])) { $wplc_data['wplc_settings_color3'] = esc_attr($_POST['wplc_settings_color3']); }
4268
- if (isset($_POST['wplc_settings_color4'])) { $wplc_data['wplc_settings_color4'] = esc_attr($_POST['wplc_settings_color4']); }
4269
-
4270
- if (isset($_POST['wplc_settings_enabled'])) { $wplc_data['wplc_settings_enabled'] = esc_attr($_POST['wplc_settings_enabled']); }
4271
- if (isset($_POST['wplc_powered_by_link'])) { $wplc_data['wplc_powered_by_link'] = esc_attr($_POST['wplc_powered_by_link']); }
4272
- if (isset($_POST['wplc_auto_pop_up'])) { $wplc_data['wplc_auto_pop_up'] = esc_attr($_POST['wplc_auto_pop_up']); }
4273
- if (isset($_POST['wplc_require_user_info'])) { $wplc_data['wplc_require_user_info'] = esc_attr($_POST['wplc_require_user_info']); } else { $wplc_data['wplc_require_user_info'] = "0"; }
4274
- if (isset($_POST['wplc_user_default_visitor_name']) && $_POST['wplc_user_default_visitor_name'] != '') { $wplc_data['wplc_user_default_visitor_name'] = esc_attr($_POST['wplc_user_default_visitor_name']); } else { $wplc_data['wplc_user_default_visitor_name'] = __("Guest", "wplivechat"); }
4275
- if (isset($_POST['wplc_loggedin_user_info'])) { $wplc_data['wplc_loggedin_user_info'] = esc_attr($_POST['wplc_loggedin_user_info']); } else { $wplc_data['wplc_loggedin_user_info'] = "0"; }
4276
- if (isset($_POST['wplc_user_alternative_text']) && $_POST['wplc_user_alternative_text'] != '') { $wplc_data['wplc_user_alternative_text'] = esc_attr($_POST['wplc_user_alternative_text']); } else { $wplc_data['wplc_user_alternative_text'] = __("Please click 'Start Chat' to initiate a chat with an agent", "wplivechat"); }
4277
- if (isset($_POST['wplc_enabled_on_mobile'])) { $wplc_data['wplc_enabled_on_mobile'] = esc_attr($_POST['wplc_enabled_on_mobile']); } else { $wplc_data['wplc_enabled_on_mobile'] = "0"; }
4278
- if (isset($_POST['wplc_display_name'])) { $wplc_data['wplc_display_name'] = esc_attr($_POST['wplc_display_name']); }
4279
- if (isset($_POST['wplc_display_to_loggedin_only'])) { $wplc_data['wplc_display_to_loggedin_only'] = esc_attr($_POST['wplc_display_to_loggedin_only']); }
4280
-
4281
- if (isset($_POST['wplc_redirect_to_thank_you_page'])) { $wplc_data['wplc_redirect_to_thank_you_page'] = esc_attr($_POST['wplc_redirect_to_thank_you_page']); }
4282
- if (isset($_POST['wplc_redirect_thank_you_url'])) { $wplc_data['wplc_redirect_thank_you_url'] = urlencode(str_replace("https:", "", str_replace("http:", "", $_POST['wplc_redirect_thank_you_url']) ) ); }
4283
-
4284
- if (isset($_POST['wplc_is_gif_integration_enabled'] )){ $wplc_data['wplc_is_gif_integration_enabled'] = esc_attr($_POST['wplc_is_gif_integration_enabled']); }
4285
- if (isset($_POST['wplc_preferred_gif_provider'])) { $wplc_data['wplc_preferred_gif_provider'] = esc_attr($_POST['wplc_preferred_gif_provider']); }
4286
- if (isset($_POST['wplc_giphy_api_key'])) { $wplc_data['wplc_giphy_api_key'] = esc_attr($_POST['wplc_giphy_api_key']); }
4287
- if (isset($_POST['wplc_tenor_api_key'])) { $wplc_data['wplc_tenor_api_key'] = esc_attr($_POST['wplc_tenor_api_key']); }
4288
-
4289
- $wplc_data['wplc_disable_emojis'] = !empty($_POST['wplc_disable_emojis']);
4290
-
4291
- /** DEPRECATED BY GDPR */
4292
- /*if(isset($_POST['wplc_record_ip_address'])){ $wplc_data['wplc_record_ip_address'] = esc_attr($_POST['wplc_record_ip_address']); } else { $wplc_data['wplc_record_ip_address'] = "0"; }*/
4293
-
4294
- $wplc_data['wplc_record_ip_address'] = "0";
4295
-
4296
- if(isset($_POST['wplc_enable_msg_sound'])){ $wplc_data['wplc_enable_msg_sound'] = esc_attr($_POST['wplc_enable_msg_sound']); } else { $wplc_data['wplc_enable_msg_sound'] = "0"; }
4297
-
4298
- if(isset($_POST['wplc_enable_visitor_sound'])){ $wplc_data['wplc_enable_visitor_sound'] = esc_attr($_POST['wplc_enable_visitor_sound']); } else { $wplc_data['wplc_enable_visitor_sound'] = "0"; }
4299
-
4300
-
4301
- if(isset($_POST['wplc_enable_font_awesome'])){ $wplc_data['wplc_enable_font_awesome'] = esc_attr($_POST['wplc_enable_font_awesome']); } else { $wplc_data['wplc_enable_font_awesome'] = "0"; }
4302
- if(isset($_POST['wplc_enable_all_admin_pages'])){ $wplc_data['wplc_enable_all_admin_pages'] = esc_attr($_POST['wplc_enable_all_admin_pages']); } else { $wplc_data['wplc_enable_all_admin_pages'] = "0"; }
4303
-
4304
- if (isset($_POST['wplc_pro_na'])) { $wplc_data['wplc_pro_na'] = esc_attr($_POST['wplc_pro_na']); }
4305
- if (isset($_POST['wplc_hide_when_offline'])) { $wplc_data['wplc_hide_when_offline'] = esc_attr($_POST['wplc_hide_when_offline']); }
4306
- if (isset($_POST['wplc_pro_chat_email_address'])) { $wplc_data['wplc_pro_chat_email_address'] = esc_attr($_POST['wplc_pro_chat_email_address']); }
4307
-
4308
- if (isset($_POST['wplc_pro_chat_email_offline_subject'])) { $wplc_data['wplc_pro_chat_email_offline_subject'] = esc_attr($_POST['wplc_pro_chat_email_offline_subject']); }
4309
-
4310
- if (isset($_POST['wplc_pro_offline1'])) { $wplc_data['wplc_pro_offline1'] = esc_attr($_POST['wplc_pro_offline1']); }
4311
- if (isset($_POST['wplc_pro_offline2'])) { $wplc_data['wplc_pro_offline2'] = esc_attr($_POST['wplc_pro_offline2']); }
4312
- if (isset($_POST['wplc_pro_offline3'])) { $wplc_data['wplc_pro_offline3'] = esc_attr($_POST['wplc_pro_offline3']); }
4313
- if (isset($_POST['wplc_pro_offline_btn'])) { $wplc_data['wplc_pro_offline_btn'] = esc_attr($_POST['wplc_pro_offline_btn']); }
4314
- if (isset($_POST['wplc_pro_offline_btn_send'])) { $wplc_data['wplc_pro_offline_btn_send'] = esc_attr($_POST['wplc_pro_offline_btn_send']); }
4315
- if (isset($_POST['wplc_using_localization_plugin'])){ $wplc_data['wplc_using_localization_plugin'] = esc_attr($_POST['wplc_using_localization_plugin']); }
4316
-
4317
-
4318
- if (isset($_POST['wplc_pro_fst1'])) { $wplc_data['wplc_pro_fst1'] = esc_attr($_POST['wplc_pro_fst1']); }
4319
- if (isset($_POST['wplc_pro_fst2'])) { $wplc_data['wplc_pro_fst2'] = esc_attr($_POST['wplc_pro_fst2']); }
4320
- if (isset($_POST['wplc_pro_fst3'])) { $wplc_data['wplc_pro_fst3'] = esc_attr($_POST['wplc_pro_fst3']); }
4321
- if (isset($_POST['wplc_pro_sst1'])) { $wplc_data['wplc_pro_sst1'] = esc_attr($_POST['wplc_pro_sst1']); }
4322
- if (isset($_POST['wplc_pro_sst1_survey'])) { $wplc_data['wplc_pro_sst1_survey'] = esc_attr($_POST['wplc_pro_sst1_survey']); }
4323
- if (isset($_POST['wplc_pro_sst1e_survey'])) { $wplc_data['wplc_pro_sst1e_survey'] = esc_attr($_POST['wplc_pro_sst1e_survey']); }
4324
- if (isset($_POST['wplc_pro_sst2'])) { $wplc_data['wplc_pro_sst2'] = esc_attr($_POST['wplc_pro_sst2']); }
4325
- if (isset($_POST['wplc_pro_tst1'])) { $wplc_data['wplc_pro_tst1'] = esc_attr($_POST['wplc_pro_tst1']); }
4326
- if (isset($_POST['wplc_pro_intro'])) { $wplc_data['wplc_pro_intro'] = esc_attr($_POST['wplc_pro_intro']); }
4327
- if (isset($_POST['wplc_user_enter'])) { $wplc_data['wplc_user_enter'] = esc_attr($_POST['wplc_user_enter']); }
4328
- if (isset($_POST['wplc_text_chat_ended'])) { $wplc_data['wplc_text_chat_ended'] = esc_attr($_POST['wplc_text_chat_ended']); }
4329
- if (isset($_POST['wplc_close_btn_text'])) { $wplc_data['wplc_close_btn_text'] = esc_attr($_POST['wplc_close_btn_text']); }
4330
- if (isset($_POST['wplc_user_welcome_chat'])) { $wplc_data['wplc_user_welcome_chat'] = esc_attr($_POST['wplc_user_welcome_chat']); }
4331
- if (isset($_POST['wplc_welcome_msg'])) { $wplc_data['wplc_welcome_msg'] = esc_attr($_POST['wplc_welcome_msg']); }
4332
-
4333
-
4334
- if(isset($_POST['wplc_animation'])){ $wplc_data['wplc_animation'] = esc_attr($_POST['wplc_animation']); }
4335
- if(isset($_POST['wplc_theme'])){ $wplc_data['wplc_theme'] = esc_attr($_POST['wplc_theme']); }
4336
- if(isset($_POST['wplc_newtheme'])){ $wplc_data['wplc_newtheme'] = esc_attr($_POST['wplc_newtheme']); }
4337
-
4338
- if(isset($_POST['wplc_elem_trigger_action'])){ $wplc_data['wplc_elem_trigger_action'] = esc_attr($_POST['wplc_elem_trigger_action']); } else{ $wplc_data['wplc_elem_trigger_action'] = "0"; }
4339
- if(isset($_POST['wplc_elem_trigger_type'])){ $wplc_data['wplc_elem_trigger_type'] = esc_attr($_POST['wplc_elem_trigger_type']); } else { $wplc_data['wplc_elem_trigger_type'] = "0";}
4340
- if(isset($_POST['wplc_elem_trigger_id'])){ $wplc_data['wplc_elem_trigger_id'] = esc_attr($_POST['wplc_elem_trigger_id']); } else { $wplc_data['wplc_elem_trigger_id'] = ""; }
4341
-
4342
- if(isset($_POST['wplc_agent_select']) && $_POST['wplc_agent_select'] != "") {
4343
- $user_array = get_users(array(
4344
- 'meta_key' => 'wplc_ma_agent',
4345
- ));
4346
- if ($user_array) {
4347
- foreach ($user_array as $user) {
4348
- $uid = $user->ID;
4349
- $wplc_ma_user = new WP_User( $uid );
4350
- $wplc_ma_user->remove_cap( 'wplc_ma_agent' );
4351
- delete_user_meta($uid, "wplc_ma_agent");
4352
- delete_user_meta($uid, "wplc_chat_agent_online");
4353
- }
4354
- }
4355
-
4356
-
4357
- $uid = intval($_POST['wplc_agent_select']);
4358
- $wplc_ma_user = new WP_User( $uid );
4359
- $wplc_ma_user->add_cap( 'wplc_ma_agent' );
4360
- update_user_meta($uid, "wplc_ma_agent", 1);
4361
- update_user_meta($uid, "wplc_chat_agent_online", time());
4362
-
4363
- }
4364
-
4365
-
4366
- if(isset($_POST['wplc_ban_users_ip'])){
4367
- $wplc_banned_ip_addresses = explode('<br />', nl2br(sanitize_text_field($_POST['wplc_ban_users_ip'])));
4368
- foreach($wplc_banned_ip_addresses as $key => $value) {
4369
- $data[$key] = trim($value);
4370
- }
4371
- $wplc_banned_ip_addresses = maybe_serialize($data);
4372
-
4373
- update_option('WPLC_BANNED_IP_ADDRESSES', $wplc_banned_ip_addresses);
4374
- }
4375
-
4376
- if( isset( $_POST['wplc_show_date'] ) ){ $wplc_data['wplc_show_date'] = '1'; } else { $wplc_data['wplc_show_date'] = '0'; }
4377
- if( isset( $_POST['wplc_show_time'] ) ){ $wplc_data['wplc_show_time'] = '1'; } else { $wplc_data['wplc_show_time'] = '0'; }
4378
-
4379
- if( isset( $_POST['wplc_show_name'] ) ){ $wplc_data['wplc_show_name'] = '1'; } else { $wplc_data['wplc_show_name'] = '0'; }
4380
- if( isset( $_POST['wplc_show_avatar'] ) ){ $wplc_data['wplc_show_avatar'] = '1'; } else { $wplc_data['wplc_show_avatar'] = '0'; }
4381
- $wplc_data = apply_filters("wplc_settings_save_filter_hook", $wplc_data);
4382
-
4383
- if (isset($_POST['wplc_user_no_answer'])) { $wplc_data["wplc_user_no_answer"] = esc_attr($_POST['wplc_user_no_answer']); } else { $wplc_data["wplc_user_no_answer"] = __("There is No Answer. Please Try Again Later.", "wplivechat"); }
4384
-
4385
- update_option('WPLC_SETTINGS', $wplc_data);
4386
- if (isset($_POST['wplc_hide_chat'])) {
4387
- update_option("WPLC_HIDE_CHAT", true);
4388
- } else {
4389
- update_option("WPLC_HIDE_CHAT", false);
4390
- }
4391
-
4392
-
4393
- $wplc_advanced_settings = array();
4394
- if (isset($_POST['wplc_iterations'])) { $wplc_advanced_settings['wplc_iterations'] = esc_attr($_POST['wplc_iterations']); }
4395
- if (isset($_POST['wplc_delay_between_loops'])) { $wplc_advanced_settings['wplc_delay_between_loops'] = esc_attr($_POST['wplc_delay_between_loops']); }
4396
- update_option("wplc_advanced_settings",$wplc_advanced_settings);
4397
-
4398
-
4399
- update_option('wplc_mail_type', $_POST['wplc_mail_type']);
4400
- update_option('wplc_mail_host', $_POST['wplc_mail_host']);
4401
- update_option('wplc_mail_port', $_POST['wplc_mail_port']);
4402
- update_option('wplc_mail_username', $_POST['wplc_mail_username']);
4403
- update_option('wplc_mail_password', $_POST['wplc_mail_password']);
4404
-
4405
-
4406
- add_action( 'admin_notices', 'wplc_save_settings_action' );
4407
- }
4408
- if (isset($_POST['action']) && $_POST['action'] == "wplc_submit_find_us") {
4409
- if (function_exists('curl_version')) {
4410
- $request_url = "http://www.wp-livechat.com/apif/rec.php";
4411
- $ch = curl_init();
4412
- curl_setopt($ch, CURLOPT_URL, $request_url);
4413
- curl_setopt($ch, CURLOPT_POST, 1);
4414
- curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
4415
- curl_setopt($ch, CURLOPT_REFERER, $_SERVER['HTTP_HOST']);
4416
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
4417
- $output = curl_exec($ch);
4418
- curl_close($ch);
4419
- }
4420
- echo "<div class=\"updated\"><p>" . __("Thank You for your feedback!", "wplivechat") . "</p></div>";
4421
- @wp_redirect( admin_url("/admin.php?page=wplivechat-menu&override=1") );
4422
- }
4423
- if( isset( $_GET['override'] ) && $_GET['override'] == '1' ){
4424
- update_option( "WPLC_V8_FIRST_TIME", false);
4425
- }
4426
- }
4427
-
4428
- function wplc_save_settings_action() { ?>
4429
- <div class='notice notice-success updated wplc_settings_save_notice'>
4430
- <?php _e("Your settings have been saved.", "wplivechat"); ?>
4431
- </div>
4432
- <?php }
4433
-
4434
- add_action('wp_logout', 'wplc_logout');
4435
- /**
4436
- * Deletes the chat transient when a user logs out
4437
- * @return bool
4438
- */
4439
- function wplc_logout() {
4440
- delete_transient('wplc_is_admin_logged_in');
4441
- }
4442
-
4443
- /**
4444
- * Returns the home page of the user's side
4445
- * @return string
4446
- */
4447
- function wplc_get_home_path() {
4448
- $home = get_option('home');
4449
- $siteurl = site_url();
4450
- if (!empty($home) && 0 !== strcasecmp($home, $siteurl)) {
4451
- $wp_path_rel_to_home = str_ireplace($home, '', $siteurl); /* $siteurl - $home */
4452
- $pos = strripos(str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']), trailingslashit($wp_path_rel_to_home));
4453
- $home_path = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos);
4454
- $home_path = trailingslashit($home_path);
4455
- } else {
4456
- $home_path = ABSPATH;
4457
- }
4458
- return str_replace('\\', '/', $home_path);
4459
- }
4460
-
4461
- /**
4462
- * Error checks used to ensure the user's resources meet the plugin's requirements
4463
- */
4464
- if(isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu-settings'){
4465
- if(is_admin()){
4466
-
4467
- // Only show these warning messages to Legacy users as they will be affected, not Node users.
4468
- $wplc_settings = get_option("WPLC_SETTINGS");
4469
- if (isset( $wplc_settings['wplc_use_node_server'] ) && intval( $wplc_settings['wplc_use_node_server'] ) == 1 ) { } else {
4470
-
4471
- $wplc_error_count = 0;
4472
- $wplc_admin_warnings = "<div class='error'>";
4473
- if(!function_exists('set_time_limit')){
4474
- $wplc_admin_warnings .= "
4475
- <p>".__("WPLC: set_time_limit() is not enabled on this server. You may experience issues while using WP Live Chat Support as a result of this. Please get in contact your host to get this function enabled.", "wplivechat")."</p>
4476
- ";
4477
- $wplc_error_count++;
4478
- }
4479
- if(ini_get('safe_mode')){
4480
- $wplc_admin_warnings .= "
4481
- <p>".__("WPLC: Safe mode is enabled on this server. You may experience issues while using WP Live Chat Support as a result of this. Please contact your host to get safe mode disabled.", "wplivechat")."</p>
4482
- ";
4483
- $wplc_error_count++;
4484
- }
4485
- $wplc_admin_warnings .= "</div>";
4486
- if($wplc_error_count > 0){
4487
- echo $wplc_admin_warnings;
4488
- }
4489
- }
4490
- }
4491
- }
4492
-
4493
- /**
4494
- * Loads the contents of the extensions menu item
4495
- * @return string
4496
- */
4497
- function wplc_extensions_menu() {
4498
-
4499
- if (isset($_GET['type']) && $_GET['type'] == "additional") {
4500
- $additional = "nav-tab-active";
4501
- $normal = "";
4502
- } else {
4503
- $normal = "nav-tab-active";
4504
- $additional = "";
4505
- }
4506
-
4507
- ?>
4508
- <h2 class="nav-tab-wrapper">
4509
- <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>
4510
- <span style='float: right; bottom:-5px; position: relative;'><img src='<?php echo plugins_url('/images/codecabin.png', __FILE__); ?>' style="height:15px;" /></span>
4511
- </h2>
4512
- <div id="tab_container">
4513
-
4514
-
4515
- <?php
4516
- if (isset($_GET['type']) && $_GET['type'] == "additional") {
4517
- ?>
4518
-
4519
- <div class="wplc-extension wplc-plugin">
4520
- <h3 class="wplc-extension-title"><?php _e("Sola Support Tickets","wplivechat"); ?></h3>
4521
- <a href="https://wordpress.org/plugins/sola-support-tickets/" title="<?php _e("Sola Support Tickets","wplivechat"); ?>" target="_BLANK">
4522
- <img width="320" src="<?php echo plugins_url('/images/plugin2.jpg', __FILE__); ?>" class="attachment-showcase wp-post-image" alt="<?php _e("Sola Support Tickets","wplivechat"); ?>" title="<?php _e("Sola Support Tickets","wplivechat"); ?>">
4523
- </a>
4524
- <p></p>
4525
- <p><?php _e("The easiest to use Help Desk & Support Ticket plugin. Create a support help desk quickly and easily with Sola Support Tickets.","wplivechat"); ?></p>
4526
- <p></p>
4527
- <a href="https://wordpress.org/plugins/sola-support-tickets/" title="<?php _e("Sola Support Tickets","wplivechat"); ?>" class="button-secondary" target="_BLANK"><?php _e("Get this Plugin","wplivechat"); ?></a>
4528
- </div>
4529
-
4530
- <div class="wplc-extension wplc-plugin">
4531
- <h3 class="wplc-extension-title"><?php _e("Nifty Newsletters","wplivechat"); ?></h3>
4532
- <a href="https://wordpress.org/plugins/sola-newsletters/" title="<?php _e("Nifty Newsletters","wplivechat"); ?>" target="_BLANK">
4533
- <img width="320" src="<?php echo plugins_url('/images/plugin1.jpg', __FILE__); ?>" class="attachment-showcase wp-post-image" alt="<?php _e("Nifty Newsletters","wplivechat"); ?>" title="<?php _e("Nifty Newsletters","wplivechat"); ?>">
4534
- </a>
4535
- <p></p>
4536
- <p><?php _e("Create and send newsletters, automatic post notifications and autoresponders that are modern and beautiful with Nifty Newsletters.","wplivechat"); ?></p>
4537
- <p></p>
4538
- <a href="https://wordpress.org/plugins/sola-newsletters/" title="<?php _e("Nifty Newsletters","wplivechat"); ?>" class="button-secondary" target="_BLANK"><?php _e("Get this Plugin","wplivechat"); ?></a>
4539
- </div>
4540
-
4541
-
4542
- <?php } else {
4543
- $filter1 = "all";
4544
- $filter2 = "all";
4545
-
4546
- if (isset($_GET['filter1'])) { $filter1 = $_GET['filter1']; }
4547
- if (isset($_GET['filter2'])) { $filter2 = $_GET['filter2']; }
4548
-
4549
- $style_strong = 'style="font-weight:bold;"';
4550
- $style_normal = 'style="font-weight:normal;"';
4551
-
4552
- $filter1_all_style = $style_normal;
4553
- $filter1_free_style = $style_normal;
4554
- $filter1_paid_style = $style_normal;
4555
- $filter2_both_style = $style_normal;
4556
- $filter2_free_style = $style_normal;
4557
- $filter2_pro_style = $style_normal;
4558
-
4559
- if ($filter1 == "all") { $filter1_all_style = $style_strong; }
4560
- else if ($filter1 == "free") { $filter1_free_style = $style_strong; }
4561
- else if ($filter1 == "paid") { $filter1_paid_style = $style_strong; }
4562
- else { $filter1_all_style = $style_strong; }
4563
- if ($filter2 == "all") { $filter2_both_style = $style_strong; }
4564
- else if ($filter2 == "free") { $filter2_free_style = $style_strong; }
4565
- else if ($filter2 == "pro") { $filter2_pro_style = $style_strong; }
4566
- else { $filter2_both_style = $style_strong; }
4567
-
4568
-
4569
- echo "<p><div style='display:block; overflow:auto; clear:both;'>";
4570
- echo "<strong>".__("Price:","wplivechat")."</strong> ";
4571
- echo "<a href='admin.php?page=wplivechat-menu-extensions-page&filter1=all&filter2=".$filter2."' $filter1_all_style>".__("All","wplivechat")."</a> |";
4572
- echo "<a href='admin.php?page=wplivechat-menu-extensions-page&filter1=free&filter2=".$filter2."' $filter1_free_style>".__("Free","wplivechat")."</a> |";
4573
- echo "<a href='admin.php?page=wplivechat-menu-extensions-page&filter1=paid&filter2=".$filter2."' $filter1_paid_style>".__("Paid","wplivechat")."</a>";
4574
- echo "</div></p>";
4575
- echo "<p><div style='display:block; overflow:auto; clear:both;'>";
4576
- echo "<strong>".__("For:","wplivechat")."</strong> ";
4577
- echo "<a href='admin.php?page=wplivechat-menu-extensions-page&filter2=all&filter1=".$filter1."' $filter2_both_style>".__("Both","wplivechat")."</a> |";
4578
- echo "<a href='admin.php?page=wplivechat-menu-extensions-page&filter2=free&filter1=".$filter1."' $filter2_free_style>".__("Free version","wplivechat")."</a> |";
4579
- echo "<a href='admin.php?page=wplivechat-menu-extensions-page&filter2=pro&filter1=".$filter1."' $filter2_pro_style>".__("Pro version","wplivechat")."</a>";
4580
- echo "</div></p>";
4581
-
4582
-
4583
- $response = wp_remote_post( "https://ccplugins.co/api-wplc-extensions", array(
4584
- 'method' => 'POST',
4585
- 'body' => array(
4586
- 'action' => 'extensions',
4587
- 'filter1' => $filter1,
4588
- 'filter2' => $filter2
4589
- )
4590
- )
4591
- );
4592
- if(is_array($response) && isset($response['body'])){
4593
- $data = json_decode($response['body']);
4594
- global $wplc_version;
4595
- $wplc_version = str_replace(",","",$wplc_version);
4596
- if ($data) {
4597
- $output = "";
4598
- foreach ($data as $extension) {
4599
- if (!isset($extension->fromversion)) { $extension->fromversion = 0; }
4600
- if (intval($wplc_version) >= intval($extension->fromversion)) {
4601
- $output .= '<div class="wplc-extension">';
4602
- $output .= '<h3 class="wplc-extension-title">'.$extension->title.'</h3>';
4603
- $output .= '<a href="'.$extension->link.'" title="'.$extension->title.'" target="_BLANK">';
4604
- $output .= '<img width="320" height="200" src="'.$extension->image.'" class="attachment-showcase wp-post-image" alt="'.$extension->title.'" title="'.$extension->title.'">';
4605
- $output .= '</a>';
4606
- $output .= '<p></p>';
4607
- $output .= '<p><div class="wplc-extension-label-box">';
4608
- $output .= '</div></p>';
4609
- $output .= '<p>'.$extension->description.'</p>';
4610
- if ($extension->slug != false && is_plugin_active($extension->slug."/".$extension->slug.".php")) {
4611
- $button = '<a href="javascriot:void(0);" title="" disabled class="button-secondary">'.__("Already installed","wplivechat").'</a>';
4612
- } else {
4613
- $button = '<a href="'.$extension->link.'" title="'.$extension->title.'" class="button-secondary" target="_BLANK">'.$extension->button_text.'</a>';
4614
- }
4615
- $output .= $button;
4616
- $output .= '</div>';
4617
- }
4618
- }
4619
- echo $output;
4620
- }
4621
-
4622
- }
4623
- ?>
4624
-
4625
-
4626
-
4627
- <?php } ?>
4628
-
4629
- </div>
4630
- <?php
4631
- }
4632
-
4633
- /**
4634
- * Loads the contents of the support menu item
4635
- * @return string
4636
- */
4637
- function wplc_support_menu() {
4638
- wplc_stats("support");
4639
- ?>
4640
- <h1><?php _e("WP Live Chat Support","wplivechat"); ?></h1>
4641
- <div class="wplc_row">
4642
- <div class='wplc_row_col' style='background-color:#FFF;'>
4643
- <h2><i class="fa fa-book fa-2x"></i> <?php _e("Documentation","wplivechat"); ?></h2>
4644
- <hr />
4645
- <p><?php _e("Getting started? Read through some of these articles to help you along your way.","wplivechat"); ?></p>
4646
- <p><strong><?php _e("Documentation:","wplivechat"); ?></strong></p>
4647
- <ul>
4648
- <li><a href='https://wp-livechat.com/documentation/minimum-system-requirements/' target='_BLANK' title='<?php _e("Minimum System Requirements","wplivechat"); ?>'><?php _e("Minimum System Requirements","wplivechat"); ?></a></li>
4649
- <li><a href='https://wp-livechat.com/documentation/do-i-have-to-be-logged-into-the-dashboard-to-chat-with-visitors/' target='_BLANK' title='<?php _e("Do I have to be logged into the dashboard to chat with visitors?","wplivechat"); ?>'><?php _e("Do I have to be logged into the dashboard to chat with visitors?","wplivechat"); ?></a></li>
4650
- <li><a href='https://wp-livechat.com/documentation/what-are-quick-responses/' target='_BLANK' title='<?php _e("What are Quick Responses?","wplivechat"); ?>'><?php _e("What are Quick Responses?","wplivechat"); ?></a></li>
4651
- <li><a href='https://wp-livechat.com/documentation/troubleshooting/is-this-plugin-multi-site-friendly/' target='_BLANK' title='<?php _e("Can I use this plugin on my multi-site?","wplivechat"); ?>'><?php _e("Can I use this plugin on my multi-site?","wplivechat"); ?></a></li>
4652
- <li><a href='https://wp-livechat.com/documentation/how-do-i-disable-apc-object-cache/' target='_BLANK' title='<?php _e("How do I disable APC Object Cache?","wplivechat"); ?>'><?php _e("How do I disable APC Object Cache?","wplivechat"); ?></a></li>
4653
- <li><a href='https://wp-livechat.com/documentation/do-you-have-a-mobile-app/' target='_BLANK' title='<?php _e("Do you have a mobile app?","wplivechat"); ?>'><?php _e("Do you have a mobile app?","wplivechat"); ?></a></li>
4654
- <li><a href='https://wp-livechat.com/documentation/how-do-i-check-for-javascript-errors-on-my-site/' target='_BLANK' title='<?php _e("How do I check for JavaScript errors on my site?","wplivechat"); ?>'><?php _e("How do I check for JavaScript errors on my site?","wplivechat"); ?></a></li>
4655
- </ul>
4656
- </div>
4657
- <div class='wplc_row_col' style='background-color:#FFF;'>
4658
- <h2><i class="fa fa-exclamation-circle fa-2x"></i> <?php _e("Troubleshooting","wplivechat"); ?></h2>
4659
- <hr />
4660
- <p><?php _e("WP Live Chat Support has a diverse and wide range of features which may, from time to time, run into conflicts with the thousands of themes and other plugins on the market.", "wplivechat"); ?></p>
4661
- <p><strong><?php _e("Common issues:","wplivechat"); ?></strong></p>
4662
- <ul>
4663
- <li><a href='https://wp-livechat.com/documentation/troubleshooting/the-chat-box-doesnt-show-up/' target='_BLANK' title='<?php _e("The chat box doesnt show up","wplivechat"); ?>'><?php _e("The chat box doesnt show up","wplivechat"); ?></a></li>
4664
- <li><a href='https://wp-livechat.com/documentation/the-chat-window-disappears-when-i-logout-or-go-offline/' target='_BLANK' title='<?php _e("The chat window disappears when I logout or go offline","wplivechat"); ?>'><?php _e("The chat window disappears when I logout or go offline","wplivechat"); ?></a></li>
4665
- <li><a href='https://wp-livechat.com/this-chat-has-already-been-answered-please-close-the-chat-window/' target='_BLANK' title='<?php _e("This chat has already been answered. Please close the chat window","wplivechat"); ?>'><?php _e("This chat has already been answered. Please close the chat window","wplivechat"); ?></a></li>
4666
- <li><a href='https://wp-livechat.com/messages-only-show-when-i-refresh-the-chat-window/' target='_BLANK' title='<?php _e("Messages only show when I refresh the chat window","wplivechat"); ?>'><?php _e("Messages only show when I refresh the chat window","wplivechat"); ?></a></li>
4667
- <li><a href='https://wp-livechat.com/documentation/im-not-getting-any-notifications-of-a-new-chat/' target='_BLANK' title='<?php _e("I'm not getting any notifications of a new chat","wplivechat"); ?>'><?php _e("I'm not getting any notifications of a new chat","wplivechat"); ?></a></li>
4668
- <li><a href='https://wp-livechat.com/the-chat-window-never-goes-offline/' target='_BLANK' title='<?php _e("The chat window never goes offline","wplivechat"); ?>'><?php _e("The chat window never goes offline","wplivechat"); ?></a></li>
4669
- </ul>
4670
- </div>
4671
- <div class='wplc_row_col' style='background-color:#FFF;'>
4672
- <h2><i class="fa fa-bullhorn fa-2x"></i> <?php _e("Support","wplivechat"); ?></h2>
4673
- <hr />
4674
- <p><?php _e("Still need help? Use one of these links below.","wplivechat"); ?></p>
4675
- <ul>
4676
- <li><a href='https://wp-livechat.com/support/' target='_BLANK' title='<?php _e("Support desk","wplivechat"); ?>'><?php _e("Support desk","wplivechat"); ?></a></li>
4677
- <li><a href='https://wp-livechat.com/contact-us/' target='_BLANK' title='<?php _e("Contact us","wplivechat"); ?>'><?php _e("Contact us","wplivechat"); ?></a></li>
4678
- </ul>
4679
- </div>
4680
- </div>
4681
- <?php
4682
- }
4683
- if (!function_exists("wplc_ic_initiate_chat_button")) {
4684
- add_action('admin_enqueue_scripts', 'wp_button_pointers_load_scripts');
4685
- }
4686
- /**
4687
- * Displays the pointers on teh live chat dashboard for the initiate chat functionality
4688
- * @param string $hook returns the page name we're on
4689
- * @return string contents ofthe pointers and their scripts
4690
- */
4691
- function wp_button_pointers_load_scripts($hook) {
4692
- $wplcrun = false;
4693
- global $wplc_version;
4694
-
4695
- $wplc_settings = get_option("WPLC_SETTINGS");
4696
- if ( isset( $wplc_settings['wplc_enable_all_admin_pages'] ) && $wplc_settings['wplc_enable_all_admin_pages'] === '1' ) {
4697
- /* Run admin JS on all admin pages */
4698
- $wplcrun = true;
4699
-
4700
-
4701
- } else {
4702
-
4703
- if( $hook === 'toplevel_page_wplivechat-menu') { $wplcrun = true; } // stop if we are not on the right page
4704
- }
4705
-
4706
-
4707
- if ( $wplcrun ) {
4708
-
4709
-
4710
-
4711
-
4712
- $pointer_localize_strings = array(
4713
- "initiate" => "<h3>".__("Initiate Chats","wplivechat")."</h3><p>".__("With the Pro add-on of WP Live Chat Support, you can", "wplivechat")." <a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate1_pointer' title='".__("see who's online and initiate chats", "wplivechat")."' target=\"_BLANK\">".__("initiate chats", "wplivechat")."</a> ".__("with your online visitors with the click of a button.", "wplivechat")." <br /><br /><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate2_pointer' title='".__("Buy the Pro add-on now (once off payment).", "wplivechat")."' target=\"_BLANK\"><strong>".__("Buy the Pro add-on now (once off payment).", "wplivechat")."</strong></a></p>",
4714
- "chats" => "<h3>".__("Multiple Chats","wplivechat")."</h3><p>".__("With the Pro add-on of WP Live Chat Support, you can", "wplivechat")." <a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=morechats1_pointer' title='".__("accept and handle multiple chats.", "wplivechat")."' target=\"_BLANK\">".__("accept and handle multiple chats.", "wplivechat")."</a><br /><br /><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=morechats2_pointer' title='".__("Buy the Pro add-on now (once off payment).", "wplivechat")."' target=\"_BLANK\"><strong>".__("Buy the Pro add-on now (once off payment).", "wplivechat")."</strong></a></p>",
4715
- "agent_info" => "<h3>".__("Add unlimited agents","wplivechat")."</h3><p><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=unlimited_agents1_pointer' title='".__("Add unlimited agents", "wplivechat")."' target=\"_BLANK\">".__("Add unlimited agents", "wplivechat")."</a> ".__(" with the Pro add-on of WP Live Chat Support","wplivechat")." "."<a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=unlimited_agents2_pointer' target='_BLANK'>".__("(once off payment).","wplivechat")."</a></p>",
4716
- "transfer" => "<h3>".__("Transfer Chats","wplivechat")."</h3><p><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=transfer1_pointer' title='".__("Transfer Chats", "wplivechat")."' target=\"_BLANK\">".__("Transfer Chats", "wplivechat")."</a> ".__(" with the Pro add-on of WP Live Chat Support","wplivechat")." "."<a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=transfer2_pointer' target='_BLANK'>".__("(once off payment).","wplivechat")."</a></p>",
4717
- "direct_to_page" => "<h3>".__("Direct User To Page","wplivechat")."</h3><p><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=direct_to_page_1' title='".__("Transfer Chats", "wplivechat")."' target=\"_BLANK\">".__("Direct User To Page", "wplivechat")."</a> ".__(" with the Pro add-on of WP Live Chat Support","wplivechat")." "."<a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=direct_to_page_2' target='_BLANK'>".__("(once off payment).","wplivechat")."</a></p>"
4718
- );
4719
-
4720
-
4721
- wp_enqueue_style( 'wp-pointer' );
4722
- wp_enqueue_script( 'wp-pointer' );
4723
- wp_register_script('wplc-user-admin-pointer', plugins_url('/js/wplc-admin-pointers.js', __FILE__), array('wp-pointer'), $wplc_version);
4724
- wp_enqueue_script('wplc-user-admin-pointer');
4725
- wp_localize_script('wplc-user-admin-pointer', 'pointer_localize_strings', $pointer_localize_strings);
4726
- }
4727
-
4728
- }
4729
-
4730
- add_filter( 'admin_footer_text', 'wplc_footer_mod' );
4731
- /**
4732
- * Adds the WP Live Chat Support & CODECABIN_ footer contents to the relevant pages
4733
- * @param string $footer_text current footer text available to us
4734
- * @return string footer contents with our branding in it
4735
- */
4736
- function wplc_footer_mod( $footer_text ) {
4737
- if (isset($_GET['page']) && ($_GET['page'] == 'wplivechat-menu' || $_GET['page'] == 'wplivechat-menu-extensions-page' || $_GET['page'] == 'wplivechat-menu-settings' || $_GET['page'] == 'wplivechat-menu-offline-messages' || $_GET['page'] == 'wplivechat-menu-history')) {
4738
- $footer_text_mod = sprintf( __( 'Thank you for using <a href="%1$s" target="_blank">WP Live Chat Support</a>! Please <a href="%2$s" target="_blank">rate us</a> on <a href="%2$s" target="_blank">WordPress.org</a>', 'wplivechat' ),
4739
- 'https://wp-livechat.com/?utm_source=plugin&utm_medium=link&utm_campaign=footer',
4740
- 'https://wordpress.org/support/view/plugin-reviews/wp-live-chat-support?filter=5#postform'
4741
- );
4742
-
4743
- 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>';
4744
- } else {
4745
- return $footer_text;
4746
- }
4747
-
4748
- }
4749
-
4750
- add_filter("wplc_filter_admin_long_poll_chat_loop_iteration","wplc_filter_control_wplc_admin_long_poll_chat_iteration", 1, 3);
4751
- /**
4752
- * Alters the admin's long poll chat iteration
4753
- * @param array $array current chat data available to us
4754
- * @param array $post_data current post data available to us
4755
- * @param int $i count for each chat available
4756
- * @return array additional contents added to the chat data
4757
- */
4758
- function wplc_filter_control_wplc_admin_long_poll_chat_iteration($array,$post_data,$i) {
4759
- if(isset($post_data['action_2']) && $post_data['action_2'] == "wplc_long_poll_check_user_opened_chat"){
4760
- $chat_status = wplc_return_chat_status(sanitize_text_field($post_data['cid']));
4761
- if(intval($chat_status) == 3){
4762
- $array['action'] = "wplc_user_open_chat";
4763
- }
4764
- } else {
4765
-
4766
- if ($post_data['first_run'] === "true") {
4767
- /* get the chat messages for the first run */
4768
- $array['chat_history'] = wplc_return_chat_messages($post_data['cid'], false, true, false, false, 'array', false);
4769
- $array['action'] = "wplc_chat_history";
4770
-
4771
- } else {
4772
-
4773
- $new_chat_status = wplc_return_chat_status(sanitize_text_field($post_data['cid']));
4774
- if($new_chat_status != $post_data['chat_status']){
4775
- $array['chat_status'] = $new_chat_status;
4776
- $array['action'] = "wplc_update_chat_status";
4777
- }
4778
- $new_chat_message = wplc_return_admin_chat_messages(sanitize_text_field($post_data['cid']));
4779
-
4780
- if($new_chat_message){
4781
-
4782
- $array['chat_message'] = $new_chat_message;
4783
- $array['action'] = "wplc_new_chat_message";
4784
- }
4785
- }
4786
- }
4787
-
4788
- return $array;
4789
- }
4790
-
4791
-
4792
- add_action("wplc_hook_agents_settings","wplc_hook_control_agents_settings", 10);
4793
- /**
4794
- * Loads the contents of the chat agents in the settings page
4795
- * @return string
4796
- */
4797
- function wplc_hook_control_agents_settings() {
4798
- $user_array = get_users(array(
4799
- 'meta_key' => 'wplc_ma_agent',
4800
- ));
4801
-
4802
- echo "<h3>".__('Current Users that are Chat Agents', 'wplivechat')."</h3>";
4803
- $wplc_agents = "<div class='wplc_agent_container'><ul>";
4804
-
4805
- if ($user_array) {
4806
- foreach ($user_array as $user) {
4807
-
4808
- $wplc_agents .= "<li id=\"wplc_agent_li_".$user->ID."\">";
4809
- $wplc_agents .= "<p><img src=\"//www.gravatar.com/avatar/" . md5($user->user_email) . "?s=80&d=mm\" /></p>";
4810
- $check = get_user_meta($user->ID,"wplc_chat_agent_online");
4811
- if ($check) {
4812
- $wplc_agents .= "<span class='wplc_status_box wplc_type_returning'>".__("Online","wplivechat")."</span>";
4813
- }
4814
- $default_agent_id = $user->ID;
4815
- $default_agent_user = $user->display_name;
4816
- $wplc_agents .= "<h3>" . $user->display_name . "</h3>";
4817
-
4818
- $wplc_agents .= "<small>" . $user->user_email . "</small>";
4819
-
4820
-
4821
-
4822
-
4823
- $wplc_agents .= "</li>";
4824
- }
4825
- }
4826
- echo $wplc_agents;
4827
- $temp_line = "<select name='wplc_agent_select' id='wplc_agent_select'><option value=''>".__("Select","wplivechat")."</option>";
4828
-
4829
- $blogusers = get_users( array( 'role' => 'administrator', 'fields' => array( 'display_name','id','user_email' ) ) );
4830
- if ($blogusers) {
4831
- foreach ( $blogusers as $user ) {
4832
- $is_agent = get_user_meta(esc_html( $user->id ), 'wplc_ma_agent', true);
4833
- $temp_line2 = '<option id="wplc_selected_agent_'. esc_html( $user->id ) .'" value="' . esc_html( $user->id ) . '">' . esc_html( $user->display_name ) . ' ('.__('Administrator','wplivechat').')</option>';
4834
- if(!$is_agent){ $temp_line .= $temp_line2; }
4835
- }
4836
- }
4837
-
4838
- $blogusers = get_users( array( 'role' => 'editor', 'fields' => array( 'display_name','id','user_email' ) ) );
4839
- if ($blogusers) {
4840
- foreach ( $blogusers as $user ) {
4841
- $is_agent = get_user_meta(esc_html( $user->id ), 'wplc_ma_agent', true);
4842
- $temp_line2 = '<option id="wplc_selected_agent_'. esc_html( $user->id ) .'" value="' . esc_html( $user->id ) . '">' . esc_html( $user->display_name ) . ' ('.__('Editor','wplivechat').')</option>';
4843
- if(!$is_agent){ $temp_line .= $temp_line2; }
4844
- }
4845
- }
4846
-
4847
- $blogusers = get_users( array( 'role' => 'author', 'fields' => array( 'display_name','id','user_email' ) ) );
4848
- if ($blogusers) {
4849
- foreach ( $blogusers as $user ) {
4850
- $is_agent = get_user_meta(esc_html( $user->id ), 'wplc_ma_agent', true);
4851
- $temp_line2 = '<option id="wplc_selected_agent_'. esc_html( $user->id ) .'" value="' . esc_html( $user->id ) . '">' . esc_html( $user->display_name ) . ' ('.__('Author','wplivechat').')</option>';
4852
- if(!$is_agent){ $temp_line .= $temp_line2; }
4853
- }
4854
- }
4855
-
4856
- $temp_line .= "</select> ";
4857
- ?>
4858
-
4859
-
4860
- <li style='width:150px;' id='wplc_add_new_agent_box'>
4861
- <p><i class='fa fa-plus-circle fa-4x' style='color:#ccc;' ></i></p>
4862
- <h3><?php _e("Add New Agent","wplivechat"); ?></h3>
4863
- <p><button class='button button-secondary' id='wplc_add_agent' disabled style=><?php _e("Add Agent","wplivechat"); ?></button></p>
4864
- <p style='font-size:0.8em'><?php _e("Add as many agents as you need with the ","wplivechat") ?> <a href="https://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=multipleAgents" target="_BLANK"><?php _e("Pro version.", "wplivechat") ?></a></p>
4865
- </li>
4866
- </ul>
4867
- <?php
4868
- $agent_text = sprintf( __( 'Change the default chat agent from <strong>%1$s</strong> to ', 'wplivechat' ),
4869
- $default_agent_user
4870
-
4871
- );
4872
- echo $agent_text.$temp_line;
4873
- ?>
4874
-
4875
- </div>
4876
-
4877
- <hr/>
4878
- <?php
4879
- }
4880
-
4881
- /**
4882
- * Returns chat data specific to a chat ID
4883
- * @param int $cid Chat ID
4884
- * @param string $line Line number the function is called on
4885
- * @return array Contents of the chat based on the ID provided
4886
- */
4887
- function wplc_get_chat_data($cid,$line = false) {
4888
- $result = apply_filters("wplc_filter_get_chat_data",null,$cid);
4889
- return $result;
4890
- }
4891
-
4892
- add_filter( "wplc_filter_get_chat_data", "wplc_get_local_chat_data", 10, 2 );
4893
- function wplc_get_local_chat_data($result, $cid) {
4894
- global $wpdb;
4895
- global $wplc_tblname_chats;
4896
-
4897
- $sql = "SELECT * FROM $wplc_tblname_chats WHERE `id` = '".intval($cid)."' LIMIT 1";
4898
- $results = $wpdb->get_results($sql);
4899
- if (isset($results[0])) { $result = $results[0]; } else { $result = null; }
4900
-
4901
- return $result;
4902
-
4903
- }
4904
-
4905
- /**
4906
- * Returns chat messages specific to a chat ID
4907
- * @param int $cid Chat ID
4908
- * @return array Chat messages based on the ID provided
4909
- */
4910
- function wplc_get_chat_messages($cid, $only_read_messages = false, $wplc_settings = false) {
4911
- global $wpdb;
4912
- global $wplc_tblname_msgs;
4913
-
4914
- if (!$wplc_settings) {
4915
- $wplc_settings = get_option("WPLC_SETTINGS");
4916
- }
4917
-
4918
- /**
4919
- * Identify if the user is using the node server and if they are, display all messages. Otherwise display read only messages (non-node users)
4920
- */
4921
- if (isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == '1') {
4922
-
4923
- $sql = "
4924
- SELECT * FROM (
4925
- SELECT *
4926
- FROM $wplc_tblname_msgs
4927
- WHERE `chat_sess_id` = '$cid'
4928
- ORDER BY `timestamp` DESC LIMIT 100
4929
- ) sub
4930
- ORDER BY `timestamp` ASC
4931
- ";
4932
- } else {
4933
- if ($only_read_messages) {
4934
- // only show read messages
4935
- $sql =
4936
- "
4937
- SELECT * FROM (
4938
- SELECT *
4939
- FROM $wplc_tblname_msgs
4940
- WHERE `chat_sess_id` = '$cid' AND `status` = 1
4941
- ORDER BY `timestamp` DESC LIMIT 100
4942
- ) sub
4943
- ORDER BY `timestamp` ASC
4944
- ";
4945
- } else {
4946
- $sql =
4947
- "
4948
- SELECT * FROM (
4949
- SELECT *
4950
- FROM $wplc_tblname_msgs
4951
- WHERE `chat_sess_id` = '$cid'
4952
- ORDER BY `timestamp` DESC LIMIT 100
4953
- ) sub
4954
- ORDER BY `timestamp` ASC
4955
- ";
4956
- }
4957
-
4958
- }
4959
- $results = $wpdb->get_results($sql);
4960
-
4961
- if (isset($results[0])) { } else { $results = null; }
4962
- $results = apply_filters("wplc_filter_get_chat_messages",$results,$cid);
4963
-
4964
- if ($results == "null") {
4965
- return false;
4966
- } else {
4967
- return $results;
4968
- }
4969
- }
4970
-
4971
- /**
4972
- * Validates extension API keys
4973
- * @param string $page_content Current page contents in the extensions page
4974
- * @param array $data Extension data such as name and slug
4975
- * @return string Updated extensions page contents
4976
- */
4977
- function wplc_build_api_check($page_content, $data) {
4978
- $link = "#";
4979
- $image = "https://ccplugins.co/api-wplc-extensions/images/add-on0.jpg";
4980
- if ($data['string'] == "Multiple Agents") {
4981
- $link = "";
4982
- $image = "https://ccplugins.co/api-wplc-extensions/images/Agents-Small.jpg";
4983
- }
4984
- if ($data['string'] == "Cloud Server") {
4985
- $link = "";
4986
- $image = "https://ccplugins.co/api-wplc-extensions/images/Cloud-Small.jpg";
4987
- }
4988
- if ($data['string'] == "Advanced Chat Box Control") {
4989
- $link = "https://wp-livechat.com/extensions/advanced-chat-control/";
4990
- $image = "https://ccplugins.co/api-wplc-extensions/images/AdvancedChatBox-Small.jpg";
4991
- }
4992
- if ($data['string'] == "Choose When Online") {
4993
- $link = "";
4994
- $image = "https://ccplugins.co/api-wplc-extensions/images/ChooseOnline-Small.jpg";
4995
- }
4996
- if ($data['string'] == "Encryption") {
4997
- $link = "";
4998
- $image = "https://ccplugins.co/api-wplc-extensions/images/Encryption-Small.jpg";
4999
- }
5000
- if ($data['string'] == "Mobile and Desktop App") {
5001
- $link = "";
5002
- $image = "https://ccplugins.co/api-wplc-extensions/images/MobileDesktop-Small.jpg";
5003
- }
5004
- if ($data['string'] == "Initiate Chats") {
5005
- $link = "";
5006
- $image = "https://ccplugins.co/api-wplc-extensions/images/InitiateChat-Small.jpg";
5007
- }
5008
- if ($data['string'] == "Include Exclude Pages") {
5009
- $link = "";
5010
- $image = "https://ccplugins.co/api-wplc-extensions/images/IncludeAndExclude-Small.jpg";
5011
- }
5012
-
5013
-
5014
- if ($data['string'] == "WP Live Chat Support Pro") {
5015
- $link = "";
5016
- $image = "https://ccplugins.co/api-wplc-extensions/images/add-on0.jpg";
5017
- }
5018
-
5019
-
5020
- $page_content .= '<div class="wplc-extension" style="height:480px;">';
5021
- $page_content .= '<a href="'.$link.'" title="'.$data['string'].'" target="_BLANK" style=" text-decoration:none;"><h3 class="wplc-extension-title" style="text-decoration:none;">'.$data['string'].'</h3></a>';
5022
- $page_content .= '<img width="320" height="200" src="'.$image.'" alt="'.$data['string'].'" title="'.$data['string'].'">';
5023
- $page_content .= '<p>'.__('API Key','wplivechat').'<br />';
5024
- $page_content .= " <form name='".$data['form_name']."' action='' method='POST'>";
5025
- $page_content .= " <input type='text' name='".$data['option_name']."' id='".$data['option_name']."' value='".get_option($data['option_name'])."' style='width: 250px;'/>";
5026
- $page_content .= " <input type='submit' name='".$data['button']."' id='".$data['button']."' value='".__("Verify","wplivechat")."' />";
5027
- $page_content .= " </form>";
5028
- $page_content .= '</p>';
5029
- $page_content .= '<p>'.__('Status: ','wplivechat');
5030
- if (isset($data['data']['status']) && $data['data']['status'] == "OK") {
5031
- update_option($data['is_valid'], 1);
5032
- $page_content .= "<span style='color: white; font-weight: bold; background-color: green; border-radius: 5px; padding: 3px;'>". __('Valid', 'wplivechat') . '</span>';
5033
- $page_content .= '<a href="https://wp-livechat.com/my-account/" title="'.__('Manage this extension','wplivechat').'" class="button-secondary" target="_BLANK">'.__('Manage this extension','wplivechat').'</a>';
5034
- } else {
5035
- update_option($data['is_valid'], 0);
5036
- $page_content .= "<span style='color: white; font-weight: bold; background-color: red; border-radius: 5px; padding: 3px;'>" . __('Invalid', 'wplivechat') . '</span>';
5037
- $page_content .= '<a href="https://wp-livechat.com/my-account/" title="'.__('Manage this extension','wplivechat').'" class="button-secondary" target="_BLANK">'.__('Manage this extension','wplivechat').'</a>';
5038
- }
5039
- $page_content .= '</p>';
5040
- $page_content .= '<div style="dispaly:block; width:100%; height:100px; overflow:auto;">';
5041
- if (isset($data['data']['domains']) && !empty($data['data']['domains'])) {
5042
- $page_content .= '<span><strong>'.__("Linked Domains","wplivechat").'</strong></span><ol>';
5043
- foreach ($data['data']['domains'] as $domain) {
5044
- $page_content .= '<li>'.$domain.'</li>';
5045
- }
5046
- $page_content .= '</ol>';
5047
- } else {
5048
- $page_content .= ' <span>'.$data['data']['message'].'</span>';
5049
-
5050
- }
5051
- $page_content .= '</div>';
5052
-
5053
- $page_content .= '</div>';
5054
-
5055
-
5056
-
5057
-
5058
- return $page_content;
5059
- }
5060
-
5061
-
5062
-
5063
- add_filter("wplc_filter_relevant_extensions_main","wplc_filter_control_relevant_extensions_main_proe");
5064
- /**
5065
- * Loads additional extension data for the Pro version
5066
- * @param string $text Current extensions page content
5067
- * @return string Extensions page content with Pro version extension data
5068
- */
5069
- function wplc_filter_control_relevant_extensions_main_proe($text) {
5070
- if (function_exists("wplc_hook_control_intiate_check")) { return $text; }
5071
-
5072
- $rel_name = __("Pro Add-on","wplivechat");
5073
- $rel_image = "https://ccplugins.co/api-wplc-extensions/images/add-on0.jpg";
5074
- $rel_link = "http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=relevant_pro";
5075
- $text .= '<div class="wplc-extension relevant_extension">';
5076
- $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" target="_BLANK" style="float:left;">';
5077
- $text .= '<img src="'.$rel_image.'" class="attachment-showcase wp-post-image" alt="'.$rel_name.'" title="'.$rel_name.'" >';
5078
- $text .= '</a>';
5079
- $text .= '<div class="float:left; padding-left:10px;">';
5080
- $text .= '<h3 class="wplc-extension-title">'.$rel_name.'</h3>';
5081
- $text .= '<p>'.__("Get unlimited agents, initiate chats, advanced chat box control, encryption and more with the Pro add-on.","wplivechat").'</p>';
5082
- $text .= '</div>';
5083
- $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" class="button-secondary" target="_BLANK">'.__("Get this extension","wplivechat").'</a>';
5084
- $text .= '</div>';
5085
-
5086
- return $text;
5087
- }
5088
-
5089
-
5090
- add_filter("wplc_filter_relevant_extensions_main","wplc_filter_control_relevant_extensions_main_mobile");
5091
- /**
5092
- * Loads additional extension data for the Mobile & Desktop App Extension
5093
- * @param string $text Current extensions page content
5094
- * @return string Extensions page content with Mobile & Desktop App extension data
5095
- */
5096
- function wplc_filter_control_relevant_extensions_main_mobile($text) {
5097
- if (function_exists("wplc_mobile_check_if_logged_in")) { return $text; }
5098
-
5099
- $rel_name = __("Mobile & Desktop App","wplivechat");
5100
- $rel_image = "https://ccplugins.co/api-wplc-extensions/images/MobileDesktop-Icon.jpg";
5101
- $rel_link = "https://wp-livechat.com/extensions/mobile-desktop-app-extension/?utm_source=plugin&amp;utm_medium=link&amp;utm_campaign=relevant_mobile";
5102
- $text .= '<div class="wplc-extension relevant_extension">';
5103
- $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" target="_BLANK" style="float:left;">';
5104
- $text .= '<img src="'.$rel_image.'" class="attachment-showcase wp-post-image" alt="'.$rel_name.'" title="'.$rel_name.'" >';
5105
- $text .= '</a>';
5106
- $text .= '<div class="float:left; padding-left:10px;">';
5107
- $text .= '<h3 class="wplc-extension-title">'.$rel_name.'</h3>';
5108
- $text .= '<p>'.__("Answer chats directly from your mobile phone or desktop with our mobile app and desktop client","wplivechat").'</p>';
5109
- $text .= '</div>';
5110
- $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" class="button-secondary" target="_BLANK">'.__("Get this extension","wplivechat").'</a>';
5111
- $text .= '</div>';
5112
-
5113
- return $text;
5114
- }
5115
-
5116
-
5117
- add_filter("wplc_filter_relevant_extensions_chatbox","wplc_filter_control_relevant_extensions_chatbox_proe");
5118
- /**
5119
- * Loads additional extension data for the Pro version - alternative option
5120
- * @param string $text Current extensions page content
5121
- * @return string Extensions page content with Pro version extension data
5122
- */
5123
- function wplc_filter_control_relevant_extensions_chatbox_proe($text) {
5124
- if (function_exists("wplc_hook_control_intiate_check")) { return $text; }
5125
-
5126
- $rel_name = __("Pro Add-on","wplivechat");
5127
- $rel_image = "https://ccplugins.co/api-wplc-extensions/images/add-on0.jpg";
5128
- $rel_link = "http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=relevant_pro_chatbox";
5129
- $text .= '<div class="wplc-extension relevant_extension">';
5130
- $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" target="_BLANK" style="float:left;">';
5131
- $text .= '<img src="'.$rel_image.'" class="attachment-showcase wp-post-image" alt="'.$rel_name.'" title="'.$rel_name.'" >';
5132
- $text .= '</a>';
5133
- $text .= '<div class="float:left; padding-left:10px;">';
5134
- $text .= '<h3 class="wplc-extension-title">'.$rel_name.'</h3>';
5135
- $text .= '<p>'.__("Get unlimited agents, initiate chats, advanced chat box control, encryption and more with the Pro add-on.","wplivechat").'</p>';
5136
- $text .= '</div>';
5137
- $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" class="button-secondary" target="_BLANK">'.__("Get this extension","wplivechat").'</a>';
5138
- $text .= '</div>';
5139
-
5140
- return $text;
5141
- }
5142
-
5143
- /**
5144
- * Add to the chat box settings page
5145
- * @return void
5146
- * @since 1.0.00
5147
- * @author Nick Duncan <nick@codecabin.co.za>
5148
- */
5149
- add_action('wplc_hook_admin_settings_chat_box_settings_after','wplc_hook_control_settings_page_relevant_extensions_acbc',9);
5150
- function wplc_hook_control_settings_page_relevant_extensions_acbc() {
5151
- $check = apply_filters("wplc_filter_relevant_extensions_chatbox","");
5152
- if ($check != "") {
5153
- echo "<hr />";
5154
- echo "<div style='padding:1%; width:98%; display:block; overflow:auto;'>";
5155
- echo "<div class='display:block; font-weight:bold;'><strong>".__("Relevant Extensions",'wplivechat')."</strong><br /><br /></div>";
5156
- echo "";
5157
- echo $check;
5158
- echo "";
5159
- echo "";
5160
- echo "</div>";
5161
- }
5162
- }
5163
-
5164
- /**
5165
- * Add to the chat box settings page
5166
- * @return void
5167
- * @since 1.0.00
5168
- * @author Nick Duncan <nick@codecabin.co.za>
5169
- */
5170
- add_action('wplc_hook_admin_settings_main_settings_after','wplc_hook_control_settings_page_relevant_extensions_main',9);
5171
- function wplc_hook_control_settings_page_relevant_extensions_main() {
5172
- $check = apply_filters("wplc_filter_relevant_extensions_main","");
5173
- if ($check != "") {
5174
- echo "<hr />";
5175
- echo "<div style='padding:1%; width:98%; display:block; overflow:auto;'>";
5176
- echo "<div class='display:block; font-weight:bold;'><strong>".__("Relevant Extensions",'wplivechat')."</strong><br /><br /></div>";
5177
- echo "";
5178
- echo $check;
5179
- echo "";
5180
- echo "";
5181
- echo "</div>";
5182
- }
5183
- }
5184
-
5185
-
5186
-
5187
- add_filter("wplc_filter_hovercard_bottom_before","wplc_filter_control_hovercard_bottom_before_pro",5,1);
5188
- /**
5189
- * Adds a powered by link to the hovercard
5190
- * @param string $content current chat content of the hover card
5191
- * @return string chat content with the powered by link
5192
- * @deprecated 7.0.0 rebuilt unknowingly
5193
- */
5194
- function wplc_filter_control_hovercard_bottom_before_pro($content) {
5195
- $wplc_settings = get_option("WPLC_SETTINGS");
5196
- if(isset($wplc_settings["wplc_powered_by_link"]) && $wplc_settings["wplc_powered_by_link"] == 0){
5197
-
5198
- } else if(!isset($wplc_settings["wplc_powered_by_link"])) {
5199
-
5200
- } else{
5201
- $content .= "<a title='".__("Powered By WP Live Chat Support", "wplivechat")."' target='_blank' rel='nofollow' href='https://wp-livechat.com/?utm_source=poweredby&utm_medium=click&utm_campaign=".esc_html(site_url())."' class='wplc_powered_by_link'>".__("Powered By WP Live Chat Support", "wplivechat")."</a>";
5202
- }
5203
- return $content;
5204
- }
5205
-
5206
-
5207
-
5208
- add_action('admin_init', 'wplc_admin_download_new_chat_history');
5209
- /**
5210
- * Downloads the chat history and adds it to a CSV file
5211
- * @return file
5212
- */
5213
- function wplc_admin_download_new_chat_history(){
5214
- if(!is_user_logged_in() || !get_user_meta(get_current_user_id(), 'wplc_ma_agent', true) ){
5215
- return;
5216
- }
5217
-
5218
- if (isset($_GET['action']) && $_GET['action'] == "download_history") {
5219
-
5220
- global $wpdb;
5221
-
5222
- $chat_id = sanitize_text_field( $_GET['cid'] );
5223
- $fileName = 'live_chat_history_'.$chat_id.'.csv';
5224
-
5225
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
5226
- header('Content-Description: File Transfer');
5227
- header("Content-type: text/csv");
5228
- header("Content-Disposition: attachment; filename={$fileName}");
5229
- header("Expires: 0");
5230
- header("Pragma: public");
5231
-
5232
- $fh = @fopen( 'php://output', 'w' );
5233
-
5234
- global $wpdb;
5235
- global $wplc_tblname_msgs;
5236
-
5237
- $results = $wpdb->get_results(
5238
- "
5239
- SELECT *
5240
- FROM $wplc_tblname_msgs
5241
- WHERE `chat_sess_id` = '$chat_id'
5242
- ORDER BY `timestamp` ASC
5243
- LIMIT 0, 100
5244
- "
5245
- );
5246
-
5247
- $fields[] = array(
5248
- 'id' => __('Chat ID', 'wplivechat'),
5249
- 'msgfrom' => __('From', 'wplivechat'),
5250
- 'msg' => __('Message', 'wplivechat'),
5251
- 'time' => __('Timestamp', 'wplivechat'),
5252
- 'orig' => __('Origin', 'wplivechat'),
5253
- );
5254
-
5255
- foreach ($results as $result => $key) {
5256
- if($key->originates == 2){
5257
- $user = __('user', 'wplivechat');
5258
- } else {
5259
- $user = __('agent', 'wplivechat');
5260
- }
5261
-
5262
- $fields[] = array(
5263
- 'id' => $key->chat_sess_id,
5264
- 'msgfrom' => $key->msgfrom,
5265
- 'msg' => apply_filters("wplc_filter_message_control_out",$key->msg),
5266
- 'time' => $key->timestamp,
5267
- 'orig' => $user,
5268
- );
5269
- }
5270
-
5271
- foreach($fields as $field){
5272
- fputcsv($fh, $field, ",", '"');
5273
- }
5274
- // Close the file
5275
- fclose($fh);
5276
- // Make sure nothing else is sent, our file is done
5277
- exit;
5278
-
5279
- }
5280
- }
5281
- /**
5282
- * Retrieves the data to start downloadling the chat history
5283
- * @param string $type Chat history output type
5284
- * @param string $cid Chat ID
5285
- * @return void
5286
- */
5287
- function wplc_admin_download_history($type, $cid){
5288
- if(!is_user_logged_in() || !get_user_meta(get_current_user_id(), 'wplc_ma_agent', true) ){
5289
- return;
5290
- }
5291
-
5292
- global $wpdb;
5293
- global $wplc_tblname_msgs;
5294
-
5295
- $results = $wpdb->get_results(
5296
- "
5297
- SELECT *
5298
- FROM $wplc_tblname_msgs
5299
- WHERE `chat_sess_id` = '$cid'
5300
- ORDER BY `timestamp` ASC
5301
- LIMIT 0, 100
5302
- "
5303
- );
5304
-
5305
- $fields[] = array(
5306
- 'id' => __('Chat ID', 'wplivechat'),
5307
- 'msgfrom' => __('From', 'wplivechat'),
5308
- 'msg' => __('Message', 'wplivechat'),
5309
- 'time' => __('Timestamp', 'wplivechat'),
5310
- 'orig' => __('Origin', 'wplivechat'),
5311
- );
5312
-
5313
- foreach ($results as $result => $key) {
5314
- if($key->originates == 2){
5315
- $user = __('user', 'wplivechat');
5316
- } else {
5317
- $user = __('agent', 'wplivechat');
5318
- }
5319
-
5320
- $fields[] = array(
5321
- 'id' => $key->chat_sess_id,
5322
- 'msgfrom' => $key->msgfrom,
5323
- 'msg' => apply_filters("wplc_filter_message_control_out",$key->msg),
5324
- 'time' => $key->timestamp,
5325
- 'orig' => $user,
5326
- );
5327
- }
5328
-
5329
- ob_end_clean();
5330
-
5331
- wplc_convert_to_csv_new($fields, 'live_chat_history_'.$cid.'.csv', ',');
5332
-
5333
- exit();
5334
- }
5335
-
5336
- /**
5337
- * Converts contents into a CSV file
5338
- * @param string $in Contents of file
5339
- * @param string $out Output of file
5340
- * @param string $del Delimiter for content
5341
- * @return void
5342
- */
5343
- function wplc_convert_to_csv_new($in, $out, $del){
5344
-
5345
- $f = fopen('php://memory', 'w');
5346
-
5347
- foreach ($in as $line) {
5348
- wplc_fputcsv_eol_new($f, $line, $del, "\r\n");
5349
- }
5350
-
5351
- fseek($f, 0);
5352
-
5353
- header('Content-Type: application/csv');
5354
-
5355
- header('Content-Disposition: attachement; filename="' . $out . '";');
5356
-
5357
- fpassthru($f);
5358
- }
5359
- /**
5360
- * Parses content to add to a CSV file
5361
- * @param string $fp The open file
5362
- * @param string $array The content to be added to the file
5363
- * @param string $del Delimiter to use in the file
5364
- * @param string $eol Content to be written to the file
5365
- * @return void
5366
- */
5367
- function wplc_fputcsv_eol_new($fp, $array, $del, $eol) {
5368
- fputcsv($fp, $array,$del);
5369
- if("\n\r" != $eol && 0 === fseek($fp, -1, SEEK_CUR)) {
5370
- fwrite($fp, $eol);
5371
- }
5372
- }
5373
-
5374
- /**
5375
- * Adds an API key notice in the plugin's page
5376
- * @return string
5377
- */
5378
- function wplc_plugin_row_invalid_api() {
5379
- echo '<tr class="active"><td>&nbsp;</td><td colspan="2" style="color:red;">
5380
- &nbsp; &nbsp; '.__('Your API Key is Invalid. You are not eligible for future updates. Please enter your API key <a href="admin.php?page=wplivechat-menu-api-keys-page">here</a>.','wplivechat').'
5381
- </td></tr>';
5382
- }
5383
-
5384
- /**
5385
- * Hides the chat when offline
5386
- * @return int Incremented number if any agents have logged in
5387
- */
5388
- function wplc_basic_hide_chat_when_offline(){
5389
- $wplc_settings = get_option("WPLC_SETTINGS");
5390
-
5391
- $hide_chat = 0;
5392
- if (isset($wplc_settings['wplc_hide_when_offline']) && $wplc_settings['wplc_hide_when_offline'] == 1) {
5393
- /* Hide the window when its offline */
5394
- $logged_in = apply_filters("wplc_loggedin_filter",false);
5395
- if (!$logged_in) {
5396
- $hide_chat++;
5397
- }
5398
- } else {
5399
- $hide_chat = 0;
5400
- }
5401
- return $hide_chat;
5402
- }
5403
-
5404
- /**
5405
- * Checks all strings that are added to the chat window
5406
- * @return void
5407
- */
5408
- function wplc_string_check() {
5409
- $wplc_settings = get_option("WPLC_SETTINGS");
5410
-
5411
- if (!isset($wplc_settings['wplc_pro_na'])) { $wplc_settings["wplc_pro_na"] = __("Chat offline. Leave a message", "wplivechat"); }
5412
- if (!isset($wplc_settings['wplc_pro_intro'])) { $wplc_settings["wplc_pro_intro"] = __("Hello. Please input your details so that I may help you.", "wplivechat"); }
5413
- if (!isset($wplc_settings['wplc_pro_offline1'])) { $wplc_settings["wplc_pro_offline1"] = __("We are currently offline. Please leave a message and we'll get back to you shortly.", "wplivechat"); }
5414
- if (!isset($wplc_settings['wplc_pro_offline2'])) { $wplc_settings["wplc_pro_offline2"] = __("Sending message...", "wplivechat"); }
5415
- if (!isset($wplc_settings['wplc_pro_offline3'])) { $wplc_settings["wplc_pro_offline3"] = __("Thank you for your message. We will be in contact soon.", "wplivechat"); }
5416
- if (!isset($wplc_settings['wplc_pro_offline_btn']) || (isset($wplc_settings['wplc_pro_offline_btn']) && $wplc_settings['wplc_pro_offline_btn'] == "")) { $wplc_settings["wplc_pro_offline_btn"] = __("Leave a message", "wplivechat"); }
5417
- if (!isset($wplc_settings['wplc_pro_offline_btn_send']) || (isset($wplc_settings['wplc_pro_offline_btn_send']) && $wplc_settings['wplc_pro_offline_btn_send'] == "")) { $wplc_settings["wplc_pro_offline_btn_send"] = __("Send message", "wplivechat"); }
5418
- if (!isset($wplc_settings['wplc_pro_fst1'])) { $wplc_settings["wplc_pro_fst1"] = __("Questions?", "wplivechat"); }
5419
- if (!isset($wplc_settings['wplc_pro_fst2'])) { $wplc_settings["wplc_pro_fst2"] = __("Chat with us", "wplivechat"); }
5420
- if (!isset($wplc_settings['wplc_pro_fst3'])) { $wplc_settings["wplc_pro_fst3"] = __("Start live chat", "wplivechat"); }
5421
- if (!isset($wplc_settings['wplc_pro_sst1'])) { $wplc_settings["wplc_pro_sst1"] = __("Start Chat", "wplivechat"); }
5422
- if (!isset($wplc_settings['wplc_pro_sst1_survey'])) { $wplc_settings["wplc_pro_sst1_survey"] = __("Or chat to an agent now", "wplivechat"); }
5423
- if (!isset($wplc_settings['wplc_pro_sst1e_survey'])) { $wplc_settings["wplc_pro_sst1e_survey"] = __("Chat ended", "wplivechat"); }
5424
- if (!isset($wplc_settings['wplc_pro_sst2'])) { $wplc_settings["wplc_pro_sst2"] = __("Connecting. Please be patient...", "wplivechat"); }
5425
- if (!isset($wplc_settings['wplc_pro_tst1'])) { $wplc_settings["wplc_pro_tst1"] = __("Reactivating your previous chat...", "wplivechat"); }
5426
- if (!isset($wplc_settings['wplc_user_welcome_chat'])) { $wplc_settings["wplc_user_welcome_chat"] = __("Welcome. How may I help you?", "wplivechat"); }
5427
- if (!isset($wplc_settings['wplc_welcome_msg'])) { $wplc_settings['wplc_welcome_msg'] = __("Please standby for an agent. While you wait for the agent you may type your message.","wplivechat"); }
5428
- if (!isset($wplc_settings['wplc_user_enter'])) { $wplc_settings["wplc_user_enter"] = __("Press ENTER to send your message", "wplivechat"); }
5429
- if (!isset($wplc_settings['wplc_close_btn_text'])) { $wplc_settings["wplc_close_btn_text"] = __("close", "wplivechat"); }
5430
-
5431
- update_option("WPLC_SETTINGS",$wplc_settings);
5432
-
5433
- }
5434
-
5435
- add_filter("wplc_filter_chat_text_editor_upsell","nifty_text_edit_upsell",1,1);
5436
- /**
5437
- * Used to upsell the advanced text editor in the chat
5438
- * @param string $msg Current text in the chat window
5439
- * @return string Additional content added for upselling purposes
5440
- */
5441
- function nifty_text_edit_upsell($msg){
5442
- if(!function_exists("nifty_text_edit_div") && !function_exists("wplc_pro_activate")){
5443
- //Only show this if in admin area and is not PRO
5444
- $msg .= "<div id='nifty_text_editor_holder' class='wplc_faded_upsell'>";
5445
- $msg .= "<i class='nifty_tedit_icon fa fa-bold' id='nifty_tedit_b'></i>";
5446
- $msg .= "<i class='nifty_tedit_icon fa fa-italic' id='nifty_tedit_i'></i>";
5447
- $msg .= "<i class='nifty_tedit_icon fa fa-underline' id='nifty_tedit_u'></i>";
5448
- $msg .= "<i class='nifty_tedit_icon fa fa-strikethrough' id='nifty_tedit_strike'></i>";
5449
- $msg .= "<i class='nifty_tedit_icon fa fa-square' id='nifty_tedit_mark'></i>";
5450
- $msg .= "<i class='nifty_tedit_icon fa fa-subscript' id='nifty_tedit_sub'></i>";
5451
- $msg .= "<i class='nifty_tedit_icon fa fa-superscript' id='nifty_tedit_sup'></i>";
5452
- $msg .= "<i class='nifty_tedit_icon fa fa-link' id='nifty_tedit_link'></i>";
5453
- $msg .= "<i class='nifty_tedit_icon'><a target='_BLANK' href='https://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=text_editor'>Pro version only</a></i>";
5454
- $msg .= "</div>";
5455
- }
5456
- return $msg;
5457
- }
5458
-
5459
- add_filter("wplc_filter_advanced_info","nifty_rating_advanced_info_upsell",1,4);
5460
- /**
5461
- * Chat experience ratings upselling page
5462
- * @param string $msg current chat window contents
5463
- * @param int $cid chat ID
5464
- * @param string $name User's name
5465
- * @return string current chat window contents with the experience rating content appended
5466
- */
5467
- function nifty_rating_advanced_info_upsell($msg, $cid, $name, $chat_data){
5468
- if(!function_exists("nifty_rating_advanced_info_control") && is_admin() && !function_exists("wplc_pro_activate")){
5469
- $msg .= "<div class='admin_visitor_advanced_info admin_agent_rating wplc_faded_upsell'>
5470
- <strong>" . __("Experience Rating", "wplivechat") . "</strong>
5471
- <div class='rating'><a target='_BLANK' href='https://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=experience_ratings'>Pro only</a></div>
5472
- </div>";
5473
- }
5474
- return $msg;
5475
- }
5476
-
5477
- add_filter("wplc_filter_typing_control_div","wplc_basic_filter_control_return_chat_response_box_before",2,1);
5478
- function wplc_basic_filter_control_return_chat_response_box_before($string) {
5479
- remove_filter("wplc_filter_typing_control_div","wplc_pro_filter_control_return_chat_response_box_before");
5480
- $string = $string. "<div class='typing_indicator wplc-color-2 wplc-color-bg-1'></div>";
5481
-
5482
- return $string;
5483
- }
5484
- add_filter("wplc_filter_typing_control_div_theme_2","wplc_basic_filter_control_return_chat_response_box_before_theme2",2,1);
5485
- function wplc_basic_filter_control_return_chat_response_box_before_theme2($string) {
5486
- remove_filter("wplc_filter_typing_control_div_theme_2","wplc_pro_filter_control_return_chat_response_box_before_theme2");
5487
- $string = $string. "<div class='typing_indicator wplc-color-2 wplc-color-bg-1'></div>";
5488
-
5489
- return $string;
5490
- }
5491
-
5492
-
5493
- add_action("wplc_hook_admin_settings_main_settings_after","wplc_hook_control_admin_settings_chat_box_settings_after",2);
5494
- /**
5495
- * Adds the settings to allow the user to change their server environment variables
5496
- * @return sring */
5497
- function wplc_hook_control_admin_settings_chat_box_settings_after() {
5498
-
5499
- $wplc_settings = get_option("WPLC_SETTINGS");
5500
- if (isset($wplc_settings["wplc_environment"])) { $wplc_environment[intval($wplc_settings["wplc_environment"])] = "SELECTED"; }
5501
-
5502
- ?>
5503
- <h4><?php _e("Advanced settings", "wplivechat") ?></h4>
5504
- <table class='wp-list-table wplc_list_table widefat fixed striped pages' width='700'>
5505
-
5506
- <?php do_action("wplc_advanced_settings_above_performance", $wplc_settings); ?>
5507
- </table>
5508
- <p>&nbsp;</p>
5509
- <table class='wp-list-table wplc_list_table widefat fixed striped pages' width='700'>
5510
-
5511
- <tr>
5512
- <td colspan='2'>
5513
- <p><em><small><?php _e("Only change these settings if you are experiencing performance issues.","wplivechat"); ?></small></em></p>
5514
- </td>
5515
- </tr>
5516
- </tr>
5517
- <?php do_action("wplc_advanced_settings_settings"); ?>
5518
- <tr>
5519
- <td valign='top'>
5520
- <?php _e("What type of environment are you on?","wplivechat"); ?>
5521
- </td>
5522
- <td valign='top'>
5523
- <select name='wplc_environment' id='wplc_environment'>
5524
- <option value='1' <?php if (isset($wplc_environment[1])) { echo $wplc_environment[1]; } ?>><?php _e("Shared hosting - low level plan","wplivechat"); ?></option>
5525
- <option value='2' <?php if (isset($wplc_environment[2])) { echo $wplc_environment[2]; } ?>><?php _e("Shared hosting - normal plan","wplivechat"); ?></option>
5526
- <option value='3' <?php if (isset($wplc_environment[3])) { echo $wplc_environment[3]; } ?>><?php _e("VPS","wplivechat"); ?></option>
5527
- <option value='4' <?php if (isset($wplc_environment[4])) { echo $wplc_environment[4]; } ?>><?php _e("Dedicated server","wplivechat"); ?></option>
5528
- </select>
5529
- </td>
5530
- </tr>
5531
- <tr>
5532
- <td valign='top'>
5533
- <?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>
5534
- </td>
5535
- <td valign='top'>
5536
- <?php
5537
- $wplc_advanced_settings = get_option("wplc_advanced_settings");
5538
- ?>
5539
- <table>
5540
- <tr>
5541
- <td><?php _e("Iterations","wplivechat"); ?></td>
5542
- <td><input id="wplc_iterations" name="wplc_iterations" type="number" max='200' min='10' value="<?php if (isset($wplc_advanced_settings['wplc_iterations'])) { echo $wplc_advanced_settings['wplc_iterations']; } else { echo '55'; } ?>" /></td>
5543
- </tr>
5544
- <tr>
5545
- <td><?php _e("Sleep between iterations","wplivechat"); ?></td>
5546
- <td>
5547
- <input id="wplc_delay_between_loops" name="wplc_delay_between_loops" type="number" max='1000000' min='25000' value="<?php if (isset($wplc_advanced_settings['wplc_delay_between_loops'])) { echo $wplc_advanced_settings['wplc_delay_between_loops']; } else { echo '500000'; } ?>" />
5548
- <small><em><?php _e("microseconds","wplivechat"); ?></em></small>
5549
- </td>
5550
- </tr>
5551
- </table>
5552
-
5553
- </td>
5554
- </tr>
5555
-
5556
- </table>
5557
- <?php
5558
- }
5559
- /**
5560
- * Basic version's reporting page
5561
- * @return string
5562
- */
5563
- function wplc_basic_reporting_page(){
5564
-
5565
- $content = "<div class='wrap wplc_wrap'>";
5566
- $content .= "<h2>".__('WP Live Chat Support Reporting', 'wp-livechat')." (beta) </h2>";
5567
- $content .= "<table class=\"wp-list-table wplc_list_table widefat fixed form-table\" cellspacing=\"0\" style='width:98%'>";
5568
- $content .= "<tr>";
5569
- $content .= "<td style='width:35%; vertical-align:top;'>";
5570
- $content .= "<img class='reporting_img_main' style='width:99%; height:auto; padding:2px; border:1px lightgray solid;box-shadow: 3px 3px 2px -2px #999;-webkit-box-shadow: 3px 3px 2px -2px #999;-moz-box-shadow: 3px 3px 2px -2px #999;-o-box-shadow: 3px 3px 2px -2px #999;' src='".plugins_url('/images/reporting_sample.jpg', __FILE__)."'>";
5571
- $content .= "</td>";
5572
- $content .= "<td style='vertical-align:top;'>";
5573
- $content .= "<h3>".__('WP Live Chat Support Reporting', 'wp-livechat')."</h3>";
5574
- $content .= "<p>".__('View comprehensive reports regarding your chat and agent activity.', 'wp-livechat')."</p>";
5575
-
5576
-
5577
- $content .= "<br><p><strong>".__('Reports', 'wp-livechat').":</strong></p>";
5578
- $content .= "<ul style='list-style: inherit;margin-left: 22px;'>";
5579
- $content .= "<li>".__('Chat statistics', 'wp-livechat')."</li>";
5580
- $content .= "<li>".__('Popular pages', 'wp-livechat')."</li>";
5581
- $content .= "<li>".__('ROI reporting and tracking (identify which agents produce the most sales)', 'wp-livechat')."</li>";
5582
- $content .= "<li>".__('User experience ratings (identify which agents produce the happiest customers)', 'wp-livechat')."</li>";
5583
- $content .= "</ul>";
5584
-
5585
- if (function_exists("wplc_pro_activate")) {
5586
- global $wplc_pro_version;
5587
- if (intval(str_replace(".","",$wplc_pro_version)) < 6300) {
5588
- $content .= "<p>In order to use reporting, please ensure you are using the latest Pro version (version 6.3.00 or newer).</p>";
5589
- $content .= "<br><a title='Update Now' href='./update-core.php' style='width: 200px;height: 58px;text-align: center;line-height: 56px;font-size: 18px;' class='button button-primary'>".__("Update now" ,"wplivechat")."</a>";
5590
- }
5591
- } else {
5592
- $content .= "<p>".__('Get all this and more in the ', 'wp-livechat')."<a href='https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=reporting' target='_BLANK'>".__("Pro add-on", "wplivechat")."</a></p>";
5593
- $content .= "<br><a title='Upgrade Now' href='https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=reporting' style='width: 200px;height: 58px;text-align: center;line-height: 56px;font-size: 18px;' class='button button-primary' target='_BLANK'>".__("Upgrade Now" ,"wplivechat")."</a>";
5594
- }
5595
- $content .= "</td>";
5596
- $content .= "</tr>";
5597
- $content .= "</table>";
5598
- $content .= "</div>";
5599
- echo $content;
5600
-
5601
- }
5602
- /**
5603
- * Basic version's triggers page - used to upsell the feature
5604
- * @return string
5605
- */
5606
- function wplc_basic_triggers_page(){
5607
- $content = "<div class='wrap wplc_wrap'>";
5608
- $content .= "<h2>".__('WP Live Chat Support Triggers', 'wp-livechat')." (beta) </h2>";
5609
- $content .= "<script>
5610
- var isOn = true;
5611
- jQuery(function(){
5612
- jQuery(function(){
5613
- setInterval(function(){
5614
- if(isOn){
5615
- jQuery('.trigger_img_main').fadeOut('fast', function(){
5616
- jQuery('.trigger_img_sec').fadeIn('slow');
5617
- jQuery('.trigger_img_sec').fadeIn('slow');
5618
- });
5619
- } else {
5620
- jQuery('.trigger_img_sec').fadeOut('fast');
5621
- jQuery('.trigger_img_sec').fadeOut('fast', function(){
5622
- jQuery('.trigger_img_main').fadeIn('slow');
5623
- });
5624
- }
5625
- isOn = !isOn;
5626
- }, 5000);
5627
- });
5628
- });
5629
- </script>";
5630
-
5631
- $content .= "<table class=\"wp-list-table wplc_list_table widefat fixed form-table\" cellspacing=\"0\" style='width:98%'>";
5632
- $content .= "<tr>";
5633
- $content .= "<td style='width:35%; vertical-align:top;'>";
5634
- $content .= "<img class='trigger_img_main' style='width:99%; height:auto; padding:2px; border:1px lightgray solid;box-shadow: 3px 3px 2px -2px #999;-webkit-box-shadow: 3px 3px 2px -2px #999;-moz-box-shadow: 3px 3px 2px -2px #999;-o-box-shadow: 3px 3px 2px -2px #999;' src='".plugins_url('/images/trigger_sample.jpg', __FILE__)."'>";
5635
- $content .= "<img class='trigger_img_sec'style='display: none; width:49%; height:auto; border:1px lightgray solid;box-shadow: 3px 3px 2px -2px #999;-webkit-box-shadow: 3px 3px 2px -2px #999;-moz-box-shadow: 3px 3px 2px -2px #999;-o-box-shadow: 3px 3px 2px -2px #999;' src='".plugins_url('/images/trigger_sample_front.jpg', __FILE__)."'>";
5636
- $content .= "</td>";
5637
- $content .= "<td style='vertical-align:top;'>";
5638
- $content .= "<h3>".__('WP Live Chat Support Triggers', 'wp-livechat')."</h3>";
5639
- $content .= "<p>".__('Create custom data triggers when users view a certain page, spend a certain amount of time on a page, scroll past a certain point or when their mouse leaves the window.', 'wp-livechat')."</p>";
5640
-
5641
-
5642
- $content .= "<br><p><strong>".__('Trigger Types', 'wp-livechat').":</strong></p>";
5643
- $content .= "<ul style='list-style: inherit;margin-left: 22px;'>";
5644
- $content .= "<li>".__('Page Trigger', 'wp-livechat')."</li>";
5645
- $content .= "<li>".__('Time Trigger', 'wp-livechat')."</li>";
5646
- $content .= "<li>".__('Scroll Trigger', 'wp-livechat')."</li>";
5647
- $content .= "<li>".__('Page Leave Trigger', 'wp-livechat')."</li>";
5648
- $content .= "</ul>";
5649
-
5650
- if (function_exists("wplc_pro_activate")) {
5651
- global $wplc_pro_version;
5652
- if (intval(str_replace(".","",$wplc_pro_version)) < 6200) {
5653
- $content .= "<p>In order to use data triggers, please ensure you are using the latest Pro version (version 6.2.00 or newer).</p>";
5654
- $content .= "<br><a title='Update Now' href='./update-core.php' style='width: 200px;height: 58px;text-align: center;line-height: 56px;font-size: 18px;' class='button button-primary'>".__("Update now" ,"wplivechat")."</a>";
5655
- }
5656
- } else {
5657
- $content .= "<p>".__('Get all this and more in the ', 'wp-livechat')."<a href='https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=data_triggers' target='_BLANK'>".__("Pro add-on", "wplivechat")."</a></p>";
5658
- $content .= "<br><a title='Upgrade Now' href='https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=data_triggers' style='width: 200px;height: 58px;text-align: center;line-height: 56px;font-size: 18px;' class='button button-primary' target='_BLANK'>".__("Upgrade Now" ,"wplivechat")."</a>";
5659
- }
5660
- $content .= "</td>";
5661
- $content .= "</tr>";
5662
- $content .= "</table>";
5663
- $content .= "</div>";
5664
- echo $content;
5665
-
5666
- }
5667
- /**
5668
- * Basic version's custom fields page - used to upsell the feature
5669
- * @return string
5670
- */
5671
- function wplc_basic_custom_fields_page(){
5672
- $content = "<div class='wrap wplc_wrap'>";
5673
- $content .= "<h2>".__('WP Live Chat Support Custom Fields', 'wplivechat')."</h2>";
5674
- $content .= "<table class=\"wp-list-table wplc_list_table widefat fixed form-table\" cellspacing=\"0\" style='width:98%'>";
5675
- $content .= "<tr>";
5676
- $content .= "<td style='width:35%; vertical-align:top;'>";
5677
- $content .= "<img class='trigger_img_main' style='width:99%; height:auto; padding:2px; border:1px lightgray solid;box-shadow: 3px 3px 2px -2px #999;-webkit-box-shadow: 3px 3px 2px -2px #999;-moz-box-shadow: 3px 3px 2px -2px #999;-o-box-shadow: 3px 3px 2px -2px #999;' src='".plugins_url('/images/trigger_sample.jpg', __FILE__)."'>";
5678
- $content .= "</td>";
5679
- $content .= "<td style='vertical-align:top;'>";
5680
- $content .= "<h3>".__('WP Live Chat Support Custom Fields', 'wp-livechat')."</h3>";
5681
- $content .= "<p>".__('Create custom fields, allowing your visitors to enter the data you need before starting a chat.', 'wp-livechat')."</p>";
5682
- $content .= "<br><p><strong>".__('Custom Field Types', 'wp-livechat').":</strong></p>";
5683
- $content .= "<ul style='list-style: inherit;margin-left: 22px;'>";
5684
- $content .= "<li>".__('Text Fields', 'wp-livechat')."</li>";
5685
- $content .= "<li>".__('Dropdown Fields', 'wp-livechat')."</li>";
5686
- $content .= "</ul>";
5687
-
5688
- if (function_exists("wplc_pro_activate")) {
5689
- global $wplc_pro_version;
5690
- if (intval(str_replace(".","",$wplc_pro_version)) < 7000) {
5691
- $content .= "<p>In order to use custom fields, please ensure you are using the latest Pro version (version 7.0.0 or newer).</p>";
5692
- $content .= "<br><a title='Update Now' href='./update-core.php' style='width: 200px;height: 58px;text-align: center;line-height: 56px;font-size: 18px;' class='button button-primary'>".__("Update now" ,"wplivechat")."</a>";
5693
- }
5694
- } else {
5695
- $content .= "<p>".__('Get all this and more in the ', 'wp-livechat')."<a href='https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=custom_fields' target='_BLANK'>".__("Pro add-on", "wplivechat")."</a></p>";
5696
- $content .= "<br><a title='Upgrade Now' href='https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=custom_fields' style='width: 200px;height: 58px;text-align: center;line-height: 56px;font-size: 18px;' class='button button-primary' target='_BLANK'>".__("Upgrade Now" ,"wplivechat")."</a>";
5697
- }
5698
- $content .= "</td>";
5699
- $content .= "</tr>";
5700
- $content .= "</table>";
5701
- $content .= "</div>";
5702
- echo $content;
5703
- }
5704
-
5705
- add_action('wplc_hook_admin_settings_main_settings_after','wplc_powered_by_link_settings_page',2);
5706
- /**
5707
- * Adds the necessary checkbox to enable/disable the 'Powered by' link
5708
- * @return string
5709
- */
5710
- function wplc_powered_by_link_settings_page() {
5711
- $wplc_powered_by = get_option("WPLC_POWERED_BY");
5712
- ?>
5713
- <table class='form-table wp-list-table wplc_list_table widefat fixed striped pages' width='700'>
5714
- <tr>
5715
- <td width='350' valign='top'>
5716
- <?php _e("Display a 'Powered by' link in the chat box", "wplivechat") ?>: <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e("Checking this will display a 'Powered by WP Live Chat Support' caption at the bottom of your chatbox.", 'wplivechat'); ?>"></i>
5717
- </td>
5718
- <td>
5719
- <input type="checkbox" value="1" name="wplc_powered_by" <?php if ( $wplc_powered_by && $wplc_powered_by == 1 ) { echo "checked"; } ?> />
5720
- </td>
5721
- </tr>
5722
- </table>
5723
- <hr>
5724
- <?php
5725
- }
5726
-
5727
- add_action( "wplc_hook_head", "wplc_powered_by_link_save_settings" );
5728
- /**
5729
- * Saves the 'Powered by' link settings
5730
- * @return void
5731
- */
5732
- function wplc_powered_by_link_save_settings(){
5733
-
5734
- if( isset( $_POST['wplc_save_settings'] ) ){
5735
-
5736
- if( isset( $_POST['wplc_powered_by'] ) && $_POST['wplc_powered_by'] == '1' ){
5737
- update_option( "WPLC_POWERED_BY", 1 );
5738
- } else {
5739
- update_option( "WPLC_POWERED_BY", 0 );
5740
- }
5741
-
5742
- }
5743
-
5744
- }
5745
-
5746
- add_filter( "wplc_start_chat_user_form_after_filter", "wplc_powered_by_link_in_chat", 12, 2 );
5747
- /**
5748
- * Appends the 'Powered by' link to the chat window
5749
- * @param string $string the current contents of the chat box
5750
- * @param int $cid the current chat ID
5751
- * @return string the chat contents, with the 'Powered by' link appended to it
5752
- */
5753
- function wplc_powered_by_link_in_chat( $string ){
5754
-
5755
- $show_powered_by = get_option( "WPLC_POWERED_BY" );
5756
-
5757
- if( $show_powered_by == 1){
5758
- $ret = "<i style='text-align: center; display: block; padding: 5px 0; font-size: 10px;'><a href='https://wp-livechat.com/?utm_source=poweredby&utm_medium=click&utm_campaign=".esc_html(site_url())."'' target='_BLANK' rel='nofollow'>".__("Powered by WP Live Chat Support", "wplivechat")."</a></i>";
5759
-
5760
- } else {
5761
-
5762
- $ret = "";
5763
-
5764
- }
5765
-
5766
- return $string . $ret;
5767
-
5768
- }
5769
-
5770
- add_action( "admin_enqueue_scripts", "wplc_custom_scripts_scripts" );
5771
- /**
5772
- * Loads the Ace.js editor for the custom scripts
5773
- * @return void
5774
- */
5775
- function wplc_custom_scripts_scripts(){
5776
-
5777
- if ( isset( $_GET['page'] ) ) {
5778
- if ( $_GET['page'] == 'wplivechat-menu-settings' ) {
5779
- wp_enqueue_script( "wplc-custom-script-tab-ace",'//cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js', array('jquery') );
5780
- } else if ( $_GET['page'] == 'wplivechat-menu-dashboard' ) {
5781
- wp_enqueue_script( 'wplc-custom-script-dashboard', plugins_url( '/js/wplc_dashboard.js', __FILE__ ), array('jquery'), null, true );
5782
- }
5783
-
5784
- }
5785
-
5786
- }
5787
-
5788
- add_filter( "wplc_filter_setting_tabs", "wplc_custom_scripts_tab" );
5789
- /**
5790
- * Adds a tab for the custom scripts
5791
- * @param array $array current array that is made available to us
5792
- * @return array our tabs array has been added to the array
5793
- */
5794
- function wplc_custom_scripts_tab( $array ){
5795
-
5796
- $array['custom-scripts'] = array(
5797
- 'href' => '#wplc-custom-scripts',
5798
- 'icon' => 'fa fa-pencil',
5799
- 'label' => __("Custom Scripts", "wplivechat")
5800
- );
5801
-
5802
- return $array;
5803
- }
5804
-
5805
- add_action( "wplc_hook_settings_page_more_tabs", "wplc_custom_scripts_content" );
5806
- /**
5807
- * Adds the tab content to the settings page to allow the user to add custom CSS & JS
5808
- * @return string
5809
- */
5810
- function wplc_custom_scripts_content(){
5811
-
5812
- $wplc_custom_css = get_option( "WPLC_CUSTOM_CSS" );
5813
- $wplc_custom_js = get_option( "WPLC_CUSTOM_JS" );
5814
-
5815
- $content = "";
5816
-
5817
- $content .= "<div id='wplc-custom-scripts'>";
5818
-
5819
- $content .= "<h2>".__("Custom Scripts", "wplivechat")."</h2>";
5820
- $content .= "<table class='form-table'>";
5821
-
5822
- $content .= "<tr>";
5823
- $content .= "<td width='300'>".__("Custom CSS", "wplivechat")."</td>";
5824
- $content .= "<td><div id='wplc_custom_css_editor'></div><textarea name='wplc_custom_css' id='wplc_custom_css' style='display: none;' data-editor='css' rows='12'>".strip_tags( stripslashes( $wplc_custom_css ) )."</textarea></td>";
5825
- $content .= "</tr>";
5826
-
5827
- $content .= "<tr>";
5828
- $content .= "<td width='300'>".__("Custom JS", "wplivechat")."</td>";
5829
- $content .= "<td valign='middle'><div id='wplc_custom_js_editor'></div><textarea name='wplc_custom_js' id='wplc_custom_js' style='display: none;' data-editor='javascript' rows='12'>".strip_tags( stripslashes( $wplc_custom_js ) )."</textarea></td>";
5830
- $content .= "</tr>";
5831
-
5832
- $content .= "</table>";
5833
-
5834
- $content .= "</div>";
5835
-
5836
- echo $content;
5837
-
5838
- }
5839
-
5840
- add_action( "wplc_hook_head", "wplc_custom_scripts_save" );
5841
- /**
5842
- * Saves the custom scripts into the options table
5843
- * @return void
5844
- */
5845
- function wplc_custom_scripts_save(){
5846
-
5847
- if( isset( $_POST['wplc_save_settings'] ) ){
5848
-
5849
- if( isset( $_POST['wplc_custom_css'] ) ){
5850
- update_option( "WPLC_CUSTOM_CSS", nl2br( $_POST['wplc_custom_css'] ) );
5851
- }
5852
-
5853
- if( isset( $_POST['wplc_custom_js'] ) ){
5854
- update_option( "WPLC_CUSTOM_JS", nl2br( $_POST['wplc_custom_js'] ) );
5855
- }
5856
-
5857
- }
5858
-
5859
- }
5860
-
5861
- add_action( "wp_head", "wplc_custom_scripts_frontend" );
5862
- /**
5863
- * Display the custom scripts on the front end of the site
5864
- * @return string
5865
- */
5866
- function wplc_custom_scripts_frontend(){
5867
-
5868
- $wplc_custom_css = get_option( "WPLC_CUSTOM_CSS" );
5869
- $wplc_custom_js = get_option( "WPLC_CUSTOM_JS" );
5870
-
5871
- if( $wplc_custom_css ){
5872
- echo "<!-- WPLC Custom CSS -->";
5873
- echo "<style>";
5874
- echo strip_tags( stripslashes( $wplc_custom_css ) );
5875
- echo "</style>";
5876
- }
5877
-
5878
- if( $wplc_custom_js ){
5879
- echo "<!-- WPLC Custom JS -->";
5880
- echo "<script>";
5881
- echo strip_tags( stripslashes( $wplc_custom_js ) );
5882
- echo "</script>";
5883
- }
5884
-
5885
- }
5886
-
5887
- add_filter( "wplc_offline_message_subject_filter", "wplc_change_offline_message", 10, 1 );
5888
- /**
5889
- * Adds a filter to change the email address to the user's preference
5890
- * @param string $subject The default subject
5891
- * @return string
5892
- */
5893
- function wplc_change_offline_message( $subject ){
5894
-
5895
- $wplc_settings = get_option( "WPLC_SETTINGS");
5896
-
5897
- if( isset( $wplc_settings['wplc_pro_chat_email_offline_subject'] ) ){
5898
- $subject = stripslashes( $wplc_settings['wplc_pro_chat_email_offline_subject'] );
5899
- }
5900
-
5901
- return $subject;
5902
-
5903
- }
5904
-
5905
- function wplc_basic_version_departments(){
5906
- echo "<div class='wrap wplc_wrap'>";
5907
- echo sprintf( "<div class='error'><p>".__("WP Live Chat Support requires WP Live Chat Support Pro Version 7.0.0 or greater in order for departments to function as expected. Please update WP Live Chat Support %s", "wplivechat")."</p></div>", "<a href='".admin_url('update-core.php')."'>".__("here", "wplivechat")."</a>" );
5908
- echo "</div>";
5909
-
5910
- $content = "";
5911
-
5912
- $content .= "<table class=\"wp-list-table wplc_list_table widefat fixed \" cellspacing=\"0\" style='width:98%'>";
5913
- $content .= "<thead>";
5914
- $content .= "<tr>";
5915
- $content .= "<th scope='col'><span>" . __("ID", "wplivechat") . "</span></th>";
5916
- $content .= "<th scope='col'><span>" . __("Name", "wplivechat") . "</span></th>";
5917
- $content .= "<th scope='col'><span>" . __("Action", "wplivechat") . "</span></th>";
5918
- $content .= "</tr>";
5919
- $content .= "</thead>";
5920
-
5921
- $content .= "<tr><td>".__("Please update your Pro version to create a department", "wp-livechat")."</td><td></td><td></td></tr>";
5922
-
5923
- $content .= "</table>";
5924
-
5925
- echo $content;
5926
- }
5927
-
5928
- add_filter( 'wplc_filter_active_chat_box_notification', 'wplc_active_chat_box_notice' );
5929
-
5930
- if ( ! function_exists( "wplc_active_chat_box_notices" ) ) {
5931
- add_action( "wplc_hook_chat_dashboard_above", "wplc_active_chat_box_notices" );
5932
- function wplc_active_chat_box_notices() {
5933
- $wplc_settings = get_option( "WPLC_SETTINGS" );
5934
- if ( $wplc_settings["wplc_settings_enabled"] == 2 ) { ?>
5935
- <div class="wplc-chat-box-notification wplc-chat-box-notification--disabled">
5936
- <p><?php echo sprintf( __( 'The Live Chat box is currently disabled on your website due to : <a href="%s">General Settings</a>', 'wp-livechat' ), admin_url( 'admin.php?page=wplivechat-menu-settings#tabs-1' ) ) ?></p>
5937
- </div>
5938
- <?php
5939
- } else {
5940
- //$notice = '<div class="wplc-chat-box-notification">';
5941
- //$notice .= '<p>' . __( 'The Live Chat box is currently active', 'wp-livechat' ) . '</p>';
5942
- //$notice .= '</div>';
5943
- $notice = '';
5944
- $notice = apply_filters( 'wplc_filter_active_chat_box_notice', $notice );
5945
- echo $notice;
5946
- }
5947
-
5948
- }
5949
- }
5950
-
5951
-
5952
- add_filter("wplc_filter_chat_4th_layer_below_input","nifty_chat_ratings_div_backwards_compat",2,2);
5953
- /**
5954
- * This adds backwards compatibility to the new look and feel of the modern chat box
5955
- *
5956
- * The ' | ' is removed from the rating icons to fit the new look and feel
5957
- *
5958
- */
5959
- function nifty_chat_ratings_div_backwards_compat($msg, $wplc_setting){
5960
- $msg = str_replace(" | ","", $msg);
5961
- return $msg;
5962
-
5963
- }
5964
-
5965
- /**
5966
- * Identifies if the chat box should show, scripts should run and the dashboard should display correctly all based on certain versions.
5967
- *
5968
- * i.e. This is the part where we force users to upgrade their extensions to make sure everything works correctly.
5969
- *
5970
- * Use with caution and always try add backwards compatibility where necessary
5971
- *
5972
- * @param bool $continue
5973
- * @return bool
5974
- * @since 7.1.00
5975
- * @author Nick Duncan
5976
- */
5977
- add_filter( "wplc_version_check_continue", "wplc_filter_control_version_check_continue", 10, 1 );
5978
- function wplc_filter_control_version_check_continue( $continue ) {
5979
-
5980
- /**
5981
- * Check to see that we are on the cloud server 1.3.00 or newer
5982
- */
5983
- if ( function_exists("wplc_cloud_load_updates") ) {
5984
- global $wplc_cloud_version;
5985
- $float_version = intval( str_replace(".", "", $wplc_cloud_version ) );
5986
- if ($float_version < 2000) {
5987
- return sprintf( "Your chat has been disabled due to a version conflict. Please <a href='%s'>update your cloud extension</a> to 1.3.00 or higher.", admin_url('update-core.php') )."<br />";
5988
-
5989
- }
5990
- }
5991
-
5992
- return $continue;
5993
-
5994
- }
5995
-
5996
- /*
5997
- * Returns the WDT emoji selector
5998
- */
5999
- function wplc_emoji_selector_div(){
6000
- $wplc_settings = get_option("WPLC_SETTINGS");
6001
-
6002
- // NB: This causes Failed to initVars ReferenceError: wplc_show_date is not defined when uncommented and enabled
6003
- if(!empty($wplc_settings['wplc_disable_emojis']))
6004
- return;
6005
-
6006
- $emoji_container = "";
6007
- if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
6008
- $emoji_container = '<div class="wdt-emoji-popup">
6009
- <a href="#" class="wdt-emoji-popup-mobile-closer"> &times; </a>
6010
- <div class="wdt-emoji-menu-content">
6011
- <div id="wdt-emoji-menu-header">
6012
- <a class="wdt-emoji-tab" data-group-name="People"></a>
6013
- <a class="wdt-emoji-tab" data-group-name="Nature"></a>
6014
- <a class="wdt-emoji-tab" data-group-name="Foods"></a>
6015
- <a class="wdt-emoji-tab" data-group-name="Activity"></a>
6016
- <a class="wdt-emoji-tab" data-group-name="Places"></a>
6017
- <a class="wdt-emoji-tab" data-group-name="Objects"></a>
6018
- <a class="wdt-emoji-tab" data-group-name="Symbols"></a>
6019
- <a class="wdt-emoji-tab" data-group-name="Flags"></a>
6020
- </div>
6021
- <div class="wdt-emoji-scroll-wrapper">
6022
- <div id="wdt-emoji-menu-items">
6023
- <input id="wdt-emoji-search" type="text" placeholder="Search">
6024
- <h3 id="wdt-emoji-search-result-title">Search Results</h3>
6025
- <div class="wdt-emoji-sections"></div>
6026
- <div id="wdt-emoji-no-result">No emoji found</div>
6027
- </div>
6028
- </div>
6029
- <div id="wdt-emoji-footer">
6030
- <div id="wdt-emoji-preview">
6031
- <span id="wdt-emoji-preview-img"></span>
6032
- <div id="wdt-emoji-preview-text">
6033
- <span id="wdt-emoji-preview-name"></span><br>
6034
- <span id="wdt-emoji-preview-aliases"></span>
6035
- </div>
6036
- </div>
6037
- <div id="wdt-emoji-preview-bundle">
6038
- <span></span>
6039
- </div>
6040
- <span class="wdt-credit">WDT Emoji Bundle</span>
6041
- </div>
6042
- </div>
6043
- </div>';
6044
- }
6045
-
6046
- return $emoji_container;
6047
-
6048
- }
6049
-
6050
- add_action("wplc_hook_chat_missed","wplc_missed_chats_deprecation_notice",5);
6051
- /**
6052
- * Displays a notice to the user that Missed Chats is being deprecated
6053
- */
6054
- function wplc_missed_chats_deprecation_notice() {
6055
- $output = "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>";
6056
- $output .= "<strong>" . __("Deprecation Notice", "wplivechat") . "</strong><br>";
6057
- $output .= "<p>" . __("Please note, missed chat functionality is being deprecated as we will be moving to a customer oriented system in the near future. ", "wplivechat") . "</p>";
6058
- $output .= "<p>" . __("The new system will offer more insight into your user base while enhancing your experience when retrieving statistics and information. ", "wplivechat") . "</p>";
6059
- $output .= "<p>" . __("This area will remain active for the time being, however it is recommended that you prepare for this change in the near future. ", "wplivechat") . "</p>";
6060
- $output .= "</div>";
6061
-
6062
- echo $output;
6063
- }
6064
-
6065
- add_action( 'admin_notices', 'wplc_browser_notifications_admin_warning' );
6066
- /**
6067
- * Displays browser notifications warning.
6068
- *
6069
- * Only displays if site is insecure (no SSL).
6070
- */
6071
- function wplc_browser_notifications_admin_warning() {
6072
-
6073
- if ( ! is_ssl() && isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu-settings' ) {
6074
-
6075
- if ( isset( $_GET['wplc_dismiss_notice_bn'] ) && 'true' === $_GET['wplc_dismiss_notice_bn'] ) {
6076
-
6077
- update_option( 'wplc_dismiss_notice_bn', 'true' );
6078
-
6079
- }
6080
-
6081
- if ( get_option( 'wplc_dismiss_notice_bn') !== 'true' ) {
6082
-
6083
- ?>
6084
- <div class="notice notice-warning is-dismissible">
6085
- <p><img src="<?php echo esc_attr( plugins_url( 'images/wplc-logo.png', __FILE__ ) ); ?>" style="width:260px;height:auto;max-width:100%;"></p>
6086
- <p><strong><?php esc_html_e( 'Browser notifications will no longer function on insecure (non-SSL) sites.', 'wplivechat' ); ?></strong></p>
6087
- <p><?php esc_html_e( 'Please add an SSL certificate to your site to continue receiving chat notifications in your browser.', 'wplivechat' ); ?></p>
6088
- <p><a href="?page=<?php echo esc_attr( $_GET['page'] ); ?>&wplc_dismiss_notice_bn=true" id="wplc_dismiss_notice_bn" class="button"><?php esc_html_e( "Don't Show This Again", 'wplivechat' ); ?></a></p>
6089
- </div>
6090
- <?php
6091
-
6092
- }
6093
- }
6094
- }
6095
-
6096
- if ( function_exists( 'wplc_et_first_run_check' ) ) {
6097
- add_action( 'admin_notices', 'wplc_transcript_admin_notice' );
6098
- }
6099
- function wplc_transcript_admin_notice() {
6100
- printf( '<div class="notice notice-info">%1$s</div>', __( 'Please deactivate WP Live Chat Suport - Email Transcript plugin. Since WP Live Chat Support 8.0.05 there is build in support for Email Transcript.', 'wplivechat' ) );
6101
- }
6102
-
6103
- add_action( 'init', 'wplc_transcript_first_run_check' );
6104
- function wplc_transcript_first_run_check() {
6105
- if ( ! get_option( "WPLC_ET_FIRST_RUN" ) ) {
6106
- /* set the default settings */
6107
- $wplc_et_data['wplc_enable_transcripts'] = 1;
6108
- $wplc_et_data['wplc_send_transcripts_to'] = 'user';
6109
- $wplc_et_data['wplc_send_transcripts_when_chat_ends'] = 0;
6110
- $wplc_et_data['wplc_et_email_body'] = wplc_transcript_return_default_email_body();
6111
- $wplc_et_data['wplc_et_email_header'] = '<a title="' . get_bloginfo( 'name' ) . '" href="' . get_bloginfo( 'url' ) . '" style="font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #FFF; font-weight: bold; text-decoration: underline;">' . get_bloginfo( 'name' ) . '</a>';
6112
-
6113
- $default_footer_text = sprintf( __( 'Thank you for chatting with us. If you have any questions, please <a href="%1$s" target="_blank" style="font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #FFF; font-weight: bold; text-decoration: underline;">contact us</a>', 'wplivechat' ),
6114
- 'mailto:' . get_bloginfo( 'admin_email' )
6115
- );
6116
-
6117
- $wplc_et_data['wplc_et_email_footer'] = "<span style='font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #FFF; font-weight: normal;'>" . $default_footer_text . "</span>";
6118
-
6119
-
6120
- update_option( 'WPLC_ET_SETTINGS', $wplc_et_data );
6121
- update_option( "WPLC_ET_FIRST_RUN", true );
6122
- }
6123
- }
6124
-
6125
- add_action( 'wplc_hook_admin_visitor_info_display_after', 'wplc_transcript_add_admin_button' );
6126
- function wplc_transcript_add_admin_button( $cid ) {
6127
- $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6128
- $wplc_enable_transcripts = $wplc_et_settings['wplc_enable_transcripts'];
6129
- if ( isset( $wplc_enable_transcripts ) && $wplc_enable_transcripts == 1 ) {
6130
- echo "<p><a href=\"javascript:void(0);\" cid='" . sanitize_text_field( $cid ) . "' class=\"wplc_admin_email_transcript button button-secondary\" id=\"wplc_admin_email_transcript\">" . __( "Email transcript to user", "wplivechat" ) . "</a></p>";
6131
- }
6132
- }
6133
-
6134
- add_action( 'wplc_hook_admin_javascript_chat', 'wplc_transcript_admin_javascript' );
6135
- function wplc_transcript_admin_javascript() {
6136
- $wplc_et_ajax_nonce = wp_create_nonce( "wplc_et_nonce" );
6137
- wp_register_script( 'wplc_transcript_admin', plugins_url( '/js/wplc_transcript.js', __FILE__ ), null, '', true );
6138
- $wplc_transcript_localizations = array(
6139
- 'ajax_nonce' => $wplc_et_ajax_nonce,
6140
- 'string_loading' => __( "Sending transcript...", "wplivechat" ),
6141
- 'string_title' => __( "Sending Transcript", "wplivechat" ),
6142
- 'string_close' => __( "Close", "wplivechat" ),
6143
- 'string_chat_emailed' => __( "The chat transcript has been emailed.", "wplivechat" ),
6144
- 'string_error1' => sprintf( __( "There was a problem emailing the chat. Please <a target='_BLANK' href='%s'>contact support</a>.", "wplivechat" ), "http://wp-livechat.com/contact-us/?utm_source=plugin&utm_medium=link&utm_campaign=error_emailing_chat" )
6145
- );
6146
- wp_localize_script( 'wplc_transcript_admin', 'wplc_transcript_nonce', $wplc_transcript_localizations );
6147
- wp_enqueue_script( 'wplc_transcript_admin' );
6148
- }
6149
-
6150
- add_action( 'wp_ajax_wplc_et_admin_email_transcript', 'wplc_transcript_callback' );
6151
- function wplc_transcript_callback() {
6152
- $check = check_ajax_referer( 'wplc_et_nonce', 'security' );
6153
- if ( $check == 1 ) {
6154
-
6155
- if ( isset( $_POST['el'] ) && $_POST['el'] === 'endChat' ) {
6156
- $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6157
- $transcript_chat_ends = $wplc_et_settings['wplc_send_transcripts_when_chat_ends'];
6158
- if ( $transcript_chat_ends === 0 ) {
6159
- wp_die();
6160
- }
6161
- }
6162
-
6163
- if ( $_POST['action'] == "wplc_et_admin_email_transcript" ) {
6164
- if ( isset( $_POST['cid'] ) ) {
6165
- $cid = wplc_return_chat_id_by_rel( $_POST['cid'] );
6166
- echo json_encode( wplc_send_transcript( sanitize_text_field( $cid ) ) );
6167
- } else {
6168
- echo json_encode( array( "error" => "no CID" ) );
6169
- }
6170
- wp_die();
6171
- }
6172
-
6173
- wp_die();
6174
- }
6175
- wp_die();
6176
- }
6177
-
6178
- function wplc_send_transcript( $cid ) {
6179
- if ( ! $cid ) {
6180
- return array( "error" => "no CID", "cid" => $cid );
6181
- }
6182
-
6183
- if( ! filter_var($cid, FILTER_VALIDATE_INT) ) {
6184
- /* We need to identify if this CID is a node CID, and if so, return the WP CID */
6185
- $cid = wplc_return_chat_id_by_rel($cid);
6186
- }
6187
-
6188
- $email = false;
6189
- $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6190
-
6191
- $wplc_enable_transcripts = $wplc_et_settings['wplc_enable_transcripts'];
6192
- if ( isset( $wplc_enable_transcripts ) && $wplc_enable_transcripts == 1 ) {
6193
-
6194
- if ( function_exists( "wplc_get_chat_data" ) ) {
6195
- $cdata = wplc_get_chat_data( $cid );
6196
- if ( $cdata ) {
6197
- if ( $wplc_et_settings['wplc_send_transcripts_to'] === 'admin' ) {
6198
- $user = wp_get_current_user();
6199
- $email = $user->user_email;
6200
- } else {
6201
- $email = $cdata->email;
6202
- }
6203
- if ( ! $email ) {
6204
- return array( "error" => "no email" );
6205
- }
6206
- } else {
6207
- return array( "error" => "no chat data" );
6208
- }
6209
- } else {
6210
- return array( "error" => "basic funtion missing" );
6211
- }
6212
-
6213
- $headers = array( 'Content-Type: text/html; charset=UTF-8' );
6214
- $subject = sprintf( __( 'Your chat transcript from %1$s', 'wplivechat' ),
6215
- get_bloginfo( 'url' )
6216
- );
6217
- wp_mail( $email, $subject, wplc_transcript_return_chat_messages( $cid ), $headers );
6218
-
6219
- }
6220
-
6221
- return array( "success" => 1 );
6222
-
6223
- }
6224
- add_action('wplc_send_transcript_hook', 'wplc_send_transcript', 10, 1);
6225
-
6226
- function wplc_transcript_return_chat_messages( $cid ) {
6227
- global $current_chat_id;
6228
- $current_chat_id = $cid;
6229
- $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6230
- $body = html_entity_decode( stripslashes( $wplc_et_settings['wplc_et_email_body'] ) );
6231
-
6232
- if ( ! $body ) {
6233
- $body = do_shortcode( wplc_transcript_return_default_email_body() );
6234
- } else {
6235
- $body = do_shortcode( $body );
6236
- }
6237
-
6238
- return $body;
6239
- }
6240
-
6241
- function wplc_transcript_return_default_email_body() {
6242
- $body = '
6243
- <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
6244
- <html>
6245
-
6246
- <body>
6247
-
6248
-
6249
-
6250
- <table id="" border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color: #ec822c;">
6251
- <tbody>
6252
- <tr>
6253
- <td width="100%" style="padding: 30px 20px 100px 20px;">
6254
- <table align="center" cellpadding="0" cellspacing="0" class="" width="100%" style="border-collapse: separate; max-width:600px;">
6255
- <tbody>
6256
- <tr>
6257
- <td style="text-align: center; padding-bottom: 20px;">
6258
-
6259
- <p>[wplc_et_transcript_header_text]</p>
6260
- </td>
6261
- </tr>
6262
- </tbody>
6263
- </table>
6264
-
6265
- <table id="" align="center" cellpadding="0" cellspacing="0" class="" width="100%" style="border-collapse: separate; max-width: 600px; font-family: Georgia, serif; font-size: 12px; color: rgb(51, 62, 72); border: 0px solid rgb(255, 255, 255); border-radius: 10px; background-color: rgb(255, 255, 255);">
6266
- <tbody>
6267
- <tr>
6268
- <td class="sortable-list ui-sortable" style="padding:20px;">
6269
- [wplc_et_transcript]
6270
- </td>
6271
- </tr>
6272
- </tbody>
6273
- </table>
6274
-
6275
- <table align="center" cellpadding="0" cellspacing="0" class="" width="100%" style="border-collapse: separate; max-width:100%;">
6276
- <tbody>
6277
- <tr>
6278
- <td style="padding:20px;">
6279
- <table border="0" cellpadding="0" cellspacing="0" class="" width="100%">
6280
- <tbody>
6281
- <tr>
6282
- <td id="" align="center">
6283
- <p>[wplc_et_transcript_footer_text]</p>
6284
- </td>
6285
- </tr>
6286
- </tbody>
6287
- </table>
6288
- </td>
6289
- </tr>
6290
- </tbody>
6291
- </table>
6292
- </td>
6293
- </tr>
6294
- </tbody>
6295
- </table>
6296
-
6297
-
6298
-
6299
- </div>
6300
- </body>
6301
- </html>
6302
- ';
6303
-
6304
- return $body;
6305
- }
6306
-
6307
- add_action( 'wplc_hook_admin_settings_save', 'wplc_transcript_save_settings' );
6308
- function wplc_transcript_save_settings() {
6309
- if ( isset( $_POST['wplc_save_settings'] ) ) {
6310
- if ( isset( $_POST['wplc_enable_transcripts'] ) ) {
6311
- $wplc_et_data['wplc_enable_transcripts'] = esc_attr( $_POST['wplc_enable_transcripts'] );
6312
- } else {
6313
- $wplc_et_data['wplc_enable_transcripts'] = 0;
6314
- }
6315
- if ( isset( $_POST['wplc_send_transcripts_to'] ) ) {
6316
- $wplc_et_data['wplc_send_transcripts_to'] = esc_attr( $_POST['wplc_send_transcripts_to'] );
6317
- } else {
6318
- $wplc_et_data['wplc_send_transcripts_to'] = 'user';
6319
- }
6320
- if ( isset( $_POST['wplc_send_transcripts_when_chat_ends'] ) ) {
6321
- $wplc_et_data['wplc_send_transcripts_when_chat_ends'] = esc_attr( $_POST['wplc_send_transcripts_when_chat_ends'] );
6322
- } else {
6323
- $wplc_et_data['wplc_send_transcripts_when_chat_ends'] = 0;
6324
- }
6325
- if ( isset( $_POST['wplc_et_email_header'] ) ) {
6326
- $wplc_et_data['wplc_et_email_header'] = esc_attr( $_POST['wplc_et_email_header'] );
6327
- }
6328
- if ( isset( $_POST['wplc_et_email_footer'] ) ) {
6329
- $wplc_et_data['wplc_et_email_footer'] = esc_attr( $_POST['wplc_et_email_footer'] );
6330
- }
6331
- if ( isset( $_POST['wplc_et_email_body'] ) ) {
6332
- $wplc_et_data['wplc_et_email_body'] = esc_html( $_POST['wplc_et_email_body'] );
6333
- }
6334
- update_option( 'WPLC_ET_SETTINGS', $wplc_et_data );
6335
-
6336
- }
6337
- }
6338
-
6339
- add_action( 'wplc_hook_admin_settings_main_settings_after', 'wplc_hook_admin_transcript_settings' );
6340
- function wplc_hook_admin_transcript_settings() {
6341
- $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6342
- echo "<hr />";
6343
- echo "<h3>" . __( "Chat Transcript Settings", 'wplivechat' ) . "</h3>";
6344
- echo "<table class='form-table wp-list-table widefat fixed striped pages' width='700'>";
6345
- echo " <tr>";
6346
- echo " <td width='400' valign='top'>" . __( "Enable chat transcripts:", "wplivechat" ) . "</td>";
6347
- echo " <td>";
6348
- echo " <input type=\"checkbox\" value=\"1\" name=\"wplc_enable_transcripts\" ";
6349
- if ( isset( $wplc_et_settings['wplc_enable_transcripts'] ) && $wplc_et_settings['wplc_enable_transcripts'] == 1 ) {
6350
- echo "checked";
6351
- }
6352
- echo " />";
6353
- echo " </td>";
6354
- echo " </tr>";
6355
-
6356
- echo " <tr>";
6357
- echo " <td width='400' valign='top'>" . __( "Send transcripts to:", "wplivechat" ) . "</td>";
6358
- echo " <td>";
6359
- echo " <select name=\"wplc_send_transcripts_to\">";
6360
- echo " <option value=\"user\" ";
6361
- if ( isset( $wplc_et_settings['wplc_send_transcripts_to'] ) && $wplc_et_settings['wplc_send_transcripts_to'] == 'user' ) {
6362
- echo "selected";
6363
- }
6364
- echo ">" . __( "User", "wplivechat" ) . "</option>";
6365
- echo " <option value=\"admin\" ";
6366
- if ( isset( $wplc_et_settings['wplc_send_transcripts_to'] ) && $wplc_et_settings['wplc_send_transcripts_to'] == 'admin' ) {
6367
- echo "selected";
6368
- }
6369
- echo ">" . __( "Admin", "wplivechat" ) . "</option>";
6370
- echo " </select>";
6371
- echo " </td>";
6372
- echo " </tr>";
6373
-
6374
- echo " <tr>";
6375
- echo " <td width='400' valign='top'>" . __( "Send transcripts when chat ends:", "wplivechat" ) . "</td>";
6376
- echo " <td>";
6377
- echo " <input type=\"checkbox\" value=\"1\" name=\"wplc_send_transcripts_when_chat_ends\" ";
6378
- if ( isset( $wplc_et_settings['wplc_send_transcripts_when_chat_ends'] ) && $wplc_et_settings['wplc_send_transcripts_when_chat_ends'] == 1 ) {
6379
- echo "checked";
6380
- }
6381
- echo " />";
6382
- echo " </td>";
6383
- echo " </tr>";
6384
-
6385
- echo " <tr>";
6386
- echo " <td width='400' valign='top'>" . __( "Email body", "wplivechat" ) . "</td>";
6387
- echo " <td>";
6388
- echo " <textarea cols='85' rows='15' name=\"wplc_et_email_body\">";
6389
- if ( isset( $wplc_et_settings['wplc_et_email_body'] ) ) {
6390
- echo html_entity_decode( stripslashes( $wplc_et_settings['wplc_et_email_body'] ) );
6391
- }
6392
- echo " </textarea>";
6393
- echo " </td>";
6394
- echo " </tr>";
6395
-
6396
-
6397
- echo " <tr>";
6398
- echo " <td width='400' valign='top'>" . __( "Email header", "wplivechat" ) . "</td>";
6399
- echo " <td>";
6400
- echo " <textarea cols='85' rows='5' name=\"wplc_et_email_header\">";
6401
- if ( isset( $wplc_et_settings['wplc_et_email_header'] ) ) {
6402
- echo stripslashes( $wplc_et_settings['wplc_et_email_header'] );
6403
- }
6404
- echo " </textarea>";
6405
- echo " </td>";
6406
- echo " </tr>";
6407
-
6408
- echo " <tr>";
6409
- echo " <td width='400' valign='top'>" . __( "Email footer", "wplivechat" ) . "</td>";
6410
- echo " <td>";
6411
- echo " <textarea cols='85' rows='5' name=\"wplc_et_email_footer\">";
6412
- if ( isset( $wplc_et_settings['wplc_et_email_footer'] ) ) {
6413
- echo stripslashes( $wplc_et_settings['wplc_et_email_footer'] );
6414
- }
6415
- echo " </textarea>";
6416
- echo " </td>";
6417
- echo " </tr>";
6418
-
6419
-
6420
- echo "</table>";
6421
- }
6422
-
6423
- add_shortcode('wplc_et_transcript', 'wplc_transcript_get_transcript');
6424
- function wplc_transcript_get_transcript() {
6425
- global $current_chat_id;
6426
- $cid = $current_chat_id;
6427
-
6428
- if ( intval( $cid ) > 0 ) {
6429
- return wplc_return_chat_messages( intval( $cid ), true );
6430
- } else {
6431
- return "0";
6432
- }
6433
- }
6434
-
6435
- add_shortcode( 'wplc_et_transcript_footer_text', 'wplc_transcript_get_footer_text' );
6436
- function wplc_transcript_get_footer_text() {
6437
- $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6438
- $wplc_et_footer = html_entity_decode( stripslashes( $wplc_et_settings['wplc_et_email_footer'] ) );
6439
- if ( $wplc_et_footer ) {
6440
- return $wplc_et_footer;
6441
- } else {
6442
- return "";
6443
- }
6444
- }
6445
-
6446
- add_shortcode( 'wplc_et_transcript_header_text', 'wplc_transcript_get_header_text' );
6447
- function wplc_transcript_get_header_text() {
6448
- $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6449
-
6450
- global $current_chat_id;
6451
- $cid = $current_chat_id;
6452
-
6453
- $from_email = "Unknown@unknown.com";
6454
- $from_name = "User";
6455
- if ( intval( $cid ) > 0 ) {
6456
- $chat_data = wplc_get_chat_data( $cid );
6457
- if ( isset( $chat_data->email ) ) {
6458
- $from_email = $chat_data->email;
6459
- }
6460
- if ( isset( $chat_data->name ) ) {
6461
- $from_name = $chat_data->name;
6462
- }
6463
- }
6464
-
6465
- $wplc_et_header = "<h3>".$from_name." (".$from_email.")"."</h3>".html_entity_decode( stripslashes( $wplc_et_settings['wplc_et_email_header'] ) );
6466
- if ( $wplc_et_header ) {
6467
- return $wplc_et_header;
6468
- } else {
6469
- return "";
6470
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6471
  }
1
+ <?php
2
+ /*
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.23
7
+ Author: WP-LiveChat
8
+ Author URI: http://www.wp-livechat.com
9
+ Text Domain: wplivechat
10
+ Domain Path: /languages
11
+ */
12
+
13
+ /**
14
+ * 8.0.23 - 2019-02-05 - Low priority
15
+ * Fixed access to new dashboard for non admin agents
16
+ * Fixed documentation suggestions not working (Pro)
17
+ *
18
+ * 8.0.22 - 2019-02-04 - Low priority
19
+ * Introduced a new dashboard that showcases latest blog posts, the latest podcast episode and the system status
20
+ * Moved GDPR warnings for first time users to the settings page only
21
+ * Moved the warning regarding desktop notifications to the settings page only
22
+ *
23
+ * 8.0.21 - 2018-12-18 - Low priority
24
+ * Readme Update: Coming soon features
25
+ * Readme Update: Features list
26
+ * Tested on WordPress 5.0.1
27
+ * Updated ZH_CN translation files. Thanks to Air
28
+ *
29
+ * 8.0.20 - 2018-11-29 - Medium priority
30
+ * Fixed issue where relay server requests were made via a shortpoll. (Performance Update)
31
+ * Re-enabled automatic server location selection for new insttalations
32
+ * GDPR Compliance is now disabled by default for new installations
33
+ *
34
+ * 8.0.19 - 2018-11-19 - Medium priority
35
+ * Tested on WordPress 5 Beta
36
+ * Tested Basic Gutenberg Block Support
37
+ *
38
+ * 8.0.18 - 2018-11-01 - High Priority
39
+ * Fixed XSS vulnerability within the GDPR search system (Thanks to Tim Coen)
40
+ * Fixed Self-XSS vulnerability within the message input field on both dashboard and chat box (Thanks to Tim Coen)
41
+ *
42
+ * 8.0.17 - 2018-10-19 - Low priority
43
+ * Removes WP User Avatar option from settings page. This was incorrectly included in the last release.
44
+ *
45
+ * 8.0.16 - 2018-10-18 - Low priority
46
+ * Fixed undefined 'wplc_user_avatars' not defined error on frontend
47
+ *
48
+ * 8.0.15 - 2018-10-11 - High priority
49
+ * Added WP User Avatar integration
50
+ * Added jQuery 3 compatibility as per WordPress.org guidelines
51
+ * Added auto hide of chat ended prompt on close or restart
52
+ * Fixed a possible injection issue within the notification control (Thanks to Nico from https://serhack.me)
53
+ * Fixed Gutenberg and Yoast compatibility issue
54
+ * Fixed minor issue with rest storage module
55
+ * Fixed minor styling issue with popup dashbaord
56
+ * Fixed some core issues which influenced custom fields (Pro)
57
+ * Fixed issue with Android Browser image missing in dashboard
58
+ * Fixed delete chat history not deleting messages
59
+ * Fixed nonce checking for non-logged in users failing on cached pages for AJAX and WP API
60
+ * Updated NL translation with GDPR strings (Google Translate)
61
+ * Updated EL translation files. Thanks to Ioannis Barkouzos
62
+ * Updated FR translation files. Thanks to Freitas Junior
63
+ * Updated IT translation files. Thanks to Carlo Piazzano
64
+ * Updated AR translation files.
65
+ *
66
+ * 8.0.14 - 2018-07-19 - Low priority
67
+ * Removed 'let' from wplc_server.js file (Adds Safari compatibility)
68
+ * Fixed issues with Google Analytics integration when using our servers
69
+ * Fixed issues with chat box styling with classic theme and GDPR module enabled
70
+ * Fixed issues with Contact From Ready integration styling with modern theme
71
+ * Fixed issues with Slack integration extension
72
+ * Bulgarian Translation Added (Thank you Emil Genchev!)
73
+ * Fixed erroneous display of set_time_limit and safe_mode warnings
74
+ * Fixed a big that lead to the deletion of sessions and not messages when a chat was marked for deletion
75
+ * Improved security in the chat history code
76
+ * Added better styling support for smaller width devices (<500px)
77
+ * Updated Swedish translation files
78
+ * Added Arabic translation files
79
+ * Fixed the duplicate message history loading in the history area
80
+ * Fixed core framework issues with Voice Note system
81
+ * Fixed an issue where invalid query selectors would break the 'Open chat via' functionality
82
+ * Fixed an issue with username encoding
83
+ * Fixed issue with surveys showing after chat end
84
+ * Fixed an issue with classic theme display when anchored to left/right positions
85
+ * Added auto transcript mailing to frontend end chat button, and REST API
86
+ * Added an 'incomplete' class when GDPR checkbox is not ticket, to draw attention to this input field
87
+ * Tested Multi-Site compatibility
88
+ * Updated all PO/MO files with updated sources
89
+ * Added default GDPR translations for DE, FR, ES, and IT languages (Using Google Translate)
90
+ *
91
+ * 8.0.13 - 2018-06-06 - Medium priority
92
+ * Fix chat delay not working for first visit and offline
93
+ * Optimize images
94
+ * Mootools compatibility
95
+ * Fix new chat request email notifications when Pro is active
96
+ *
97
+ * 8.0.12 - 2018-05-29 - High priority
98
+ * Fixed a bug which caused the chat box not to display on some sites
99
+ * Fixed minor styling issues
100
+ *
101
+ * 8.0.11 - 2018-05-28 - High priority
102
+ * Fixed a bug that caused a fatal error on PHP 5.3 and below
103
+ */
104
+
105
+ //error_reporting(E_ERROR);
106
+ global $wplc_version;
107
+ global $wplc_p_version;
108
+ global $wplc_tblname;
109
+ global $wpdb;
110
+ global $wplc_tblname_chats;
111
+ global $wplc_tblname_msgs;
112
+ global $wplc_tblname_offline_msgs;
113
+
114
+ /**
115
+ * This stores the admin chat data once so that we do not need to keep sourcing it via the WP DB or Cloud DB
116
+ */
117
+ global $admin_chat_data;
118
+ $admin_chat_data = false;
119
+
120
+ global $debug_start;
121
+
122
+ $wplc_tblname_offline_msgs = $wpdb->prefix . "wplc_offline_messages";
123
+ $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
124
+ $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
125
+ $wplc_version = "8.0.23";
126
+
127
+ define('WPLC_BASIC_PLUGIN_DIR', dirname(__FILE__));
128
+ define('WPLC_BASIC_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
129
+ define('WPLC_PLUGIN', plugin_basename( __FILE__ ) );
130
+ global $wplc_basic_plugin_url;
131
+ $wplc_basic_plugin_url = WPLC_BASIC_PLUGIN_URL;
132
+
133
+
134
+ global $wplc_pro_version;
135
+ $wplc_ver = str_replace('.', '', $wplc_pro_version);
136
+ $checker = intval($wplc_ver);
137
+ if (function_exists("wplc_pro_version_control") && $checker < 6000) { } else {
138
+ require_once (plugin_dir_path(__FILE__) . "ajax_new.php");
139
+ }
140
+
141
+ require_once (plugin_dir_path(__FILE__) . "functions.php");
142
+ require_once (plugin_dir_path(__FILE__) . "includes/deprecated.php");
143
+ require_once (plugin_dir_path(__FILE__) . "includes/surveys.php");
144
+ require_once (plugin_dir_path(__FILE__) . "includes/notification_control.php");
145
+ require_once (plugin_dir_path(__FILE__) . "includes/modal_control.php");
146
+ require_once (plugin_dir_path(__FILE__) . "modules/documentation_suggestions.php");
147
+ require_once (plugin_dir_path(__FILE__) . "modules/offline_messages_custom_fields.php");
148
+ require_once (plugin_dir_path(__FILE__) . "modules/google_analytics.php");
149
+ require_once (plugin_dir_path(__FILE__) . "modules/api/wplc-api.php");
150
+ require_once (plugin_dir_path(__FILE__) . "modules/beta_features.php");
151
+ require_once (plugin_dir_path(__FILE__) . "modules/node_server.php");
152
+ require_once (plugin_dir_path(__FILE__) . "modules/module_gif.php");
153
+ require_once (plugin_dir_path(__FILE__) . "includes/update_control.class.php");
154
+ require_once (plugin_dir_path(__FILE__) . "modules/webhooks_manager.php");
155
+ require_once (plugin_dir_path(__FILE__) . "modules/privacy.php");
156
+
157
+ // Gutenberg Blocks
158
+ require_once (plugin_dir_path(__FILE__) . "includes/blocks/wplc-chat-box/index.php");
159
+ require_once (plugin_dir_path(__FILE__) . "includes/blocks/wplc-inline-chat-box/index.php");
160
+
161
+ // Shortcodes
162
+ require_once (plugin_dir_path(__FILE__) . "includes/shortcodes.php");
163
+
164
+ add_action( 'wp_ajax_wplc_admin_set_transient', 'wplc_action_callback' );
165
+ add_action( 'wp_ajax_wplc_admin_remove_transient', 'wplc_action_callback' );
166
+ add_action( 'wp_ajax_wplc_hide_ftt', 'wplc_action_callback' );
167
+ add_action( 'wp_ajax_nopriv_wplc_user_send_offline_message', 'wplc_action_callback' );
168
+ add_action( 'wp_ajax_wplc_user_send_offline_message', 'wplc_action_callback' );
169
+ add_action( 'wp_ajax_delete_offline_message', 'wplc_action_callback' );
170
+ add_action( 'wp_ajax_wplc_a2a_dismiss', 'wplc_action_callback' );
171
+ add_action( 'init', 'wplc_version_control' );
172
+ add_action( "activated_plugin", "wplc_redirect_on_activate" );
173
+ add_action( 'wp_footer', 'wplc_display_box' );
174
+ add_action( 'init', 'wplc_init' );
175
+
176
+
177
+
178
+ if (function_exists('wplc_head_pro')) {
179
+ add_action('admin_init', 'wplc_head_pro');
180
+ } else {
181
+ add_action('admin_init', 'wplc_head_basic');
182
+ }
183
+
184
+ add_action('wp_enqueue_scripts', 'wplc_add_user_stylesheet');
185
+ add_action('admin_enqueue_scripts', 'wplc_add_admin_stylesheet');
186
+
187
+ if (function_exists('wplc_admin_menu_pro')) {
188
+ add_action('admin_menu', 'wplc_admin_menu_pro');
189
+ } else {
190
+ add_action('admin_menu', 'wplc_admin_menu', 4);
191
+ }
192
+ add_action('admin_head', 'wplc_superadmin_javascript');
193
+ register_activation_hook(__FILE__, 'wplc_activate');
194
+
195
+
196
+ function wplc_basic_check() {
197
+ // check if basic exists if pro is installed
198
+ }
199
+
200
+ function wplc_init() {
201
+ $plugin_dir = basename(dirname(__FILE__)) . "/languages/";
202
+ load_plugin_textdomain('wplivechat', false, $plugin_dir);
203
+
204
+
205
+ }
206
+
207
+
208
+ /**
209
+ * Redirect the user to the welcome page on plugin activate
210
+ * @param string $plugin
211
+ * @return void
212
+ */
213
+ function wplc_redirect_on_activate( $plugin ) {
214
+
215
+ if( $plugin == plugin_basename( __FILE__ ) ) {
216
+ if (get_option("WPLC_V8_FIRST_TIME") == true) {
217
+ update_option("WPLC_V8_FIRST_TIME",false);
218
+ // clean the output header and redirect the user
219
+ @ob_flush();
220
+ @ob_end_flush();
221
+ @ob_end_clean();
222
+ exit( wp_redirect( admin_url( 'admin.php?page=wplivechat-menu&action=welcome' ) ) );
223
+ }
224
+ }
225
+ }
226
+
227
+
228
+ add_action( 'admin_init', 'wplc_redirect_on_activate' );
229
+
230
+
231
+
232
+ function wplc_version_control() {
233
+
234
+ global $wplc_version;
235
+
236
+
237
+ $current_version = get_option("wplc_current_version");
238
+ if (!isset($current_version) || $current_version != $wplc_version) {
239
+
240
+ $wplc_settings = get_option( 'WPLC_SETTINGS' );
241
+
242
+ /**
243
+ * Are we updating from a version before version 8?
244
+ * If yes, set NODE to enabled
245
+ */
246
+ if ( isset( $current_version ) ) {
247
+ $main_ver = intval( $current_version[0] );
248
+ if ( $main_ver < 8 ) {
249
+ if ( $wplc_settings ) {
250
+ $wplc_settings['wplc_use_node_server'] = 1;
251
+
252
+ update_option( "WPLC_V8_FIRST_TIME", true );
253
+
254
+ }
255
+ }
256
+
257
+ }
258
+
259
+
260
+ $admins = get_role('administrator');
261
+ if( $admins !== null ) {
262
+ $admins->add_cap('wplc_ma_agent');
263
+ }
264
+
265
+ $uid = get_current_user_id();
266
+ update_user_meta($uid, 'wplc_ma_agent', 1);
267
+ update_user_meta($uid, "wplc_chat_agent_online", time());
268
+
269
+ /*$wplc_super_admins = get_super_admins();
270
+
271
+ foreach( $wplc_super_admins as $super_admin ){
272
+
273
+ $user = get_user_by( 'login', $super_admin );
274
+
275
+ $wplc_super_admin_id = $user->ID;
276
+
277
+ update_user_meta( $wplc_super_admin_id, 'wplc_ma_agent', 1);
278
+ update_user_meta( $wplc_super_admin_id, "wplc_chat_agent_online", time());
279
+
280
+ break;
281
+
282
+ }
283
+ */
284
+
285
+
286
+ /* add caps to admin */
287
+ if (current_user_can('manage_options')) {
288
+ global $user_ID;
289
+ $user = new WP_User($user_ID);
290
+ foreach ($user->roles as $urole) {
291
+ if ($urole == "administrator") {
292
+ $admins = get_role('administrator');
293
+ $admins->add_cap('edit_wplc_quick_response');
294
+ $admins->add_cap('edit_wplc_quick_response');
295
+ $admins->add_cap('edit_other_wplc_quick_response');
296
+ $admins->add_cap('publish_wplc_quick_response');
297
+ $admins->add_cap('read_wplc_quick_response');
298
+ $admins->add_cap('read_private_wplc_quick_response');
299
+ $admins->add_cap('delete_wplc_quick_response');
300
+ }
301
+ }
302
+ }
303
+
304
+
305
+
306
+ if (!isset($wplc_settings['wplc_pro_na'])) { $wplc_settings["wplc_pro_na"] = __("Chat offline. Leave a message", "wplivechat"); }
307
+ if (!isset($wplc_settings['wplc_pro_intro'])) { $wplc_settings["wplc_pro_intro"] = __("Hello. Please input your details so that I may help you.", "wplivechat"); }
308
+ if (!isset($wplc_settings['wplc_pro_offline1'])) { $wplc_settings["wplc_pro_offline1"] = __("We are currently offline. Please leave a message and we'll get back to you shortly.", "wplivechat"); }
309
+ if (!isset($wplc_settings['wplc_pro_offline2'])) { $wplc_settings["wplc_pro_offline2"] = __("Sending message...", "wplivechat"); }
310
+ if (!isset($wplc_settings['wplc_pro_offline3'])) { $wplc_settings["wplc_pro_offline3"] = __("Thank you for your message. We will be in contact soon.", "wplivechat"); }
311
+ if (!isset($wplc_settings['wplc_pro_offline_btn']) || (isset($wplc_settings['wplc_pro_offline_btn']) && $wplc_settings['wplc_pro_offline_btn'] == "")) { $wplc_settings["wplc_pro_offline_btn"] = __("Leave a message", "wplivechat"); }
312
+ if (!isset($wplc_settings['wplc_pro_offline_btn_send']) || (isset($wplc_settings['wplc_pro_offline_btn_send']) && $wplc_settings['wplc_pro_offline_btn_send'] == "")) { $wplc_settings["wplc_pro_offline_btn_send"] = __("Send message", "wplivechat"); }
313
+ if (!isset($wplc_settings['wplc_pro_fst1'])) { $wplc_settings["wplc_pro_fst1"] = __("Questions?", "wplivechat"); }
314
+ if (!isset($wplc_settings['wplc_pro_fst2'])) { $wplc_settings["wplc_pro_fst2"] = __("Chat with us", "wplivechat"); }
315
+ if (!isset($wplc_settings['wplc_pro_fst3'])) { $wplc_settings["wplc_pro_fst3"] = __("Start live chat", "wplivechat"); }
316
+ if (!isset($wplc_settings['wplc_pro_sst1'])) { $wplc_settings["wplc_pro_sst1"] = __("Start Chat", "wplivechat"); }
317
+ if (!isset($wplc_settings['wplc_pro_sst1_survey'])) { $wplc_settings["wplc_pro_sst1_survey"] = __("Or chat to an agent now", "wplivechat"); }
318
+ if (!isset($wplc_settings['wplc_pro_sst1e_survey'])) { $wplc_settings["wplc_pro_sst1e_survey"] = __("Chat ended", "wplivechat"); }
319
+ if (!isset($wplc_settings['wplc_pro_sst2'])) { $wplc_settings["wplc_pro_sst2"] = __("Connecting. Please be patient...", "wplivechat"); }
320
+ if (!isset($wplc_settings['wplc_pro_tst1'])) { $wplc_settings["wplc_pro_tst1"] = __("Reactivating your previous chat...", "wplivechat"); }
321
+ if (!isset($wplc_settings['wplc_user_welcome_chat'])) { $wplc_settings["wplc_user_welcome_chat"] = __("Welcome. How may I help you?", "wplivechat"); }
322
+ if (!isset($wplc_settings['wplc_welcome_msg'])) { $wplc_settings['wplc_welcome_msg'] = __("Please standby for an agent. While you wait for the agent you may type your message.","wplivechat"); }
323
+ if (!isset($wplc_settings['wplc_user_enter'])) { $wplc_settings["wplc_user_enter"] = __("Press ENTER to send your message", "wplivechat"); }
324
+ if (!isset($wplc_settings['wplc_close_btn_text'])) { $wplc_settings["wplc_close_btn_text"] = __("close", "wplivechat"); }
325
+
326
+
327
+ if (!isset($wplc_settings['wplc_powered_by_link'])) { $wplc_settings["wplc_powered_by_link"] = "0"; }
328
+
329
+
330
+
331
+ /* users who are updating will stay on the existing theme */
332
+ if (get_option("WPLC_V8_FIRST_TIME")) {} else {
333
+ if (!isset($wplc_settings['wplc_newtheme'])) { $wplc_settings["wplc_newtheme"] = "theme-2"; }
334
+ }
335
+
336
+
337
+ if (!isset($wplc_settings['wplc_settings_color1'])) { $wplc_settings["wplc_settings_color1"] = "ED832F"; }
338
+ if (!isset($wplc_settings['wplc_settings_color2'])) { $wplc_settings["wplc_settings_color2"] = "FFFFFF"; }
339
+ if (!isset($wplc_settings['wplc_settings_color3'])) { $wplc_settings["wplc_settings_color3"] = "EEEEEE"; }
340
+ if (!isset($wplc_settings['wplc_settings_color4'])) { $wplc_settings["wplc_settings_color4"] = "666666"; }
341
+
342
+
343
+
344
+ if (!isset($wplc_settings['wplc_settings_align'])) { $wplc_settings["wplc_settings_align"] = 2; }
345
+
346
+ if (!isset($wplc_settings['wplc_settings_enabled'])) { $wplc_settings["wplc_settings_enabled"] = 1; }
347
+
348
+ if (!isset($wplc_settings['wplc_settings_fill'])) { $wplc_settings["wplc_settings_fill"] = "ed832f"; }
349
+
350
+ if (!isset($wplc_settings['wplc_settings_font'])) { $wplc_settings["wplc_settings_font"] = "FFFFFF"; }
351
+
352
+ if (!isset($wplc_settings['wplc_preferred_gif_provider'])) { $wplc_settings["wplc_preferred_gif_provider"] = 1; }
353
+ if (!isset($wplc_settings['wplc_giphy_api_key'])) { $wplc_settings["wplc_giphy_api_key"] = ""; }
354
+ if (!isset($wplc_settings['wplc_tenor_api_key'])) { $wplc_settings["wplc_tenor_api_key"] = ""; }
355
+
356
+ wplc_handle_db();
357
+ update_option("wplc_current_version", $wplc_version);
358
+
359
+
360
+ if (!isset($wplc_settings['wplc_require_user_info'])) { $wplc_settings['wplc_require_user_info'] = "1"; }
361
+ if (!isset($wplc_settings['wplc_user_default_visitor_name'])) {
362
+ $wplc_default_visitor_name = __( "Guest", "wplivechat" );
363
+ $wplc_settings['wplc_user_default_visitor_name'] = $wplc_default_visitor_name;
364
+ }
365
+ if (!isset($wplc_settings['wplc_loggedin_user_info'])) { $wplc_settings['wplc_loggedin_user_info'] = "1"; }
366
+ if (!isset($wplc_settings['wplc_user_alternative_text'])) {
367
+ $wplc_alt_text = __("Please click \'Start Chat\' to initiate a chat with an agent", "wplivechat");
368
+ $wplc_settings['wplc_user_alternative_text'] = $wplc_alt_text;
369
+ }
370
+ if (!isset($wplc_settings['wplc_enabled_on_mobile'])) { $wplc_settings['wplc_enabled_on_mobile'] = "1"; }
371
+ if(!isset($wplc_settings['wplc_record_ip_address'])){ $wplc_settings['wplc_record_ip_address'] = "0"; }
372
+ if(!isset($wplc_settings['wplc_enable_msg_sound'])){ $wplc_settings['wplc_enable_msg_sound'] = "1"; }
373
+ if(!isset($wplc_settings['wplc_enable_font_awesome'])){ $wplc_settings['wplc_enable_font_awesome'] = "1"; }
374
+ if(!isset($wplc_settings['wplc_using_localization_plugin'])){ $wplc_settings['wplc_using_localization_plugin'] = 0; }
375
+
376
+ $wplc_settings = apply_filters('wplc_update_settings_between_versions_hook', $wplc_settings); //Added in 8.0.09
377
+
378
+ update_option("WPLC_SETTINGS", $wplc_settings);
379
+
380
+ do_action("wplc_update_hook");
381
+ }
382
+
383
+
384
+
385
+ }
386
+
387
+ add_action("wplc_hook_set_transient","wplc_hook_control_set_transient",10);
388
+ function wplc_hook_control_set_transient() {
389
+ $should_set_transient = apply_filters("wplc_filter_control_set_transient",true);
390
+ if ($should_set_transient) {
391
+ set_transient("wplc_is_admin_logged_in", "1", 70);
392
+ }
393
+ }
394
+
395
+ add_action("wplc_hook_remove_transient","wplc_hook_control_remove_transient",10);
396
+ function wplc_hook_control_remove_transient() {
397
+ delete_transient('wplc_is_admin_logged_in');
398
+ }
399
+
400
+ function wplc_action_callback() {
401
+ global $wpdb;
402
+ global $wplc_tblname_chats;
403
+ $check = check_ajax_referer('wplc', 'security');
404
+
405
+ if ($check == 1) {
406
+
407
+ if( $_POST['action'] == 'wplc_a2a_dismiss' ){
408
+ $uid = get_current_user_id();
409
+ update_user_meta($uid, 'wplc_a2a_upsell', 1);
410
+ }
411
+
412
+ if( $_POST['action'] == 'delete_offline_message' ){
413
+
414
+ global $wplc_tblname_offline_msgs;
415
+
416
+ $mid = sanitize_text_field( $_POST['mid'] );
417
+
418
+ $sql = "DELETE FROM `$wplc_tblname_offline_msgs` WHERE `id` = '$mid'";
419
+ $query = $wpdb->Query($sql);
420
+
421
+ if( $query ){
422
+
423
+ echo 1;
424
+
425
+ }
426
+
427
+ }
428
+
429
+ if ($_POST['action'] == "wplc_user_send_offline_message") {
430
+ if(function_exists('wplc_send_offline_msg')){ wplc_send_offline_msg($_POST['name'], $_POST['email'], $_POST['msg'], $_POST['cid']); }
431
+ if(function_exists('wplc_store_offline_message')){ wplc_store_offline_message($_POST['name'], $_POST['email'], $_POST['msg']); }
432
+ do_action("wplc_hook_offline_message",array(
433
+ "cid"=>$_POST['cid'],
434
+ "name"=>$_POST['name'],
435
+ "email"=>$_POST['email'],
436
+ "url"=>get_site_url(),
437
+ "msg"=>$_POST['msg']
438
+ )
439
+ );
440
+ }
441
+ if ($_POST['action'] == "wplc_admin_set_transient") {
442
+ do_action("wplc_hook_set_transient");
443
+
444
+ }
445
+ if ($_POST['action'] == "wplc_admin_remove_transient") {
446
+ do_action("wplc_hook_remove_transient");
447
+
448
+ }
449
+ if ($_POST['action'] == 'wplc_hide_ftt') {
450
+ update_option("WPLC_FIRST_TIME_TUTORIAL",true);
451
+ }
452
+ do_action("wplc_hook_action_callback");
453
+ }
454
+ die(); // this is required to return a proper result
455
+ }
456
+
457
+
458
+
459
+ /**
460
+ * Decide who gets to see the various main menus (left navigation)
461
+ * @return array
462
+ * @since 6.0.00
463
+ * @author Nick Duncan <nick@codecabin.co.za>
464
+ */
465
+ add_filter("wplc_ma_filter_menu_control","wplc_filter_control_menu_control",10,1);
466
+ function wplc_filter_control_menu_control() {
467
+ $array = array(
468
+ 0 => 'read', /* main menu */
469
+ 1 => 'read', /* settings */
470
+ 2 => 'read', /* history */
471
+ 3 => 'read', /* missed chats */
472
+ 4 => 'read', /* offline messages */
473
+ 5 => 'read', /* feedback */
474
+ 6 => 'read' /* surveys */
475
+ );
476
+ return $array;
477
+ }
478
+
479
+ add_action('admin_init', 'wplc_metric_dashboard_redirect');
480
+ function wplc_metric_dashboard_redirect(){
481
+ try{
482
+ $cap = apply_filters("wplc_ma_filter_menu_control",array());
483
+ if(current_user_can($cap[1])){
484
+ if (isset($_GET['page'])) {
485
+ if ($_GET['page'] === 'wplivechat-menu') {
486
+ // check if we are overriding this redirect because the user pressed the "Chat now" button in the dashboard
487
+ if (isset($_GET['subaction']) && $_GET['subaction'] == 'override') { } else {
488
+ if(!isset($_COOKIE['wplcfirstsession'])) {
489
+ @setcookie("wplcfirstsession", true, time() + (60 * 10)); // 60 seconds ( 1 minute) * 20 = 20 minutes
490
+ @Header("Location: ./admin.php?page=wplivechat-menu-dashboard");
491
+ exit();
492
+ }
493
+ }
494
+
495
+ }
496
+ }
497
+ }
498
+ } catch (Exception $ex){
499
+
500
+ }
501
+ }
502
+
503
+ function wplc_admin_menu() {
504
+
505
+ $cap = apply_filters("wplc_ma_filter_menu_control",array());
506
+ if ( get_option("wplc_seen_surveys") ) { $survey_new = ""; } else { $survey_new = ' <span class="update-plugins"><span class="plugin-count">New</span></span>'; }
507
+
508
+ $wplc_current_user = get_current_user_id();
509
+
510
+ /* If user is either an agent or an admin, access the page. */
511
+ if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true ) || current_user_can("wplc_ma_agent")){
512
+ $wplc_mainpage = add_menu_page('WP Live Chat', __('Live Chat', 'wplivechat'), $cap[0], 'wplivechat-menu', 'wplc_admin_menu_layout', 'dashicons-format-chat');
513
+ add_submenu_page('wplivechat-menu', __('Dashboard', 'wplivechat'), __('Dashboard', 'wplivechat'), $cap[1], 'wplivechat-menu-dashboard', 'wplc_admin_dashboard_layout');
514
+ add_submenu_page('wplivechat-menu', __('Settings', 'wplivechat'), __('Settings', 'wplivechat'), $cap[1], 'wplivechat-menu-settings', 'wplc_admin_settings_layout');
515
+ add_submenu_page('wplivechat-menu', __('Surveys', 'wplivechat'), __('Surveys', 'wplivechat'). $survey_new, $cap[2], 'wplivechat-menu-survey', 'wplc_admin_survey_layout');
516
+ }
517
+
518
+ //Only if pro is not active
519
+ if(!function_exists("wplc_pro_reporting_page")){
520
+ add_submenu_page('wplivechat-menu', __('Reporting', 'wplivechat'), __('Reporting', 'edit_posts') . ' <span class="update-plugins"><span class="plugin-count">Pro</span></span>', $cap[0], 'wplc-basic-reporting', 'wplc_basic_reporting_page');
521
+ }
522
+
523
+
524
+ //Only if pro is not active
525
+ if(!function_exists("wplc_pro_triggers_page")){
526
+ add_submenu_page('wplivechat-menu', __('Triggers', 'wplivechat'), __('Triggers', 'edit_posts') . ' <span class="update-plugins"><span class="plugin-count">Pro</span></span>', $cap[0], 'wplc-basic-triggers', 'wplc_basic_triggers_page');
527
+ }
528
+
529
+ /* only if user is both an agent and an admin that has the cap assigned, can they access these pages */
530
+ if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true ) && current_user_can("wplc_ma_agent")){
531
+
532
+ add_submenu_page('wplivechat-menu', __('History', 'wplivechat'), __('History', 'wplivechat'), $cap[2], 'wplivechat-menu-history', 'wplc_admin_history_layout');
533
+ add_submenu_page('wplivechat-menu', __('Missed Chats', 'wplivechat'), __('Missed Chats', 'wplivechat'), $cap[3], 'wplivechat-menu-missed-chats', 'wplc_admin_missed_chats');
534
+
535
+ /* TO DO
536
+ Add a hook here so that the other plugins can add to the menu
537
+ Also make sure the function below is controled differently as the pro will not longer exist
538
+ */
539
+
540
+ if (function_exists("wplc_admin_menu_pro")) {
541
+ global $wplc_pro_version;
542
+ if (intval(str_replace(".","",$wplc_pro_version)) <= 5100) {
543
+ /* do nothing as they have the pro active and their version of the pro makes use of offline messages */
544
+
545
+ } else {
546
+ add_submenu_page('wplivechat-menu', __('Offline Messages', 'wplivechat'), __('Offline Messages', 'wplivechat'), $cap[4], 'wplivechat-menu-offline-messages', 'wplc_admin_offline_messages');
547
+ }
548
+ } else {
549
+ add_submenu_page('wplivechat-menu', __('Offline Messages', 'wplivechat'), __('Offline Messages', 'wplivechat'), $cap[4], 'wplivechat-menu-offline-messages', 'wplc_admin_offline_messages');
550
+
551
+ }
552
+ do_action("wplc_hook_menu_mid",$cap);
553
+
554
+
555
+ add_submenu_page('wplivechat-menu', __('Support', 'wplivechat'), __('Support', 'wplivechat'), 'manage_options', 'wplivechat-menu-support-page', 'wplc_support_menu');
556
+ add_submenu_page('wplivechat-menu', __('Extensions', 'wplivechat'), __('Extensions', 'wplivechat'), 'manage_options', 'wplivechat-menu-extensions-page', 'wplc_extensions_menu');
557
+ }
558
+ do_action("wplc_hook_menu");
559
+ }
560
+
561
+
562
+ add_action("wplc_hook_menu","wplc_hook_control_menu");
563
+ function wplc_hook_control_menu() {
564
+ $check = apply_filters("wplc_filter_menu_api",0);
565
+ if ($check > 0) {
566
+ add_submenu_page('wplivechat-menu', __('API Keys', 'wplivechat'), __('API Keys', 'wplivechat'), 'manage_options', 'wplivechat-menu-api-keys-page', 'wplc_api_keys_menu');
567
+ }
568
+ }
569
+
570
+
571
+ function wplc_api_keys_menu() {
572
+ $page_content = "<h1>".__("Premium Extension API Keys","wplivechat")."</h3>";
573
+ $page_content .= "<p>".__("To find and manage your premium API keys, please visit your <a target='_BLANK' href='https://wp-livechat.com/my-account/'>my account</a> page.","")."</p>";
574
+
575
+ $page_content .= "<hr />";
576
+ $page_content = apply_filters("wplc_filter_api_page",$page_content);
577
+
578
+
579
+ echo $page_content;
580
+ }
581
+
582
+
583
+ add_action("wp_head","wplc_load_user_js",0);
584
+
585
+
586
+ function wplc_load_user_js () {
587
+ if (!is_admin()) {
588
+ if (in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))) {
589
+ return false;
590
+ }
591
+
592
+
593
+ if(function_exists('wplc_display_chat_contents')){
594
+ $display_contents = wplc_display_chat_contents();
595
+ } else {
596
+ $display_contents = 1;
597
+ }
598
+
599
+ if(function_exists('wplc_is_user_banned_basic')){
600
+ $user_banned = wplc_is_user_banned_basic();
601
+ } else {
602
+ $user_banned = 0;
603
+ }
604
+ $display_contents = apply_filters("wplc_filter_display_contents",$display_contents);
605
+
606
+ if($display_contents && $user_banned == 0){
607
+
608
+ /* do not show if pro is outdated */
609
+ global $wplc_pro_version;
610
+ if (isset($wplc_pro_version)) {
611
+ $float_version = floatval($wplc_pro_version);
612
+ if ($float_version < 4 || $wplc_pro_version == "4.1.0" || $wplc_pro_version == "4.1.1") {
613
+ return;
614
+ }
615
+ }
616
+
617
+ $wplc_settings = get_option("WPLC_SETTINGS");
618
+ if (!class_exists('Mobile_Detect')) {
619
+ require_once (plugin_dir_path(__FILE__) . 'includes/Mobile_Detect.php');
620
+ }
621
+ $wplc_detect_device = new Mobile_Detect;
622
+ $wplc_is_mobile = $wplc_detect_device->isMobile();
623
+
624
+ if ($wplc_is_mobile && isset($wplc_settings['wplc_enabled_on_mobile']) && $wplc_settings['wplc_enabled_on_mobile'] == '0') {
625
+ return;
626
+ }
627
+
628
+ if (function_exists("wplc_register_pro_version")) {
629
+ if (function_exists('wplc_basic_hide_chat_when_offline')) {
630
+ $wplc_hide_chat = wplc_basic_hide_chat_when_offline();
631
+ if (!$wplc_hide_chat) {
632
+ if (function_exists("wplc_push_js_to_front_pro")) {
633
+ wplc_push_js_to_front_pro();
634
+ }
635
+ }
636
+ } else {
637
+ if (function_exists("wplc_push_js_to_front_pro")) {
638
+ wplc_push_js_to_front_pro();
639
+ }
640
+ }
641
+ } else {
642
+ wplc_push_js_to_front_basic();
643
+ }
644
+ }
645
+ }
646
+
647
+
648
+
649
+
650
+
651
+ }
652
+
653
+ function wplc_push_js_to_front_basic() {
654
+ global $wplc_is_mobile;
655
+ global $wplc_version;
656
+
657
+ wp_register_script('wplc-user-jquery-cookie', plugins_url('/js/jquery-cookie.js', __FILE__), array('jquery'),false, false);
658
+ wp_enqueue_script('wplc-user-jquery-cookie');
659
+
660
+ wp_enqueue_script('jquery');
661
+
662
+ $wplc_settings = get_option("WPLC_SETTINGS");
663
+ $wplc_acbc_data = get_option("WPLC_ACBC_SETTINGS");
664
+ $wplc_ga_enabled = get_option("WPLC_GA_SETTINGS");
665
+
666
+ if (isset($wplc_settings['wplc_display_to_loggedin_only']) && $wplc_settings['wplc_display_to_loggedin_only'] == 1) {
667
+ /* Only show to users that are logged in */
668
+ if (!is_user_logged_in()) {
669
+ return;
670
+ }
671
+ }
672
+
673
+ /* is the chat enabled? */
674
+ if ($wplc_settings["wplc_settings_enabled"] == 2) { return; }
675
+
676
+ wp_register_script('wplc-md5', plugins_url('/js/md5.js', __FILE__),array('wplc-user-script'),$wplc_version);
677
+ wp_enqueue_script('wplc-md5');
678
+ if (isset($wplc_settings['wplc_display_name']) && $wplc_settings['wplc_display_name'] == 1) {
679
+ $wplc_display = 'display';
680
+ } else {
681
+ $wplc_display = 'hide';
682
+ }
683
+
684
+
685
+ if (isset($wplc_settings['wplc_enable_msg_sound']) && intval($wplc_settings['wplc_enable_msg_sound']) == 1) { $wplc_ding = '1'; } else { $wplc_ding = '0'; }
686
+
687
+ $ajax_nonce = wp_create_nonce("wplc");
688
+ if (!function_exists("wplc_register_pro_version")) {
689
+ $ajaxurl = admin_url('admin-ajax.php');
690
+ $wplc_ajaxurl = $ajaxurl;
691
+ }
692
+
693
+
694
+ wp_register_script('wplc-server-script', plugins_url('/js/wplc_server.js', __FILE__), array('jquery'), $wplc_version);
695
+ wp_enqueue_script('wplc-server-script');
696
+
697
+ wp_localize_script( 'wplc-server-script', 'wplc_datetime_format', array(
698
+ 'date_format' => get_option( 'date_format' ),
699
+ 'time_format' => get_option( 'time_format' ),
700
+ ) );
701
+
702
+ if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
703
+ wp_localize_script('wplc-server-script', 'wplc_use_node_server', "true");
704
+
705
+ $wplc_node_token = get_option("wplc_node_server_secret_token");
706
+ if(!$wplc_node_token){
707
+ if(function_exists("wplc_node_server_token_regenerate")){
708
+ wplc_node_server_token_regenerate();
709
+ $wplc_node_token = get_option("wplc_node_server_secret_token");
710
+ }
711
+ }
712
+ wp_localize_script('wplc-server-script', 'bleeper_api_key', $wplc_node_token);
713
+
714
+
715
+
716
+ $wplc_end_point_override = get_option("wplc_end_point_override");
717
+ if($wplc_end_point_override !== false && $wplc_end_point_override !== ""){
718
+ $bleeper_url = $wplc_end_point_override; //Use the override URL
719
+ } else {
720
+ $bleeper_url = BLEEPER_NODE_SERVER_URL;
721
+ }
722
+ //wp_register_script('wplc-node-server-script', trailingslashit( $bleeper_url ) . "socket.io/socket.io.js", array('jquery'), $wplc_version);
723
+ wp_register_script('wplc-node-server-script', "https://bleeper.io/app/assets/js/vendor/socket.io/socket.io.slim.js", array('jquery'), $wplc_version);
724
+
725
+
726
+ //wp_register_script('wplc-node-server-script', 'http://localhost:3000/socket.io/socket.io.js', array('jquery'), $wplc_version);
727
+ wp_enqueue_script('wplc-node-server-script');
728
+ wp_register_script('wplc-user-events-script', plugins_url('/js/wplc_u_node_events.js', __FILE__),array('jquery', 'wplc-server-script'),$wplc_version);
729
+
730
+ wp_localize_script('wplc-server-script', 'bleeper_override_upload_url', rest_url( 'wp_live_chat_support/v1/remote_upload' ) );
731
+
732
+ /** DEPRECATED BY GDPR */
733
+ /*if(isset($wplc_settings['wplc_record_ip_address']) && $wplc_settings['wplc_record_ip_address'] == 1) {
734
+ $ip_address = false;
735
+ if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != '') { $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip_address = $_SERVER['REMOTE_ADDR']; }
736
+
737
+ if($ip_address !== false){
738
+ wp_localize_script('wplc-server-script', 'bleeper_user_ip_address', $ip_address);
739
+ }
740
+ }*/
741
+
742
+ $wplc_server_location = get_option( "wplc_server_location" );
743
+ $wplc_server_location = apply_filters('wplc_node_server_default_selection_override', $wplc_server_location, $wplc_settings);
744
+
745
+ if( $wplc_server_location !== false && $wplc_server_location !== "" && $wplc_server_location !== "auto" ){
746
+ if ( $wplc_server_location === "us1") { $wplc_server_location = "0"; }
747
+ else if ( $wplc_server_location === "us2") { $wplc_server_location = "3"; }
748
+ else if ( $wplc_server_location === "eu1") { $wplc_server_location = "1"; }
749
+ else if ( $wplc_server_location === "eu2") { $wplc_server_location = "2"; }
750
+ else { $wplc_server_location = "0"; }
751
+ wp_localize_script( 'wplc-server-script', 'bleeper_server_location', $wplc_server_location );
752
+ }
753
+
754
+
755
+ $wplc_end_point_override = get_option("wplc_end_point_override");
756
+ if($wplc_end_point_override !== false && $wplc_end_point_override !== ""){
757
+ wp_localize_script( 'wplc-server-script', 'bleeper_end_point_override', $wplc_end_point_override );
758
+ }
759
+ //For node verification
760
+ if(function_exists("wplc_pro_activate")){
761
+ wp_localize_script('wplc-server-script', 'bleeper_pro_auth', get_option('wp-live-chat-support-pro_key', "false"));
762
+ } else {
763
+ wp_localize_script('wplc-server-script', 'bleeper_pro_auth', 'false');
764
+ }
765
+
766
+
767
+
768
+ //Emoji Libs
769
+ if(empty($wplc_settings['wplc_disable_emojis'])) {
770
+ //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);
771
+ //wp_enqueue_script('wplc-user-js-emoji');
772
+ //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);
773
+ //wp_enqueue_script('wplc-user-js-emoji-bundle');
774
+
775
+ 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);
776
+ wp_enqueue_script('wplc-user-js-emoji-concat');
777
+
778
+ wp_register_style( 'wplc-admin-style-emoji', "https://bleeper.io/app/assets/wdt-emoji/wdt-emoji-bundle.css", false, $wplc_version );
779
+ wp_enqueue_style( 'wplc-admin-style-emoji' );
780
+ }
781
+
782
+ } else {
783
+ /* not using the node server, load traditional event handler JS */
784
+ wp_register_script('wplc-user-events-script', plugins_url('/js/wplc_u_events.js', __FILE__),array('jquery', 'wplc-server-script'),$wplc_version);
785
+ }
786
+
787
+
788
+
789
+
790
+ wp_register_script('wplc-user-script', plugins_url('/js/wplc_u.js', __FILE__),array('jquery', 'wplc-server-script'),$wplc_version);
791
+
792
+
793
+ /**
794
+ * No longer in use as of 6.2.11 as using the minified file causes issues on sites that are minified.
795
+ * @deprecated 6.2.11
796
+ */
797
+ // wp_register_script('wplc-user-script', plugins_url('/js/wplc_u.min.js', __FILE__),array('jquery'),$wplc_version);
798
+
799
+ wp_enqueue_script('wplc-user-script');
800
+ wp_enqueue_script('wplc-user-events-script');
801
+
802
+ if (isset($wplc_settings['wplc_newtheme'])) { $wplc_newtheme = $wplc_settings['wplc_newtheme']; } else { $wplc_newtheme = "theme-2"; }
803
+ if (isset($wplc_newtheme)) {
804
+ if($wplc_newtheme == 'theme-1') {
805
+ wp_register_script('wplc-theme-classic', plugins_url('/js/themes/classic.js', __FILE__),array('wplc-user-script'),$wplc_version);
806
+ wp_enqueue_script('wplc-theme-classic');
807
+ $avatars = wplc_all_avatars();
808
+ wp_localize_script('wplc-theme-classic', 'wplc_user_avatars', $avatars);
809
+
810
+ }
811
+ else if($wplc_newtheme == 'theme-2') {
812
+ wp_register_script('wplc-theme-modern', plugins_url('/js/themes/modern.js', __FILE__),array('wplc-user-script'),$wplc_version);
813
+ wp_enqueue_script('wplc-theme-modern');
814
+ $avatars = wplc_all_avatars();
815
+ wp_localize_script('wplc-theme-modern', 'wplc_user_avatars', $avatars);
816
+ }
817
+ } else {
818
+ wp_register_script('wplc-theme-classic', plugins_url('/js/themes/classic.js', __FILE__),array('wplc-user-script'),$wplc_version);
819
+ wp_enqueue_script('wplc-theme-classic');
820
+ $avatars = wplc_all_avatars();
821
+ wp_localize_script('wplc-theme-classic', 'wplc_user_avatars', $avatars);
822
+ }
823
+
824
+ $ajax_url = admin_url('admin-ajax.php');
825
+ $home_ajax_url = $ajax_url;
826
+
827
+ $wplc_ajax_url = apply_filters("wplc_filter_ajax_url",$ajax_url);
828
+ wp_localize_script('wplc-admin-chat-js', 'wplc_ajaxurl', $wplc_ajax_url);
829
+ wp_localize_script('wplc-ma-js', 'wplc_home_ajaxurl', $home_ajax_url);
830
+
831
+ //Added rest security nonces
832
+ if(class_exists("WP_REST_Request")) {
833
+ wp_localize_script('wplc-user-script', 'wplc_restapi_enabled', '1');
834
+ wp_localize_script('wplc-user-script', 'wplc_restapi_token', get_option('wplc_api_secret_token'));
835
+ wp_localize_script('wplc-user-script', 'wplc_restapi_endpoint', rest_url('wp_live_chat_support/v1'));
836
+ wp_localize_script('wplc-user-script', 'wplc_restapi_nonce', wp_create_nonce( 'wp_rest' ));
837
+ } else {
838
+ wp_localize_script('wplc-user-script', 'wplc_restapi_enabled', '0');
839
+ wp_localize_script('wplc-user-script', 'wplc_restapi_nonce', "false");
840
+ }
841
+
842
+
843
+ if (isset($wplc_ga_enabled['wplc_enable_ga']) && $wplc_ga_enabled['wplc_enable_ga'] == '1') {
844
+ wp_localize_script('wplc-user-script', 'wplc_enable_ga', '1');
845
+ }
846
+
847
+ $wplc_ding_file = apply_filters( 'wplc_filter_message_sound', '' );
848
+ if ( ! empty( $wplc_ding_file ) ) {
849
+ wp_localize_script( 'wplc-user-script', 'bleeper_message_override', $wplc_ding_file );
850
+ }
851
+
852
+ $wplc_detect_device = new Mobile_Detect;
853
+ $wplc_is_mobile = $wplc_detect_device->isMobile() ? 'true' : 'false';
854
+ wp_localize_script('wplc-user-script', 'wplc_is_mobile', $wplc_is_mobile);
855
+
856
+
857
+ wp_localize_script('wplc-user-script', 'wplc_ajaxurl', $wplc_ajax_url);
858
+ wp_localize_script('wplc-user-script', 'wplc_ajaxurl_site', admin_url('admin-ajax.php'));
859
+ wp_localize_script('wplc-user-script', 'wplc_nonce', $ajax_nonce);
860
+ wp_localize_script('wplc-user-script', 'wplc_plugin_url', WPLC_BASIC_PLUGIN_URL);
861
+
862
+ $wplc_display = false;
863
+
864
+ $wplc_images = apply_filters( 'wplc_get_images_to_preload', array(), $wplc_acbc_data );
865
+ wp_localize_script( 'wplc-user-script', 'wplc_preload_images', $wplc_images );
866
+
867
+
868
+
869
+
870
+ if( isset($wplc_settings['wplc_show_name']) && $wplc_settings['wplc_show_name'] == '1' ){ $wplc_show_name = true; } else { $wplc_show_name = false; }
871
+ if( isset($wplc_settings['wplc_show_avatar']) && $wplc_settings['wplc_show_avatar'] ){ $wplc_show_avatar = true; } else { $wplc_show_avatar = false; }
872
+ if( isset($wplc_settings['wplc_show_date']) && $wplc_settings['wplc_show_date'] == '1' ){ $wplc_show_date = true; } else { $wplc_show_date = false; }
873
+ if( isset($wplc_settings['wplc_show_time']) && $wplc_settings['wplc_show_time'] == '1' ){ $wplc_show_time = true; } else { $wplc_show_time = false; }
874
+
875
+ $wplc_chat_detail = array( 'name' => $wplc_show_name, 'avatar' => $wplc_show_avatar, 'date' => $wplc_show_date, 'time' => $wplc_show_time );
876
+
877
+
878
+
879
+ if( $wplc_display !== FALSE && $wplc_display !== 'hide' ){
880
+ wp_localize_script('wplc-user-script', 'wplc_display_name', $wplc_display);
881
+ } else {
882
+ wp_localize_script( 'wplc-user-script', 'wplc_show_chat_detail', $wplc_chat_detail );
883
+ }
884
+
885
+
886
+
887
+ /**
888
+ * Create a JS object for all Agent ID's and Gravatar MD5's
889
+ */
890
+ $user_array = get_users(array(
891
+ 'meta_key' => 'wplc_ma_agent',
892
+ ));
893
+
894
+ $a_array = array();
895
+ if ($user_array) {
896
+ foreach ($user_array as $user) {
897
+ $a_array[$user->ID] = array();
898
+ $a_array[$user->ID]['name'] = apply_filters( "wplc_decide_agents_name", $user->display_name, $wplc_acbc_data );
899
+ $a_array[$user->ID]['md5'] = md5( $user->user_email );
900
+ }
901
+ }
902
+ wp_localize_script('wplc-user-script', 'wplc_agent_data', $a_array);
903
+
904
+
905
+ $wplc_error_messages = array(
906
+ 'valid_name' => __( "Please enter your name", "wplivechat" ),
907
+ 'valid_email' => __( "Please enter your email address", "wplivechat" ),
908
+ 'server_connection_lost' => __("Connection to server lost. Please reload this page. Error: ", "wplivechat"),
909
+ 'chat_ended_by_operator' => ( empty( $wplc_settings['wplc_text_chat_ended'] ) ) ? __("The chat has been ended by the operator.", "wplivechat") : esc_attr( $wplc_settings['wplc_text_chat_ended'] ) ,
910
+ 'empty_message' => __( "Please enter a message", "wplivechat" ),
911
+ 'disconnected_message' => __("Disconnected, attempting to reconnect...", "wplivechat"),
912
+ );
913
+
914
+ $wplc_error_messages = apply_filters( "wplc_user_error_messages_filter", $wplc_error_messages );
915
+
916
+ wp_localize_script('wplc-user-script', 'wplc_error_messages', $wplc_error_messages);
917
+ wp_localize_script('wplc-user-script', 'wplc_enable_ding', $wplc_ding);
918
+ $wplc_run_override = "0";
919
+ $wplc_run_override = apply_filters("wplc_filter_run_override",$wplc_run_override);
920
+ wp_localize_script('wplc-user-script', 'wplc_filter_run_override', $wplc_run_override);
921
+
922
+ if (!isset($wplc_settings['wplc_pro_offline1'])) { $wplc_settings["wplc_pro_offline1"] = __("We are currently offline. Please leave a message and we'll get back to you shortly.", "wplivechat"); }
923
+ if (!isset($wplc_settings['wplc_pro_offline2'])) { $wplc_settings["wplc_pro_offline2"] = __("Sending message...", "wplivechat"); }
924
+ if (!isset($wplc_settings['wplc_pro_offline3'])) { $wplc_settings["wplc_pro_offline3"] = __("Thank you for your message. We will be in contact soon.", "wplivechat"); }
925
+
926
+
927
+ wp_localize_script('wplc-user-script', 'wplc_offline_msg', __(stripslashes($wplc_settings['wplc_pro_offline2']), 'wplivechat'));
928
+ wp_localize_script('wplc-user-script', 'wplc_offline_msg3',__(stripslashes($wplc_settings['wplc_pro_offline3']), 'wplivechat'));
929
+ wp_localize_script('wplc-user-script', 'wplc_welcome_msg', __(stripslashes($wplc_settings['wplc_welcome_msg']), 'wplivechat'));
930
+ wp_localize_script('wplc-user-script', 'wplc_pro_sst1', __(stripslashes($wplc_settings['wplc_pro_sst1']), 'wplivechat') );
931
+ wp_localize_script('wplc-user-script', 'wplc_pro_offline_btn_send', __(stripslashes($wplc_settings['wplc_pro_offline_btn_send']), 'wplivechat') );
932
+ wp_localize_script('wplc-user-script', 'wplc_user_default_visitor_name', __(stripslashes($wplc_settings['wplc_user_default_visitor_name']), 'wplivechat') );
933
+
934
+ if( isset( $wplc_acbc_data['wplc_use_wp_name'] ) && $wplc_acbc_data['wplc_use_wp_name'] == '1' ){
935
+ if( isset( $_COOKIE['wplc_cid'] ) ){
936
+ $chat_data = wplc_get_chat_data( $_COOKIE['wplc_cid'] );
937
+ if ( isset($chat_data->agent_id ) ) {
938
+ $user_info = get_userdata( intval( $chat_data->agent_id ) );
939
+ if( $user_info ){
940
+ $agent = $user_info->display_name;
941
+ } else {
942
+ $agent = "agent";
943
+ }
944
+ } else {
945
+ $agent = 'agent';
946
+ }
947
+ } else {
948
+ $agent = 'agent';
949
+ }
950
+
951
+ } else {
952
+ if (!empty($wplc_acbc_data['wplc_chat_name'])) {
953
+ $agent = $wplc_acbc_data['wplc_chat_name'];
954
+ } else {
955
+ $agent = 'agent';
956
+ }
957
+ }
958
+ wp_localize_script('wplc-user-script', 'wplc_localized_string_is_typing', $agent . __(" is typing...","wplivechat"));
959
+ wp_localize_script('wplc-user-script', 'wplc_localized_string_is_typing_single', __(" is typing...","wplivechat"));
960
+
961
+ $bleeper_string_array = array(
962
+ __(" has joined.","wplivechat"),
963
+ __(" has left.","wplivechat"),
964
+ __(" has ended the chat.", "wplivechat"),
965
+ __(" has disconnected.", "wplivechat"),
966
+ __("(edited)", "wplivechat"),
967
+ __("Type here","wplivechat")
968
+ );
969
+
970
+ wp_localize_script('wplc-user-script', 'bleeper_localized_strings', $bleeper_string_array );
971
+
972
+ if( isset( $wplc_settings['wplc_elem_trigger_id'] ) && trim( $wplc_settings['wplc_elem_trigger_id'] ) !== "" ) {
973
+ if( isset( $wplc_settings['wplc_elem_trigger_action'] ) ){
974
+ wp_localize_script( 'wplc-user-script', 'wplc_elem_trigger_action', stripslashes( $wplc_settings['wplc_elem_trigger_action'] ) );
975
+ }
976
+ if( isset( $wplc_settings['wplc_elem_trigger_type'] ) ){
977
+ wp_localize_script( 'wplc-user-script', 'wplc_elem_trigger_type', stripslashes( $wplc_settings['wplc_elem_trigger_type'] ) );
978
+ }
979
+ wp_localize_script( 'wplc-user-script', 'wplc_elem_trigger_id', stripslashes( $wplc_settings['wplc_elem_trigger_id'] ) );
980
+ }
981
+
982
+ $extra_data_array = array("object_switch" => true);
983
+ $extra_data_array = apply_filters("wplc_filter_front_js_extra_data",$extra_data_array);
984
+ wp_localize_script('wplc-user-script', 'wplc_extra_data',$extra_data_array);
985
+
986
+
987
+ if (isset($_COOKIE['wplc_email']) && $_COOKIE['wplc_email'] != "") { $wplc_user_gravatar = sanitize_text_field(md5(strtolower(trim($_COOKIE['wplc_email'])))); } else {$wplc_user_gravatar = ""; }
988
+
989
+ if ($wplc_user_gravatar != "") { $wplc_grav_image = "<img src='//www.gravatar.com/avatar/$wplc_user_gravatar?s=30' class='wplc-user-message-avatar' />";} else { $wplc_grav_image = "";}
990
+
991
+ if ( ! empty( $wplc_grav_image ) ) {
992
+ wp_localize_script('wplc-user-script', 'wplc_gravatar_image', $wplc_grav_image);
993
+ }
994
+
995
+ $wplc_hide_chat = "";
996
+ if (get_option('WPLC_HIDE_CHAT') == TRUE) { $wplc_hide_chat = "yes"; } else { $wplc_hide_chat = null; }
997
+ wp_localize_script('wplc-user-script', 'wplc_hide_chat', $wplc_hide_chat);
998
+
999
+ if(isset($wplc_settings['wplc_redirect_to_thank_you_page']) && isset($wplc_settings['wplc_redirect_thank_you_url']) && $wplc_settings['wplc_redirect_thank_you_url'] !== "" && $wplc_settings['wplc_redirect_thank_you_url'] !== " "){
1000
+ wp_localize_script('wplc-user-script', 'wplc_redirect_thank_you', urldecode($wplc_settings['wplc_redirect_thank_you_url']));
1001
+ }
1002
+
1003
+ wp_enqueue_script('jquery-ui-core',false,array('wplc-user-script'),false,false);
1004
+ wp_enqueue_script('jquery-ui-draggable',false,array('wplc-user-script'),false,false);
1005
+
1006
+ do_action("wplc_hook_push_js_to_front");
1007
+
1008
+ }
1009
+ if (function_exists('wplc_pro_user_top_js')) {
1010
+ add_action('wp_head', 'wplc_pro_user_top_js');
1011
+
1012
+ } else {
1013
+ add_action('wp_head', 'wplc_user_top_js');
1014
+
1015
+ }
1016
+
1017
+
1018
+
1019
+ /**
1020
+ * Add to the array to determine which images need to be preloaded via JS on the front end.
1021
+ *
1022
+ * @param array $images Array of images to be preloaded
1023
+ * @return array
1024
+ */
1025
+ add_filter( "wplc_get_images_to_preload", "wplc_filter_control_get_images_to_preload", 10, 2 );
1026
+ function wplc_filter_control_get_images_to_preload( $images, $wplc_acbc_data ) {
1027
+ $icon = plugins_url('images/iconRetina.png', __FILE__);
1028
+ $close_icon = plugins_url('images/iconCloseRetina.png', __FILE__);
1029
+ array_push( $images, $icon );
1030
+ array_push( $images, $close_icon );
1031
+ return $images;
1032
+ }
1033
+
1034
+
1035
+
1036
+ function wplc_user_top_js() {
1037
+
1038
+ if(function_exists('wplc_display_chat_contents')){
1039
+ $display_contents = wplc_display_chat_contents();
1040
+ } else {
1041
+ $display_contents = 1;
1042
+ }
1043
+ if($display_contents >= 1){
1044
+ /*echo "<!-- DEFINING DO NOT CACHE -->";
1045
+ if (!defined('DONOTCACHEPAGE')) {
1046
+ define('DONOTCACHEPAGE', true);
1047
+ }
1048
+ if (!defined('DONOTCACHEDB')) {
1049
+ define('DONOTCACHEDB', true);
1050
+ }
1051
+ */
1052
+ $ajax_nonce = wp_create_nonce("wplc");
1053
+ $wplc_settings = get_option("WPLC_SETTINGS");
1054
+ $ajax_url = admin_url('admin-ajax.php');
1055
+ $wplc_ajax_url = apply_filters("wplc_filter_ajax_url",$ajax_url);
1056
+ ?>
1057
+
1058
+ <script type="text/javascript">
1059
+ <?php if (!function_exists("wplc_register_pro_version")) { ?>
1060
+ var wplc_ajaxurl = '<?php echo $wplc_ajax_url; ?>';
1061
+ <?php } ?>
1062
+ var wplc_nonce = '<?php echo $ajax_nonce; ?>';
1063
+ </script>
1064
+
1065
+
1066
+
1067
+
1068
+ <?php
1069
+
1070
+ $wplc_settings = get_option('WPLC_SETTINGS');
1071
+ if (isset($wplc_settings['wplc_theme'])) { $wplc_theme = $wplc_settings['wplc_theme']; } else { $wplc_theme = "theme-default"; }
1072
+ if (isset($wplc_theme)) {
1073
+
1074
+ if($wplc_theme == 'theme-6') {
1075
+ /* custom */
1076
+
1077
+ if (isset($wplc_settings["wplc_settings_color1"])) { $wplc_settings_color1 = $wplc_settings["wplc_settings_color1"]; } else { $wplc_settings_color1 = "ED832F"; }
1078
+ if (isset($wplc_settings["wplc_settings_color2"])) { $wplc_settings_color2 = $wplc_settings["wplc_settings_color2"]; } else { $wplc_settings_color2 = "FFFFFF"; }
1079
+ if (isset($wplc_settings["wplc_settings_color3"])) { $wplc_settings_color3 = $wplc_settings["wplc_settings_color3"]; } else { $wplc_settings_color3 = "EEEEEE"; }
1080
+ if (isset($wplc_settings["wplc_settings_color4"])) { $wplc_settings_color4 = $wplc_settings["wplc_settings_color4"]; } else { $wplc_settings_color4 = "666666"; }
1081
+
1082
+
1083
+ ?>
1084
+ <style>
1085
+ .wplc-color-1 { color: #<?php echo $wplc_settings_color1; ?> !important; }
1086
+ .wplc-color-2 { color: #<?php echo $wplc_settings_color2; ?> !important; }
1087
+ .wplc-color-3 { color: #<?php echo $wplc_settings_color3; ?> !important; }
1088
+ .wplc-color-4 { color: #<?php echo $wplc_settings_color4; ?> !important; }
1089
+ .wplc-color-bg-1 { background-color: #<?php echo $wplc_settings_color1; ?> !important; }
1090
+ .wplc-color-bg-2 { background-color: #<?php echo $wplc_settings_color2; ?> !important; }
1091
+ .wplc-color-bg-3 { background-color: #<?php echo $wplc_settings_color3; ?> !important; }
1092
+ .wplc-color-bg-4 { background-color: #<?php echo $wplc_settings_color4; ?> !important; }
1093
+ .wplc-color-border-1 { border-color: #<?php echo $wplc_settings_color1; ?> !important; }
1094
+ .wplc-color-border-2 { border-color: #<?php echo $wplc_settings_color2; ?> !important; }
1095
+ .wplc-color-border-3 { border-color: #<?php echo $wplc_settings_color3; ?> !important; }
1096
+ .wplc-color-border-4 { border-color: #<?php echo $wplc_settings_color4; ?> !important; }
1097
+ .wplc-color-border-1:before { border-color: transparent #<?php echo $wplc_settings_color1; ?> !important; }
1098
+ .wplc-color-border-2:before { border-color: transparent #<?php echo $wplc_settings_color2; ?> !important; }
1099
+ .wplc-color-border-3:before { border-color: transparent #<?php echo $wplc_settings_color3; ?> !important; }
1100
+ .wplc-color-border-4:before { border-color: transparent #<?php echo $wplc_settings_color4; ?> !important; }
1101
+ </style>
1102
+
1103
+ <?php
1104
+
1105
+
1106
+ }
1107
+ }
1108
+
1109
+
1110
+ }
1111
+ }
1112
+
1113
+
1114
+
1115
+
1116
+ /**
1117
+ * Detect if the user is using blocked in the live chat settings 'blocked IP' section
1118
+ * @return void
1119
+ * @since 6.0.00
1120
+ * @author Nick Duncan <nick@codecabin.co.za>
1121
+ */
1122
+ function wplc_hook_control_banned_users() {
1123
+ if (function_exists('wplc_is_user_banned_basic')){
1124
+ $user_banned = wplc_is_user_banned_basic();
1125
+ } else {
1126
+ $user_banned = 0;
1127
+ }
1128
+ if ($user_banned) {
1129
+ remove_action("wplc_hook_output_box_body","wplc_hook_control_show_chat_box");
1130
+ remove_action("wplc_hook_output_box_footer","wplc_action_control_hook_output_box_footer");
1131
+ }
1132
+ }
1133
+
1134
+ /**
1135
+ * Detect if the user is using a mobile phone or not and decides to show the chat box depending on the admins settings
1136
+ * @return void
1137
+ * @since 6.0.00
1138
+ * @author Nick Duncan <nick@codecabin.co.za>
1139
+ */
1140
+ function wplc_hook_control_check_mobile() {
1141
+ $wplc_settings = get_option("WPLC_SETTINGS");
1142
+
1143
+ $draw_box = false;
1144
+
1145
+ if (!class_exists('Mobile_Detect')) {
1146
+ require_once (plugin_dir_path(__FILE__) . 'includes/Mobile_Detect.php');
1147
+ }
1148
+
1149
+ $wplc_detect_device = new Mobile_Detect;
1150
+ $wplc_is_mobile = $wplc_detect_device->isMobile();
1151
+
1152
+ if ($wplc_is_mobile && !isset($wplc_settings['wplc_enabled_on_mobile']) && $wplc_settings['wplc_enabled_on_mobile'] != 1) {
1153
+ return "";
1154
+ }
1155
+
1156
+ if (function_exists('wplc_basic_hide_chat_when_offline')) {
1157
+ $wplc_hide_chat = wplc_basic_hide_chat_when_offline();
1158
+ if (!$wplc_hide_chat) {
1159
+ $draw_box = true;
1160
+ }
1161
+ } else {
1162
+ $draw_box = true;
1163
+ }
1164
+ if (!$draw_box) {
1165
+ remove_action("wplc_hook_output_box_body","wplc_hook_control_show_chat_box");
1166
+ remove_action("wplc_hook_output_box_footer","wplc_action_control_hook_output_box_footer");
1167
+ }
1168
+
1169
+ }
1170
+
1171
+
1172
+ add_action("wplc_hook_output_box_footer","wplc_action_control_hook_output_box_footer",10,1);
1173
+ function wplc_action_control_hook_output_box_footer() {
1174
+ /* nothing here */
1175
+ }
1176
+
1177
+ /**
1178
+ * Decides whether or not to show the chat box based on the main setting in the settings page
1179
+ * @return void
1180
+ * @since 6.0.00
1181
+ */
1182
+ function wplc_hook_control_is_chat_enabled() {
1183
+ $wplc_settings = get_option("WPLC_SETTINGS");
1184
+ if ($wplc_settings["wplc_settings_enabled"] == 2) {
1185
+ remove_action("wplc_hook_output_box_body","wplc_hook_control_show_chat_box");
1186
+ remove_action("wplc_hook_output_box_footer","wplc_action_control_hook_output_box_footer");
1187
+ }
1188
+ }
1189
+
1190
+ /**
1191
+ * Backwards compatibility for the control of the chat box
1192
+ * @return string
1193
+ * @since 6.0.00
1194
+ * @author Nick Duncan - nick@codecabin.co.za
1195
+ */
1196
+ function wplc_hook_control_show_chat_box($cid) {
1197
+ if (function_exists("wplc_pro_version_control")) {
1198
+ global $wplc_pro_version;
1199
+ if (intval(str_replace(".","",$wplc_pro_version)) < 5100) {
1200
+
1201
+ echo wplc_output_box_ajax();
1202
+
1203
+ } else {
1204
+ echo wplc_output_box_ajax_new($cid);
1205
+ }
1206
+ } else {
1207
+ echo wplc_output_box_ajax_new($cid);
1208
+
1209
+ }
1210
+
1211
+ }
1212
+
1213
+ /* basic */
1214
+ add_action("wplc_hook_output_box_header","wplc_hook_control_banned_users");
1215
+ add_action("wplc_hook_output_box_header","wplc_hook_control_check_mobile");
1216
+ add_action("wplc_hook_output_box_header","wplc_hook_control_is_chat_enabled");
1217
+
1218
+ add_action("wplc_hook_output_box_body","wplc_hook_control_show_chat_box",10,1);
1219
+
1220
+ /**
1221
+ * Build the chat box
1222
+ * @return void
1223
+ * @since 6.0.00
1224
+ * @author Nick Duncan <nick@codecabin.co.za>
1225
+ */
1226
+ function wplc_output_box_5100($cid = null) {
1227
+ wplc_string_check();
1228
+ do_action("wplc_hook_output_box_header",$cid);
1229
+ do_action("wplc_hook_output_box_body",$cid);
1230
+ do_action("wplc_hook_output_box_footer",$cid);
1231
+ }
1232
+
1233
+
1234
+
1235
+ /**
1236
+ * Filter to control the top MAIN DIV of the chat box
1237
+ * @param array $wplc_settings Live chat settings array
1238
+ * @return string
1239
+ * @since 6.0.00
1240
+ * @author Nick Duncan <nick@codecabin.co.za>
1241
+ */
1242
+ function wplc_filter_control_live_chat_box_html_main_div_top($wplc_settings,$logged_in,$wplc_using_locale) {
1243
+ $ret_msg = "";
1244
+ $wplc_class = "";
1245
+ // $wplc_settings = get_option("WPLC_SETTINGS");
1246
+
1247
+ if ($wplc_settings["wplc_settings_align"] == 1) {
1248
+ $original_pos = "bottom_left";
1249
+ } else if ($wplc_settings["wplc_settings_align"] == 2) {
1250
+ $original_pos = "bottom_right";
1251
+ } else if ($wplc_settings["wplc_settings_align"] == 3) {
1252
+ $original_pos = "left";
1253
+ $wplc_class = "wplc_left";
1254
+ } else if ($wplc_settings["wplc_settings_align"] == 4) {
1255
+ $original_pos = "right";
1256
+ $wplc_class = "wplc_right";
1257
+ }
1258
+
1259
+
1260
+ $animations = wplc_return_animations_basic();
1261
+ if ($animations) {
1262
+ isset($animations['animation']) ? $wplc_animation = $animations['animation'] : $wplc_animation = 'animation-4';
1263
+ isset($animations['starting_point']) ? $wplc_starting_point = $animations['starting_point'] : $wplc_starting_point = 'display: none;';
1264
+ isset($animations['box_align']) ? $wplc_box_align = $animations['box_align'] : $wplc_box_align = '';
1265
+ }
1266
+ else {
1267
+
1268
+ if ($wplc_settings["wplc_settings_align"] == 1) {
1269
+ $original_pos = "bottom_left";
1270
+ $wplc_box_align = "left:20px; bottom:0px;";
1271
+ } else if ($wplc_settings["wplc_settings_align"] == 2) {
1272
+ $original_pos = "bottom_right";
1273
+ $wplc_box_align = "right:20px; bottom:0px;";
1274
+ } else if ($wplc_settings["wplc_settings_align"] == 3) {
1275
+ $original_pos = "left";
1276
+ $wplc_box_align = "left:0; bottom:100px;";
1277
+ $wplc_class = "wplc_left";
1278
+ } else if ($wplc_settings["wplc_settings_align"] == 4) {
1279
+ $original_pos = "right";
1280
+ $wplc_box_align = "right:0; bottom:100px;";
1281
+ $wplc_class = "wplc_right";
1282
+ }
1283
+ }
1284
+
1285
+
1286
+ $wplc_extra_attr = apply_filters("wplc_filter_chat_header_extra_attr","");
1287
+ if (isset($wplc_settings['wplc_newtheme'])) { $wplc_newtheme = $wplc_settings['wplc_newtheme']; } else { $wplc_newtheme = "theme-2"; }
1288
+ if (isset($wplc_newtheme)) {
1289
+ if($wplc_newtheme == 'theme-1') { $wplc_theme_type = "classic"; }
1290
+ else if($wplc_newtheme == 'theme-2') { $wplc_theme_type = "modern"; }
1291
+ else { $wplc_theme_type = "modern"; }
1292
+ }
1293
+
1294
+ if(!isset($wplc_settings['wplc_newtheme'])){ $wplc_settings['wplc_newtheme'] = "theme-2"; }
1295
+ if (isset($wplc_settings['wplc_newtheme']) && $wplc_settings['wplc_newtheme'] == "theme-2") {
1296
+ $hovercard_content = "<div class='wplc_hovercard_content_left'>".apply_filters("wplc_filter_modern_theme_hovercard_content_left","")."</div><div class='wplc_hovercard_content_right'>".apply_filters("wplc_filter_live_chat_box_html_1st_layer",wplc_filter_control_live_chat_box_html_1st_layer($wplc_settings,$logged_in,$wplc_using_locale,'wplc-color-4'))."</div>";
1297
+ $hovercard_content = apply_filters("wplc_filter_hovercard_content", $hovercard_content);
1298
+
1299
+ $ret_msg .= "<div id='wplc_hovercard' style='display:none' class='".$wplc_theme_type."'>";
1300
+ //$ret_msg .= "<div id='wplc_hovercard_min' class='wplc_button_standard wplc-color-border-1 wplc-color-bg-1'>".stripslashes( $wplc_settings['wplc_close_btn_text'] )."</div>";
1301
+ $ret_msg .= "<div id='wplc_hovercard_content'>".apply_filters("wplc_filter_live_chat_box_pre_layer1","").$hovercard_content."</div>";
1302
+ $ret_msg .= "<div id='wplc_hovercard_bottom'>".apply_filters("wplc_filter_hovercard_bottom_before","").apply_filters("wplc_filter_live_chat_box_hover_html_start_chat_button","",$wplc_settings,$logged_in,$wplc_using_locale)."</div>";
1303
+ $ret_msg .= "</div>";
1304
+
1305
+ } else if (isset($wplc_settings['wplc_newtheme']) && $wplc_settings['wplc_newtheme'] == "theme-1"){
1306
+ $hovercard_content = "<div class='wplc_hovercard_content_right'>".apply_filters("wplc_filter_live_chat_box_html_1st_layer",wplc_filter_control_live_chat_box_html_1st_layer($wplc_settings,$logged_in,$wplc_using_locale, "wplc-color-2"))."</div>";
1307
+ $hovercard_content = apply_filters("wplc_filter_hovercard_content", $hovercard_content);
1308
+
1309
+ $ret_msg .= "<div id='wplc_hovercard' style='display:none' class='".$wplc_theme_type."'>";
1310
+ //$ret_msg .= "<div id='wplc_hovercard_min' class='wplc_button_standard wplc-color-border-1 wplc-color-bg-1'>".__("close", "wplivechat")."</div>";
1311
+ $ret_msg .= "<div id='wplc_hovercard_content'>".apply_filters("wplc_filter_live_chat_box_pre_layer1","").$hovercard_content."</div>";
1312
+ $ret_msg .= "<div id='wplc_hovercard_bottom'>".apply_filters("wplc_filter_hovercard_bottom_before","").apply_filters("wplc_filter_live_chat_box_hover_html_start_chat_button","",$wplc_settings,$logged_in,$wplc_using_locale)."</div>";
1313
+ $ret_msg .= "</div>";
1314
+ }
1315
+
1316
+ $ret_msg .= "<div id=\"wp-live-chat\" wplc_animation=\"".$wplc_animation."\" style=\"".$wplc_starting_point." ".$wplc_box_align.";\" class=\"".$wplc_theme_type." ".$wplc_class." wplc_close\" original_pos=\"".$original_pos."\" ".$wplc_extra_attr." > ";
1317
+ return $ret_msg;
1318
+ }
1319
+
1320
+
1321
+
1322
+ add_filter("wplc_filter_modern_theme_hovercard_content_left","wplc_filter_control_modern_theme_hovercard_content_left",10,1);
1323
+ function wplc_filter_control_modern_theme_hovercard_content_left($msg) {
1324
+
1325
+ $msg .= "<div class='wplc_left_logo' style='background:url(".plugins_url('images/iconmicro.png', __FILE__).") no-repeat; background-size: cover;'></div>";
1326
+ $msg = apply_filters("wplc_filter_microicon",$msg);
1327
+ return $msg;
1328
+ }
1329
+
1330
+ /**
1331
+ * Filter to control the top HEADER DIV of the chat box
1332
+ * @param array $wplc_settings Live chat settings array
1333
+ * @return string
1334
+ * @since 6.0.00
1335
+ * @author Nick Duncan <nick@codecabin.co.za>
1336
+ */
1337
+ function wplc_filter_control_live_chat_box_html_header_div_top($wplc_settings) {
1338
+
1339
+ $ret_msg = "";
1340
+
1341
+ $current_theme = isset($wplc_settings['wplc_newtheme']) ? $wplc_settings['wplc_newtheme'] : "theme-2";
1342
+ if($current_theme === "theme-1"){
1343
+ $ret_msg .= apply_filters("wplc_filter_chat_header_above","", $wplc_settings); //Ratings/Social Icon Filter
1344
+ }
1345
+
1346
+ $ret_msg .= "<div id=\"wp-live-chat-header\" class='wplc-color-bg-1 wplc-color-2'>";
1347
+ $ret_msg .= apply_filters("wplc_filter_chat_header_under","",$wplc_settings);
1348
+ return $ret_msg;
1349
+ }
1350
+
1351
+
1352
+ add_filter("wplc_filter_chat_header_under","wplc_filter_control_chat_header_under",1,2);
1353
+ function wplc_filter_control_chat_header_under($ret_msg,$wplc_settings) {
1354
+ $current_theme = isset($wplc_settings['wplc_newtheme']) ? $wplc_settings['wplc_newtheme'] : "theme-2";
1355
+ if($current_theme === "theme-2"){
1356
+
1357
+ if (function_exists("wplc_acbc_filter_control_chat_header_under")) {
1358
+ remove_filter("wplc_filter_chat_header_under","wplc_acbc_filter_control_chat_header_under");
1359
+ }
1360
+ }
1361
+
1362
+ return $ret_msg;
1363
+
1364
+ }
1365
+
1366
+
1367
+
1368
+ /**
1369
+ * Filter to control the user details section - custom fields coming soon
1370
+ * @param array $wplc_settings Live chat settings array
1371
+ * @return string
1372
+ * @since 6.0.00
1373
+ * @author Nick Duncan <nick@codecabin.co.za>
1374
+ */
1375
+ function wplc_filter_control_live_chat_box_html_ask_user_detail($wplc_settings) {
1376
+ $ret_msg = "";
1377
+ if (isset($wplc_settings['wplc_loggedin_user_info']) && $wplc_settings['wplc_loggedin_user_info'] == 1) {
1378
+ $wplc_use_loggedin_user_details = 1;
1379
+ } else {
1380
+ $wplc_use_loggedin_user_details = 0;
1381
+ }
1382
+
1383
+ if (isset($wplc_settings['wplc_require_user_info']) && ( $wplc_settings['wplc_require_user_info'] == 1 || $wplc_settings['wplc_require_user_info'] == 'name' )) {
1384
+ $wplc_ask_user_details = 1;
1385
+ } else {
1386
+ $wplc_ask_user_details = 0;
1387
+ }
1388
+
1389
+ $wplc_loggedin_user_name = "";
1390
+ $wplc_loggedin_user_email = "";
1391
+
1392
+ if ($wplc_use_loggedin_user_details == 1 && is_user_logged_in()) {
1393
+ global $current_user;
1394
+
1395
+ if ($current_user->data != null) {
1396
+ //Logged in. Get name and email
1397
+ $wplc_loggedin_user_name = $current_user->user_nicename;
1398
+ $wplc_loggedin_user_email = $current_user->user_email;
1399
+ }
1400
+ } else {
1401
+ if ( $wplc_ask_user_details == 0 ) {
1402
+ $wplc_loggedin_user_name = stripslashes( $wplc_settings['wplc_user_default_visitor_name'] );
1403
+ }
1404
+ }
1405
+
1406
+ if (isset($wplc_settings['wplc_require_user_info']) && $wplc_settings['wplc_require_user_info'] == 1) {
1407
+ //Ask the user to enter name and email
1408
+
1409
+ $ret_msg .= "<input type=\"text\" name=\"wplc_name\" id=\"wplc_name\" value='" . $wplc_loggedin_user_name . "' placeholder=\"" . __( "Name", "wplivechat" ) . "\" />";
1410
+ $ret_msg .= "<input type=\"text\" name=\"wplc_email\" id=\"wplc_email\" wplc_hide=\"0\" value=\"" . $wplc_loggedin_user_email . "\" placeholder=\"" . __( "Email", "wplivechat" ) . "\" />";
1411
+ $ret_msg .= apply_filters( "wplc_start_chat_user_form_after_filter", "" );
1412
+
1413
+ } elseif (isset($wplc_settings['wplc_require_user_info']) && $wplc_settings['wplc_require_user_info'] == 'email') {
1414
+ /*$ret_msg .= "<div style=\"padding: 7px; text-align: center;\">";
1415
+ if (isset($wplc_settings['wplc_user_alternative_text'])) {
1416
+ $ret_msg .= html_entity_decode( stripslashes($wplc_settings['wplc_user_alternative_text']) );
1417
+ }
1418
+ $ret_msg .= '</div>';*/
1419
+
1420
+ $wplc_random_user_number = rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9);
1421
+ if ($wplc_loggedin_user_name != '') { $wplc_lin = $wplc_loggedin_user_name; } else { $wplc_lin = 'user' . $wplc_random_user_number; }
1422
+ $ret_msg .= "<input type=\"hidden\" name=\"wplc_name\" id=\"wplc_name\" value=\"".$wplc_lin."\" />";
1423
+ $ret_msg .= "<input type=\"text\" name=\"wplc_email\" id=\"wplc_email\" wplc_hide=\"0\" value=\"" . $wplc_loggedin_user_email . "\" placeholder=\"" . __( "Email", "wplivechat" ) . "\" />";
1424
+ $ret_msg .= apply_filters("wplc_start_chat_user_form_after_filter", "");
1425
+ } elseif (isset($wplc_settings['wplc_require_user_info']) && $wplc_settings['wplc_require_user_info'] == 'name') {
1426
+ /*
1427
+ $ret_msg .= "<div style=\"padding: 7px; text-align: center;\">";
1428
+ if (isset($wplc_settings['wplc_user_alternative_text'])) {
1429
+ $ret_msg .= html_entity_decode( stripslashes($wplc_settings['wplc_user_alternative_text']) );
1430
+ }
1431
+ $ret_msg .= '</div>';*/
1432
+
1433
+ $wplc_random_user_number = rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9);
1434
+ if ($wplc_loggedin_user_email != '' && $wplc_loggedin_user_email != null) { $wplc_lie = $wplc_loggedin_user_email; } else { $wplc_lie = $wplc_random_user_number . '@' . $wplc_random_user_number . '.com'; }
1435
+ $ret_msg .= "<input type=\"text\" name=\"wplc_name\" id=\"wplc_name\" value='" . $wplc_loggedin_user_name . "' placeholder=\"" . __( "Name", "wplivechat" ) . "\" />";
1436
+ $ret_msg .= "<input type=\"hidden\" name=\"wplc_email\" id=\"wplc_email\" wplc_hide=\"1\" value=\"".$wplc_lie."\" />";
1437
+ $ret_msg .= apply_filters("wplc_start_chat_user_form_after_filter", "");
1438
+ } else {
1439
+ //Dont ask the user
1440
+
1441
+ $ret_msg .= "<div style=\"padding: 7px; text-align: center;\">";
1442
+ if (isset($wplc_settings['wplc_user_alternative_text'])) {
1443
+ $ret_msg .= html_entity_decode( stripslashes($wplc_settings['wplc_user_alternative_text']) );
1444
+ }
1445
+ $ret_msg .= '</div>';
1446
+
1447
+ $wplc_random_user_number = rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9);
1448
+ //$wplc_loggedin_user_email = $wplc_random_user_number."@".$wplc_random_user_number.".com";
1449
+ if ($wplc_loggedin_user_name != '') { $wplc_lin = $wplc_loggedin_user_name; } else { $wplc_lin = 'user' . $wplc_random_user_number; }
1450
+ if ($wplc_loggedin_user_email != '' && $wplc_loggedin_user_email != null) { $wplc_lie = $wplc_loggedin_user_email; } else { $wplc_lie = $wplc_random_user_number . '@' . $wplc_random_user_number . '.com'; }
1451
+ $ret_msg .= "<input type=\"hidden\" name=\"wplc_name\" id=\"wplc_name\" value=\"".$wplc_lin."\" />";
1452
+ $ret_msg .= "<input type=\"hidden\" name=\"wplc_email\" id=\"wplc_email\" wplc_hide=\"1\" value=\"".$wplc_lie."\" />";
1453
+ $ret_msg .= apply_filters("wplc_start_chat_user_form_after_filter", "");
1454
+ }
1455
+ return $ret_msg;
1456
+ }
1457
+
1458
+
1459
+ /**
1460
+ * Filter to control the start chat button
1461
+ * @param array $wplc_settings Live chat settings array
1462
+ * @return string
1463
+ * @since 6.0.00
1464
+ * @author Nick Duncan <nick@codecabin.co.za>
1465
+ */
1466
+ function wplc_filter_control_live_chat_box_html_start_chat_button($wplc_settings,$wplc_using_locale ) {
1467
+ $wplc_sst_1 = __('Start chat', 'wplivechat');
1468
+ if (!isset($wplc_settings['wplc_pro_sst1']) || $wplc_settings['wplc_pro_sst1'] == "") { $wplc_settings['wplc_pro_sst1'] = $wplc_sst_1; }
1469
+ $text = ($wplc_using_locale ? $wplc_sst_1 : stripslashes($wplc_settings['wplc_pro_sst1']));
1470
+ $custom_attr = apply_filters('wplc_start_button_custom_attributes_filter', "", $wplc_settings);
1471
+ return "<button id=\"wplc_start_chat_btn\" type=\"button\" class='wplc-color-bg-1 wplc-color-2' $custom_attr>$text</button>";
1472
+ }
1473
+
1474
+
1475
+
1476
+
1477
+ /**
1478
+ * Filter to control the hover card start chat button
1479
+ * @param array $wplc_settings Live chat settings array
1480
+ * @return string
1481
+ * @since 6.1.00
1482
+ * @author Nick Duncan <nick@codecabin.co.za>
1483
+ */
1484
+ add_filter("wplc_filter_live_chat_box_hover_html_start_chat_button","wplc_filter_control_live_chat_box_html_hovercard_chat_button",10,4);
1485
+ function wplc_filter_control_live_chat_box_html_hovercard_chat_button($content,$wplc_settings,$logged_in,$wplc_using_locale ) {
1486
+ if ($logged_in) {
1487
+ $wplc_sst_1 = __('Start chat', 'wplivechat');
1488
+
1489
+ if (!isset($wplc_settings['wplc_pro_sst1']) || $wplc_settings['wplc_pro_sst1'] == "") { $wplc_settings['wplc_pro_sst1'] = $wplc_sst_1; }
1490
+ $text = ($wplc_using_locale ? $wplc_sst_1 : stripslashes($wplc_settings['wplc_pro_sst1']));
1491
+ return "<button id=\"speeching_button\" type=\"button\" class='wplc-color-bg-1 wplc-color-2'>$text</button>";
1492
+ } else {
1493
+ $wplc_sst_1 = stripslashes($wplc_settings['wplc_pro_offline_btn']);
1494
+ return "<button id=\"speeching_button\" type=\"button\" class='wplc-color-bg-1 wplc-color-2'>$wplc_sst_1</button>";
1495
+
1496
+ }
1497
+ }
1498
+
1499
+ /**
1500
+ * Filter to control the offline message button
1501
+ * @param array $wplc_settings Live chat settings array
1502
+ * @return string
1503
+ * @since 6.0.00
1504
+ * @author Nick Duncan <nick@codecabin.co.za>
1505
+ */
1506
+ function wplc_filter_control_live_chat_box_html_send_offline_message_button($wplc_settings) {
1507
+ $wplc_settings = get_option('WPLC_SETTINGS');
1508
+ if (isset($wplc_settings['wplc_theme'])) { $wplc_theme = $wplc_settings['wplc_theme']; } else { }
1509
+
1510
+ if (isset($wplc_theme)) {
1511
+ if($wplc_theme == 'theme-1') {
1512
+ $wplc_settings_fill = "#DB0000";
1513
+ $wplc_settings_font = "#FFFFFF";
1514
+ } else if ($wplc_theme == 'theme-2'){
1515
+ $wplc_settings_fill = "#000000";
1516
+ $wplc_settings_font = "#FFFFFF";
1517
+ } else if ($wplc_theme == 'theme-3'){
1518
+ $wplc_settings_fill = "#DB30B3";
1519
+ $wplc_settings_font = "#FFFFFF";
1520
+ } else if ($wplc_theme == 'theme-4'){
1521
+ $wplc_settings_fill = "#1A14DB";
1522
+ $wplc_settings_font = "#F7FF0F";
1523
+ } else if ($wplc_theme == 'theme-5'){
1524
+ $wplc_settings_fill = "#3DCC13";
1525
+ $wplc_settings_font = "#FF0808";
1526
+ } else if ($wplc_theme == 'theme-6'){
1527
+ if ($wplc_settings["wplc_settings_fill"]) {
1528
+ $wplc_settings_fill = "#" . $wplc_settings["wplc_settings_fill"];
1529
+ } else {
1530
+ $wplc_settings_fill = "#ec832d";
1531
+ }
1532
+ if ($wplc_settings["wplc_settings_font"]) {
1533
+ $wplc_settings_font = "#" . $wplc_settings["wplc_settings_font"];
1534
+ } else {
1535
+ $wplc_settings_font = "#FFFFFF";
1536
+ }
1537
+ } else {
1538
+ if ($wplc_settings["wplc_settings_fill"]) {
1539
+ $wplc_settings_fill = "#" . $wplc_settings["wplc_settings_fill"];
1540
+ } else {
1541
+ $wplc_settings_fill = "#ec832d";
1542
+ }
1543
+ if ($wplc_settings["wplc_settings_font"]) {
1544
+ $wplc_settings_font = "#" . $wplc_settings["wplc_settings_font"];
1545
+ } else {
1546
+ $wplc_settings_font = "#FFFFFF";
1547
+ }
1548
+ }
1549
+ } else {
1550
+ if ($wplc_settings["wplc_settings_fill"]) {
1551
+ $wplc_settings_fill = "#" . $wplc_settings["wplc_settings_fill"];
1552
+ } else {
1553
+ $wplc_settings_fill = "#ec832d";
1554
+ }
1555
+ if ($wplc_settings["wplc_settings_font"]) {
1556
+ $wplc_settings_font = "#" . $wplc_settings["wplc_settings_font"];
1557
+ } else {
1558
+ $wplc_settings_font = "#FFFFFF";
1559
+ }
1560
+ }
1561
+ $custom_attr = apply_filters('wplc_offline_message_button_custom_attributes_filter', "", $wplc_settings);
1562
+ $ret_msg = "<input id=\"wplc_na_msg_btn\" type=\"button\" value=\"".stripslashes($wplc_settings['wplc_pro_offline_btn_send'])."\" style=\"background: ".$wplc_settings_fill." !important; background-color: ".$wplc_settings_fill." !important; color: ".$wplc_settings_font." !important;\" $custom_attr/>";
1563
+ return $ret_msg;
1564
+ }
1565
+
1566
+
1567
+
1568
+ /**
1569
+ * Filter to control the 2nd layer of the chat window (online/offline)
1570
+ * @param array $wplc_settings Live chat settings array
1571
+ * @param bool $logged_in Is the user logged in or not
1572
+ * @return string
1573
+ * @since 6.0.00
1574
+ * @author Nick Duncan <nick@codecabin.co.za>
1575
+ */
1576
+ function wplc_filter_control_live_chat_box_html_2nd_layer($wplc_settings,$logged_in,$wplc_using_locale, $cid) {
1577
+
1578
+ if ($logged_in) {
1579
+ $wplc_intro = __('Hello. Please input your details so that I may help you.', 'wplivechat');
1580
+ if (!isset($wplc_settings['wplc_pro_intro']) || $wplc_settings['wplc_pro_intro'] == "") { $wplc_settings['wplc_pro_intro'] = $wplc_intro; }
1581
+ $text = ($wplc_using_locale ? $wplc_intro : stripslashes($wplc_settings['wplc_pro_intro']));
1582
+
1583
+ $ret_msg = "<div id=\"wp-live-chat-2-inner\">";
1584
+ $ret_msg .= " <div id=\"wp-live-chat-2-info\" class='wplc-color-4'>";
1585
+ $ret_msg .= apply_filters("wplc_filter_intro_text_heading", $text, $wplc_settings);
1586
+ $ret_msg .= " </div>";
1587
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_ask_user_details",wplc_filter_control_live_chat_box_html_ask_user_detail($wplc_settings));
1588
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_start_chat_button",wplc_filter_control_live_chat_box_html_start_chat_button($wplc_settings,$wplc_using_locale ), $cid);
1589
+ $ret_msg .= "</div>";
1590
+ } else {
1591
+ if ( isset( $wplc_settings['wplc_loggedin_user_info'] ) && $wplc_settings['wplc_loggedin_user_info'] == 1 ) {
1592
+ $wplc_use_loggedin_user_details = 1;
1593
+ } else {
1594
+ $wplc_use_loggedin_user_details = 0;
1595
+ }
1596
+
1597
+ $wplc_loggedin_user_name = '';
1598
+ $wplc_loggedin_user_email = '';
1599
+
1600
+ if ( $wplc_use_loggedin_user_details == 1 ) {
1601
+ global $current_user;
1602
+
1603
+ if ( $current_user->data != null ) {
1604
+ if ( is_user_logged_in() ) {
1605
+ //Logged in. Get name and email
1606
+ $wplc_loggedin_user_name = $current_user->user_nicename;
1607
+ $wplc_loggedin_user_email = $current_user->user_email;
1608
+ } else {
1609
+ $wplc_loggedin_user_name = stripslashes( $wplc_settings['wplc_user_default_visitor_name'] );
1610
+ }
1611
+ }
1612
+ } else {
1613
+ $wplc_loggedin_user_name = '';
1614
+ $wplc_loggedin_user_email = '';
1615
+ }
1616
+
1617
+ /* admin not logged in, show offline messages */
1618
+ $wplc_offline = __("We are currently offline. Please leave a message and we'll get back to you shortly.", "wplivechat");
1619
+ $text = ($wplc_using_locale ? $wplc_offline : stripslashes($wplc_settings['wplc_pro_offline1']));
1620
+
1621
+ $ret_msg = "<div id=\"wp-live-chat-2-info\" class=\"wplc-color-bg-1 wplc-color-2\">";
1622
+ $ret_msg .= $text;
1623
+ $ret_msg .= "</div>";
1624
+ $ret_msg .= "<div id=\"wplc_message_div\">";
1625
+ $ret_msg .= "<input type=\"text\" name=\"wplc_name\" id=\"wplc_name\" value=\"$wplc_loggedin_user_name\" placeholder=\"".__("Name", "wplivechat")."\" />";
1626
+ $ret_msg .= "<input type=\"text\" name=\"wplc_email\" id=\"wplc_email\" value=\"$wplc_loggedin_user_email\" placeholder=\"".__("Email", "wplivechat")."\" />";
1627
+ $ret_msg .= "<textarea name=\"wplc_message\" id=\"wplc_message\" placeholder=\"".__("Message", "wplivechat")."\"></textarea>";
1628
+
1629
+ if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != '') {
1630
+ $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
1631
+ } else {
1632
+ $ip_address = $_SERVER['REMOTE_ADDR'];
1633
+ }
1634
+
1635
+ /** DEPRECATED BY GDPR */
1636
+ /*if(isset($wplc_settings['wplc_record_ip_address']) && $wplc_settings['wplc_record_ip_address'] == 1) { $offline_ip_address = $ip_address; } else { $offline_ip_address = ""; }*/
1637
+
1638
+ $offline_ip_address = "";
1639
+
1640
+ $ret_msg .= "<input type=\"hidden\" name=\"wplc_ip_address\" id=\"wplc_ip_address\" value=\"".$offline_ip_address."\" />";
1641
+ $ret_msg .= "<input type=\"hidden\" name=\"wplc_domain_offline\" id=\"wplc_domain_offline\" value=\"".site_url()."\" />";
1642
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_send_offline_message_button",wplc_filter_control_live_chat_box_html_send_offline_message_button($wplc_settings));
1643
+ $ret_msg .= "</div>";
1644
+
1645
+
1646
+
1647
+ }
1648
+ $data = array(
1649
+ 'ret_msg' => $ret_msg,
1650
+ 'wplc_settings' => $wplc_settings,
1651
+ 'logged_in' => $logged_in,
1652
+ 'wplc_using_locale' => $wplc_using_locale
1653
+ );
1654
+
1655
+
1656
+ $ret_msg = apply_filters( "wplc_filter_2nd_layer_modify" , $data );
1657
+ if( is_array( $ret_msg ) ){
1658
+ /* if nothing uses this filter is comes back as an array, so return the original message in that array */
1659
+ return $ret_msg['ret_msg'];
1660
+ } else {
1661
+ return $ret_msg;
1662
+ }
1663
+ }
1664
+
1665
+ /**
1666
+ * Filter to control the 3rd layer of the chat window
1667
+ * @param array $wplc_settings live chat settings array
1668
+ * @return string
1669
+ * @since 6.0.00
1670
+ * @author Nick Duncan <nick@codecabin.co.za>
1671
+ */
1672
+ function wplc_filter_control_live_chat_box_html_3rd_layer($wplc_settings,$wplc_using_locale) {
1673
+
1674
+ $wplc_sst_2 = __('Connecting. Please be patient...', 'wplivechat');
1675
+ if (!isset($wplc_settings['wplc_pro_sst2']) || $wplc_settings['wplc_pro_sst2'] == "") { $wplc_settings['wplc_pro_sst2'] = $wplc_sst_2; }
1676
+ $text = ($wplc_using_locale ? $wplc_sst_2 : stripslashes($wplc_settings['wplc_pro_sst2']));
1677
+
1678
+ $ret_msg = "<p class=''wplc-color-4>".$text."</p>";
1679
+ return $ret_msg;
1680
+ }
1681
+
1682
+ add_filter("wplc_filter_intro_text_heading", "wplc_filter_control_intro_text_heading", 10, 2);
1683
+ /**
1684
+ * Filters intro text
1685
+ */
1686
+ function wplc_filter_control_intro_text_heading($content, $wplc_settings){
1687
+
1688
+ if (isset($wplc_settings['wplc_require_user_info']) && $wplc_settings['wplc_require_user_info'] == 1) {
1689
+
1690
+ } elseif (isset($wplc_settings['wplc_require_user_info']) && $wplc_settings['wplc_require_user_info'] == 'email') {
1691
+
1692
+ } elseif (isset($wplc_settings['wplc_require_user_info']) && $wplc_settings['wplc_require_user_info'] == 'name') {
1693
+
1694
+ } else {
1695
+ $content = "";
1696
+ }
1697
+
1698
+ return $content;
1699
+ }
1700
+
1701
+
1702
+ add_filter("wplc_filter_live_chat_box_above_main_div","wplc_filter_control_live_chat_box_above_main_div",10,3);
1703
+ function wplc_filter_control_live_chat_box_above_main_div( $msg, $wplc_settings, $cid ) {
1704
+ if(!isset($wplc_settings['wplc_newtheme'])){ $wplc_settings['wplc_newtheme'] = "theme-2"; }
1705
+ if (isset($wplc_settings['wplc_newtheme']) && $wplc_settings['wplc_newtheme'] == "theme-2") {
1706
+
1707
+ $agent_info = '';
1708
+ $cbox_header_bg = '';
1709
+ $agent_tagline = '';
1710
+ $agent_bio = '';
1711
+
1712
+ $a_twitter = '';
1713
+ $a_linkedin = '';
1714
+ $a_facebook = '';
1715
+ $a_website = '';
1716
+ $social_links = '';
1717
+ $agent_string = '';
1718
+
1719
+ if(isset($wplc_settings['wplc_use_node_server']) && intval($wplc_settings['wplc_use_node_server']) == 1) {} else {
1720
+ if ( $cid ) {
1721
+ $cid = wplc_return_chat_id_by_rel($cid);
1722
+ $chat_data = wplc_get_chat_data( $cid );
1723
+
1724
+ if ( isset( $chat_data->agent_id ) ) {
1725
+ $agent_id = intval( $chat_data->agent_id );
1726
+ } else {
1727
+ $agent_id = get_current_user_id();
1728
+ }
1729
+
1730
+ if ( $agent_id ) {
1731
+
1732
+ $wplc_acbc_data = get_option("WPLC_ACBC_SETTINGS");
1733
+ $user_info = get_userdata( $agent_id );
1734
+
1735
+
1736
+ if( isset( $wplc_acbc_data['wplc_use_wp_name'] ) && $wplc_acbc_data['wplc_use_wp_name'] == '1' ){
1737
+
1738
+ $agent = $user_info->display_name;
1739
+ } else {
1740
+ if (!empty($wplc_acbc_data['wplc_chat_name'])) {
1741
+ $agent = $wplc_acbc_data['wplc_chat_name'];
1742
+ } else {
1743
+ $agent = 'Admin';
1744
+ }
1745
+ }
1746
+ $cbox_header_bg = "style='background-image:url(https://www.gravatar.com/avatar/".md5($user_info->user_email)."?s=380); no-repeat; cover;'";
1747
+
1748
+ $extra = apply_filters( "wplc_filter_further_live_chat_box_above_main_div", '', $wplc_settings, $cid, $chat_data, $agent );
1749
+
1750
+ $agent_string = '
1751
+ <p style="text-align:center;">
1752
+ <img class="img-thumbnail img-circle wplc_thumb32 wplc_agent_involved" style="max-width:inherit;" id="agent_grav_'.$agent_id.'" title="'.$agent.'" src="https://www.gravatar.com/avatar/'.md5($user_info->user_email).'?s=60" /><br />
1753
+ <span class="wplc_agent_name wplc-color-2">'.$agent.'</span>
1754
+ '.$extra.'
1755
+ <span class="bleeper_pullup down"><i class="fa fa-angle-up"></i></span>
1756
+ </p>';
1757
+
1758
+ }
1759
+ }
1760
+
1761
+ }
1762
+
1763
+ $msg .= "<div id='wplc_chatbox_header_bg' ".$cbox_header_bg."><div id='wplc_chatbox_header' class='wplc-color-bg-1 wplc-color-4'><div class='wplc_agent_info'>".$agent_string."</div></div></div>";
1764
+
1765
+ }
1766
+ return $msg;
1767
+ }
1768
+
1769
+ /**
1770
+ * Filter to control the 4th layer of the chat window
1771
+ * @param array $wplc_settings live chat settings array
1772
+ * @return string
1773
+ * @since 6.0.00
1774
+ * @author Nick Duncan <nick@codecabin.co.za>
1775
+ */
1776
+ function wplc_filter_control_live_chat_box_html_4th_layer($wplc_settings,$wplc_using_locale, $cid ) {
1777
+ $wplc_enter = __('Connecting. Please be patient...', 'wplivechat');
1778
+ if (!isset($wplc_settings['wplc_user_enter']) || $wplc_settings['wplc_user_enter'] == "") { $wplc_settings['wplc_pro_sst2'] = $wplc_enter; }
1779
+ $text = ($wplc_using_locale ? $wplc_enter : stripslashes($wplc_settings['wplc_user_enter']));
1780
+
1781
+ $wplc_welcome = __('Welcome. How may I help you?', 'wplivechat');
1782
+ if (!isset($wplc_settings['wplc_user_welcome_chat']) || $wplc_settings['wplc_user_welcome_chat'] == "") { $wplc_settings['wplc_user_welcome_chat'] = $wplc_welcome; }
1783
+ $text2 = ($wplc_using_locale ? $wplc_welcome : stripslashes($wplc_settings['wplc_user_welcome_chat']));
1784
+
1785
+
1786
+
1787
+
1788
+
1789
+ $ret_msg = "";
1790
+ if(!isset($wplc_settings['wplc_newtheme'])){ $wplc_settings['wplc_newtheme'] = "theme-2"; }
1791
+ if (isset($wplc_settings['wplc_newtheme']) && $wplc_settings['wplc_newtheme'] == 'theme-1') {
1792
+ $ret_msg .= apply_filters("wplc_filter_typing_control_div","");
1793
+ }
1794
+
1795
+ $ret_msg .= apply_filters("wplc_filter_inner_live_chat_box_4th_layer","", $wplc_settings);
1796
+
1797
+ $ret_msg .= "<div id=\"wplc_sound_update\" style=\"height:0; width:0; display:none; border:0;\"></div>";
1798
+
1799
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_above_main_div","",$wplc_settings, $cid);
1800
+
1801
+
1802
+ $ret_msg .= "<div id=\"wplc_chatbox\">";
1803
+ // $ret_msg .= "<span class='wplc-admin-message'>";
1804
+ // $ret_msg .= $text2;
1805
+ // $ret_msg .= "</span>";
1806
+ // $ret_msg .= "<br />";
1807
+ // $ret_msg .= "<div class='wplc-clear-float-message'></div>";
1808
+ $ret_msg .= "</div>";
1809
+
1810
+ $ret_msg .= "<div id='bleeper_chat_ended' style='display:none;'></div>";
1811
+ $ret_msg .= "<div id='wplc_user_message_div'>";
1812
+
1813
+ $ret_msg .= "<p id='wplc_msg_notice'>".$text."</p>";
1814
+
1815
+ //Editor Controls
1816
+ $ret_msg .= apply_filters("wplc_filter_chat_text_editor","");
1817
+
1818
+ $ret_msg .= "<p>";
1819
+ $placeholder = __('Type here','wplivechat');
1820
+ $ret_msg .= "<textarea type=\"text\" name=\"wplc_chatmsg\" id=\"wplc_chatmsg\" placeholder=\"".$placeholder."\" onclick=\"jQuery(this).select();\" class='wdt-emoji-bundle-enabled'></textarea>";
1821
+ if(!isset($wplc_settings['wplc_newtheme'])){ $wplc_settings['wplc_newtheme'] = "theme-2"; }
1822
+ if (isset($wplc_settings['wplc_newtheme']) && $wplc_settings['wplc_newtheme'] == 'theme-2') {
1823
+ $ret_msg .= apply_filters("wplc_filter_typing_control_div_theme_2","");
1824
+ }
1825
+
1826
+ //Upload Controls
1827
+ $ret_msg .= apply_filters("wplc_filter_chat_upload","");
1828
+
1829
+ $ret_msg .= "<input type=\"hidden\" name=\"wplc_cid\" id=\"wplc_cid\" value=\"\" />";
1830
+ $ret_msg .= "<input id=\"wplc_send_msg\" type=\"button\" value=\"".__("Send", "wplivechat")."\" style=\"display:none;\" />";
1831
+ $ret_msg .= "</p>";
1832
+
1833
+ $ret_msg .= function_exists("wplc_emoji_selector_div") ? wplc_emoji_selector_div() : "";
1834
+
1835
+ $current_theme = isset($wplc_settings['wplc_newtheme']) ? $wplc_settings['wplc_newtheme'] : "theme-2";
1836
+ if($current_theme === "theme-2"){
1837
+ $ret_msg .= apply_filters("wplc_filter_chat_4th_layer_below_input","", $wplc_settings); //Ratings/Social Icon Filter
1838
+ }
1839
+
1840
+ $ret_msg .= "</div>";
1841
+ $ret_msg .= "</div>";
1842
+ return $ret_msg;
1843
+ }
1844
+
1845
+ /**
1846
+ * Filter to control the 1st layer of the chat window
1847
+ * @param array $wplc_settings live chat settings array
1848
+ * @param bool $logged_in Is the admin logged in or not
1849
+ * @param bool $wplc_using_locale Are they using a localization plugin
1850
+ * @return string
1851
+ * @since 6.0.00
1852
+ * @author Nick Duncan <nick@codecabin.co.za>
1853
+ */
1854
+ function wplc_filter_control_live_chat_box_html_1st_layer($wplc_settings,$logged_in,$wplc_using_locale, $class_override = false) {
1855
+
1856
+ $ret_msg = "<div id='wplc_first_message'>";
1857
+
1858
+ if(!isset($wplc_settings['wplc_newtheme'])){ $wplc_settings['wplc_newtheme'] = "theme-2"; }
1859
+
1860
+ if ($logged_in) {
1861
+ $wplc_fst_1 = __('Questions?', 'wplivechat');
1862
+ $wplc_fst_2 = __('Chat with us', 'wplivechat');
1863
+ if (isset($wplc_settings['wplc_newtheme']) && $wplc_settings['wplc_newtheme'] == "theme-2") {
1864
+ $coltheme = "wplc-color-4";
1865
+ } else {
1866
+ $coltheme = "wplc-color-2";
1867
+ }
1868
+
1869
+ if($class_override){
1870
+ //Override color class
1871
+ $coltheme = $class_override;
1872
+ }
1873
+
1874
+ $wplc_tl_msg = "<div class='$coltheme'><strong>" . ($wplc_using_locale ? $wplc_fst_1 : stripslashes($wplc_settings['wplc_pro_fst1'])) . "</strong> " . ( $wplc_using_locale ? $wplc_fst_2 : stripslashes($wplc_settings['wplc_pro_fst2'])) ."</div>";
1875
+
1876
+ $ret_msg .= $wplc_tl_msg;
1877
+ } else {
1878
+
1879
+
1880
+ $wplc_na = __('Chat offline. Leave a message', 'wplivechat');
1881
+ $wplc_tl_msg = "<span class='wplc_offline'>" . ($wplc_using_locale ? $wplc_na : stripslashes($wplc_settings['wplc_pro_na'])) . "</span>";
1882
+ $ret_msg .= $wplc_tl_msg;
1883
+ }
1884
+ $ret_msg .= "</div>";
1885
+
1886
+
1887
+
1888
+ return $ret_msg;
1889
+
1890
+ }
1891
+
1892
+ /**
1893
+ * Build the initiate teaser
1894
+ * @return void
1895
+ * @since 6.0.00
1896
+ * @author Nick Duncan <nick@codecabin.co.za>
1897
+ */
1898
+ add_filter( 'wplc_filter_list_chats_actions', 'wplc_initiate_chat_button', 12, 3);
1899
+ function wplc_initiate_chat_button($actions,$result,$post_data) {
1900
+
1901
+
1902
+ if(intval($result->status) == 5 ){
1903
+ $actions = "<a href=\"javascript:void(0);\" id=\"wplc_initiate_chat\" class=\"wplc_initiate_chat button button-secondary\">".__("Initiate Chat","wplivechat")."</a>";
1904
+ }
1905
+ return $actions;
1906
+ }
1907
+
1908
+
1909
+ add_filter("wplc_loggedin_filter","wplc_filter_control_loggedin",10,1);
1910
+ function wplc_filter_control_loggedin($logged_in) {
1911
+ $wplc_is_admin_logged_in = get_transient("wplc_is_admin_logged_in");
1912
+
1913
+ if (!function_exists("wplc_register_pro_version") && $wplc_is_admin_logged_in != 1) {
1914
+ $logged_in = false;
1915
+ } else {
1916
+ $logged_in = true;
1917
+ }
1918
+
1919
+ $logged_in_checks = apply_filters("wplc_filter_is_admin_logged_in",array());
1920
+
1921
+ /* if we are logged in ANYWHERE, set this to true */
1922
+ foreach($logged_in_checks as $key => $val) {
1923
+ if ($val) { $logged_in = true; break; }
1924
+ }
1925
+ $logged_in_via_app = false;
1926
+ if (isset($logged_in_checks['app']) && $logged_in_checks['app'] == true) { $logged_in_via_app = true; }
1927
+
1928
+ $logged_in = apply_filters("wplc_final_loggedin_control",$logged_in,$logged_in_via_app);
1929
+
1930
+ /* admin is using the basic version and is logged in */
1931
+ if ($wplc_is_admin_logged_in) { $logged_in = true; }
1932
+
1933
+ return $logged_in;
1934
+ }
1935
+
1936
+ function wplc_shortenurl($url) {
1937
+ if ( strlen($url) > 45) {
1938
+ return substr($url, 0, 30)."[...]".substr($url, -15);
1939
+ } else {
1940
+ return $url;
1941
+ }
1942
+ }
1943
+
1944
+
1945
+ /**
1946
+ * The function that builds the chat box
1947
+ * @since 6.0.00
1948
+ * @author Nick Duncan <nick@codecabin.co.za>
1949
+ * @return JSON encoded HTML
1950
+ */
1951
+ function wplc_output_box_ajax_new($cid = null) {
1952
+
1953
+
1954
+ $ret_msg = array();
1955
+ $logged_in = false;
1956
+
1957
+ $wplc_settings = get_option("WPLC_SETTINGS");
1958
+
1959
+ if(isset($wplc_settings['wplc_using_localization_plugin']) && $wplc_settings['wplc_using_localization_plugin'] == 1){ $wplc_using_locale = true; } else { $wplc_using_locale = false; }
1960
+
1961
+
1962
+ $logged_in = apply_filters("wplc_loggedin_filter",false);
1963
+
1964
+ $ret_msg['cbox'] = apply_filters("wplc_theme_control",$wplc_settings,$logged_in,$wplc_using_locale,$cid);
1965
+
1966
+ $ret_msg['online'] = $logged_in;
1967
+
1968
+ global $wplc_pro_version;
1969
+ $wplc_ver = str_replace('.', '', $wplc_pro_version);
1970
+ $checker = intval($wplc_ver);
1971
+
1972
+ if ($cid !== null && $cid !== '') {
1973
+ $ret_msg['cid'] = $cid;
1974
+ $chat_data = wplc_get_chat_data( $cid );
1975
+ wplc_record_chat_notification('user_loaded',$cid,array('uri' => $_SERVER['HTTP_REFERER'], 'chat_data' => $chat_data ));
1976
+
1977
+
1978
+
1979
+ if ( !isset($chat_data) || !$chat_data->agent_id ) {
1980
+ $ret_msg['type'] = 'new';
1981
+ } else {
1982
+ $ret_msg['type'] = 'returning';
1983
+
1984
+ if(isset($wplc_settings['wplc_use_node_server']) && intval($wplc_settings['wplc_use_node_server']) == 1) {
1985
+ //This is using node, we shouldn't generate the header data as part of the chat box.
1986
+ //We will do this dynamically on the front end
1987
+
1988
+ //var_dump("NOPEEE");
1989
+
1990
+ } else {
1991
+ /* build the AGENT DATA array */
1992
+ $wplc_acbc_data = get_option("WPLC_ACBC_SETTINGS");
1993
+ $user_info = get_userdata( intval( $chat_data->agent_id ) );
1994
+
1995
+ $agent_tagline = '';
1996
+ $agent_bio = '';
1997
+ $a_twitter = '';
1998
+ $a_linkedin = '';
1999
+ $a_facebook = '';
2000
+ $a_website = '';
2001
+ $social_links = '';
2002
+
2003
+ if( isset( $wplc_acbc_data['wplc_use_wp_name'] ) && $wplc_acbc_data['wplc_use_wp_name'] == '1' ){
2004
+
2005
+ $agent = $user_info->display_name;
2006
+ } else {
2007
+ if (!empty($wplc_acbc_data['wplc_chat_name'])) {
2008
+ $agent = $wplc_acbc_data['wplc_chat_name'];
2009
+ } else {
2010
+ $agent = 'Admin';
2011
+ }
2012
+ }
2013
+
2014
+ if( !isset( $data ) ){ $data = false; }
2015
+
2016
+ $agent_tagline = apply_filters( "wplc_filter_agent_data_agent_tagline", $agent_tagline, $cid, $chat_data, $agent, $wplc_acbc_data, $user_info, $data );
2017
+ $agent_bio = apply_filters( "wplc_filter_agent_data_agent_bio", $agent_bio, $cid, $chat_data, $agent, $wplc_acbc_data, $user_info, $data );
2018
+ $social_links = apply_filters( "wplc_filter_agent_data_social_links", $social_links, $cid, $chat_data, $agent, $wplc_acbc_data, $user_info, $data);
2019
+
2020
+ $ret_msg['agent_data'] = array(
2021
+ 'email' => md5($user_info->user_email),
2022
+ 'name' => $agent,
2023
+ 'aid' => $user_info->ID,
2024
+ 'agent_tagline' => $agent_tagline,
2025
+ 'agent_bio' => $agent_bio,
2026
+ "social_links" => $social_links
2027
+ );
2028
+ }
2029
+
2030
+ }
2031
+
2032
+
2033
+ } else {
2034
+ $ret_msg['type'] = 'new';
2035
+ }
2036
+
2037
+
2038
+ if (function_exists("wplc_pro_version_control")) {
2039
+ if ($checker < 6000) {
2040
+ /* backwards compatibilitty for the old pro version */
2041
+ return json_encode($ret_msg['cbox']);
2042
+ } else {
2043
+ return json_encode($ret_msg);
2044
+ }
2045
+
2046
+ } else {
2047
+ return json_encode($ret_msg);
2048
+ }
2049
+
2050
+
2051
+
2052
+
2053
+
2054
+
2055
+ }
2056
+ function wplc_return_default_theme($wplc_settings,$logged_in,$wplc_using_locale,$cid) {
2057
+ $ret_msg = apply_filters("wplc_filter_live_chat_box_html_main_div_top",wplc_filter_control_live_chat_box_html_main_div_top($wplc_settings,$logged_in,$wplc_using_locale));
2058
+ $ret_msg .= "<div class=\"wp-live-chat-wraper\">";
2059
+ $ret_msg .= "<div id='bleeper_bell' class='wplc-color-bg-1 wplc-color-2' style='display:none;'><i class='fa fa-bell'></i></div>";
2060
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_header_div_top",wplc_filter_control_live_chat_box_html_header_div_top($wplc_settings));
2061
+ $ret_msg .= " <i id=\"wp-live-chat-minimize\" class=\"fa fa-minus wplc-color-bg-2 wplc-color-1\" style=\"display:none;\"></i>";
2062
+ $ret_msg .= " <i id=\"wp-live-chat-close\" class=\"fa fa-times\" style=\"display:none;\" ></i>";
2063
+ $ret_msg .= " <div id=\"wp-live-chat-1\" >";
2064
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_1st_layer",wplc_filter_control_live_chat_box_html_1st_layer($wplc_settings,$logged_in,$wplc_using_locale,'wplc-color-2'));
2065
+ $ret_msg .= " </div>";
2066
+ $ret_msg .= '<div id="wplc-chat-alert" class="wplc-chat-alert wplc-chat-alert--' . $wplc_settings["wplc_theme"] . '"></div>';
2067
+ $ret_msg .= " </div>";
2068
+ $ret_msg .= " <div id=\"wp-live-chat-2\" style=\"display:none;\">";
2069
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_survey","");
2070
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_2nd_layer",wplc_filter_control_live_chat_box_html_2nd_layer($wplc_settings,$logged_in,$wplc_using_locale,$cid), $cid);
2071
+ $ret_msg .= " </div>";
2072
+ $ret_msg .= " <div id=\"wp-live-chat-3\" style=\"display:none;\">";
2073
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_3rd_layer",wplc_filter_control_live_chat_box_html_3rd_layer($wplc_settings,$wplc_using_locale));
2074
+ $ret_msg .= " </div>";
2075
+ $ret_msg .= " <div id=\"wp-live-chat-react\" style=\"display:none;\">";
2076
+ $ret_msg .= " <p>".__("Reactivating your previous chat...", "wplivechat")."</p>";
2077
+ $ret_msg .= " </div>";
2078
+ $ret_msg .= " <div id=\"wplc-extra-div\" style=\"display:none;\">";
2079
+ $ret_msg .= apply_filters("wplc_filter_wplc_extra_div","",$wplc_settings,$wplc_using_locale);
2080
+ $ret_msg .= "</div>";
2081
+ $ret_msg .= "</div>";
2082
+ $ret_msg .= " <div id=\"wp-live-chat-4\" style=\"display:none;\">";
2083
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_4th_layer",wplc_filter_control_live_chat_box_html_4th_layer($wplc_settings,$wplc_using_locale, $cid));
2084
+ $ret_msg .= "</div>";
2085
+ return $ret_msg;
2086
+ }
2087
+
2088
+
2089
+ add_filter("wplc_theme_control","wplc_theme_control_function",10,4);
2090
+ function wplc_theme_control_function($wplc_settings,$logged_in,$wplc_using_locale, $cid) {
2091
+
2092
+ if (!$wplc_settings) { return ""; }
2093
+ if (isset($wplc_settings['wplc_newtheme'])) { $wplc_newtheme = $wplc_settings['wplc_newtheme']; } else { $wplc_newtheme = "theme-2"; }
2094
+
2095
+ $default_theme = wplc_return_default_theme($wplc_settings,$logged_in,$wplc_using_locale, $cid);
2096
+ if (isset($wplc_newtheme)) {
2097
+
2098
+
2099
+
2100
+
2101
+
2102
+
2103
+
2104
+ if($wplc_newtheme == 'theme-1') {
2105
+ $ret_msg = $default_theme;
2106
+
2107
+ }
2108
+ else if($wplc_newtheme == 'theme-2') {
2109
+ $ret_msg = apply_filters("wplc_filter_live_chat_box_html_main_div_top",wplc_filter_control_live_chat_box_html_main_div_top($wplc_settings,$logged_in,$wplc_using_locale));
2110
+ $ret_msg .= "<div class=\"wp-live-chat-wraper\">";
2111
+ $ret_msg .= "<div id='bleeper_bell' class='wplc-color-bg-1 wplc-color-2' style='display:none;'><i class='fa fa-bell'></i></div>";
2112
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_header_div_top",wplc_filter_control_live_chat_box_html_header_div_top($wplc_settings));
2113
+ $ret_msg .= " </div>";
2114
+ $ret_msg .= '<div id="wplc-chat-alert" class="wplc-chat-alert wplc-chat-alert--' . $wplc_settings["wplc_theme"] . '"></div>';
2115
+ $ret_msg .= " <div id=\"wp-live-chat-2\" style=\"display:none;\">";
2116
+ $ret_msg .= " <i id=\"wp-live-chat-minimize\" class=\"fa fa-minus wplc-color-bg-2 wplc-color-1\" style=\"display:none;\" ></i>";
2117
+ $ret_msg .= " <i id=\"wp-live-chat-close\" class=\"fa fa-times\" style=\"display:none;\" ></i>";
2118
+ $ret_msg .= " <div id=\"wplc-extra-div\" style=\"display:none;\">";
2119
+ $ret_msg .= apply_filters("wplc_filter_wplc_extra_div","",$wplc_settings,$wplc_using_locale);
2120
+ $ret_msg .= " </div>";
2121
+ $ret_msg .= " <div id='wp-live-chat-inner-container'>";
2122
+ $ret_msg .= " <div id='wp-live-chat-inner'>";
2123
+ $ret_msg .= " <div id=\"wp-live-chat-1\" class=\"wplc-color-2 wplc-color-bg-1\" >";
2124
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_1st_layer",wplc_filter_control_live_chat_box_html_1st_layer($wplc_settings,$logged_in,$wplc_using_locale,'wplc-color-2'));
2125
+ $ret_msg .= " </div>";
2126
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_2nd_layer",wplc_filter_control_live_chat_box_html_2nd_layer($wplc_settings,$logged_in,$wplc_using_locale, $cid), $cid);
2127
+ $ret_msg .= " </div>";
2128
+ $ret_msg .= " <div id=\"wp-live-chat-react\" style=\"display:none;\">";
2129
+ $ret_msg .= " <p>".__("Reactivating your previous chat...", "wplivechat")."</p>";
2130
+ $ret_msg .= " </div>";
2131
+ $ret_msg .= " </div>";
2132
+ $ret_msg .= " <div id=\"wp-live-chat-3\" style=\"display:none;\">";
2133
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_3rd_layer",wplc_filter_control_live_chat_box_html_3rd_layer($wplc_settings,$wplc_using_locale));
2134
+ $ret_msg .= " </div>";
2135
+ $ret_msg .= " </div>";
2136
+ $ret_msg .= " <div id=\"wp-live-chat-4\" style=\"display:none;\">";
2137
+ $ret_msg .= apply_filters("wplc_filter_live_chat_box_html_4th_layer",wplc_filter_control_live_chat_box_html_4th_layer($wplc_settings,$wplc_using_locale, $cid));
2138
+ $ret_msg .= " </div>";
2139
+
2140
+ $ret_msg .= "</div>";
2141
+
2142
+ } else {
2143
+ $ret_msg = $default_theme;
2144
+ }
2145
+ } else {
2146
+ $ret_msg = $default_theme;
2147
+ }
2148
+
2149
+ return $ret_msg;
2150
+ }
2151
+
2152
+
2153
+ /**
2154
+ * THIS FUNCTION ONLY RUNS IF THE PRO VERSION IS LESS THAN 5.0.1
2155
+ * The new method is being handled with ajax
2156
+ * @return void
2157
+ */
2158
+ function wplc_display_box() {
2159
+
2160
+ global $wplc_pro_version;
2161
+ $wplc_ver = str_replace('.', '', $wplc_pro_version);
2162
+ $checker = intval($wplc_ver);
2163
+
2164
+ if (function_exists("wplc_pro_version_control") && ($checker <= 501 || $checker == 4410)) {
2165
+ /* prior to latest pro version with ajax handling */
2166
+
2167
+ if(function_exists('wplc_display_chat_contents')){
2168
+ $display_contents = wplc_display_chat_contents();
2169
+ } else {
2170
+ $display_contents = 1;
2171
+ }
2172
+
2173
+ if(function_exists('wplc_is_user_banned_basic')){
2174
+ $user_banned = wplc_is_user_banned_basic();
2175
+ } else {
2176
+ $user_banned = 0;
2177
+ }
2178
+ if($display_contents && $user_banned == 0){
2179
+ $wplc_is_admin_logged_in = get_transient("wplc_is_admin_logged_in");
2180
+ if ($wplc_is_admin_logged_in != 1) {
2181
+ echo "<!-- wplc a-n-c -->";
2182
+ }
2183
+
2184
+ /* do not show if pro is outdated */
2185
+ global $wplc_pro_version;
2186
+ if (isset($wplc_pro_version)) {
2187
+ $float_version = floatval($wplc_pro_version);
2188
+ if ($float_version < 4 || $wplc_pro_version == "4.1.0" || $wplc_pro_version == "4.1.1") {
2189
+ return;
2190
+ }
2191
+ }
2192
+
2193
+ if (function_exists("wplc_register_pro_version")) {
2194
+ $wplc_settings = get_option("WPLC_SETTINGS");
2195
+ if (!class_exists('Mobile_Detect')) {
2196
+ require_once (plugin_dir_path(__FILE__) . 'includes/Mobile_Detect.php');
2197
+ }
2198
+ $wplc_detect_device = new Mobile_Detect;
2199
+ $wplc_is_mobile = $wplc_detect_device->isMobile();
2200
+ if ($wplc_is_mobile && !isset($wplc_settings['wplc_enabled_on_mobile']) && $wplc_settings['wplc_enabled_on_mobile'] != 1) {
2201
+ return;
2202
+ }
2203
+ if (function_exists('wplc_basic_hide_chat_when_offline')) {
2204
+ $wplc_hide_chat = wplc_basic_hide_chat_when_offline();
2205
+ if (!$wplc_hide_chat) {
2206
+ wplc_pro_draw_user_box();
2207
+ }
2208
+ } else {
2209
+ wplc_pro_draw_user_box();
2210
+ }
2211
+ } else {
2212
+ wplc_draw_user_box();
2213
+ }
2214
+ }
2215
+ }
2216
+ }
2217
+ function wplc_display_box_ajax() {
2218
+
2219
+ if(function_exists('wplc_display_chat_contents')){
2220
+ $display_contents = wplc_display_chat_contents();
2221
+ } else {
2222
+ $display_contents = 1;
2223
+ }
2224
+
2225
+ if(function_exists('wplc_is_user_banned')){
2226
+ $user_banned = wplc_is_user_banned();
2227
+ } else if (function_exists('wplc_is_user_banned')){
2228
+ $user_banned = wplc_is_user_banned_basic();
2229
+ } else {
2230
+ $user_banned = 0;
2231
+ }
2232
+ if($display_contents && $user_banned == 0){
2233
+ $wplc_is_admin_logged_in = get_transient("wplc_is_admin_logged_in");
2234
+ if ($wplc_is_admin_logged_in != 1) {
2235
+ return "";
2236
+ }
2237
+
2238
+ /* do not show if pro is outdated */
2239
+ global $wplc_pro_version;
2240
+ if (isset($wplc_pro_version)) {
2241
+ $float_version = floatval($wplc_pro_version);
2242
+ if ($float_version < 4 || $wplc_pro_version == "4.1.0" || $wplc_pro_version == "4.1.1") {
2243
+ return;
2244
+ }
2245
+ }
2246
+
2247
+ if (function_exists("wplc_register_pro_version")) {
2248
+ $wplc_settings = get_option("WPLC_SETTINGS");
2249
+ if (!class_exists('Mobile_Detect')) {
2250
+ require_once (plugin_dir_path(__FILE__) . 'includes/Mobile_Detect.php');
2251
+ }
2252
+ $wplc_detect_device = new Mobile_Detect;
2253
+ $wplc_is_mobile = $wplc_detect_device->isMobile();
2254
+ if ($wplc_is_mobile && !isset($wplc_settings['wplc_enabled_on_mobile']) && $wplc_settings['wplc_enabled_on_mobile'] != 1) {
2255
+ return;
2256
+ }
2257
+ if (function_exists('wplc_basic_hide_chat_when_offline')) {
2258
+ $wplc_hide_chat = wplc_basic_hide_chat_when_offline();
2259
+ if (!$wplc_hide_chat) {
2260
+ wplc_pro_draw_user_box();
2261
+ }
2262
+ } else {
2263
+ wplc_pro_draw_user_box();
2264
+ }
2265
+ } else {
2266
+ wplc_draw_user_box();
2267
+ }
2268
+ }
2269
+ }
2270
+
2271
+ function wplc_admin_display_chat($cid) {
2272
+ global $wpdb;
2273
+ global $wplc_tblname_msgs;
2274
+ $results = $wpdb->get_results(
2275
+ "
2276
+ SELECT *
2277
+ FROM $wplc_tblname_msgs
2278
+ WHERE `chat_sess_id` = '$cid'
2279
+ ORDER BY `timestamp` DESC
2280
+ LIMIT 0, 100
2281
+ "
2282
+ );
2283
+ foreach ($results as $result) {
2284
+ $from = $result->msgfrom;
2285
+ $msg = stripslashes($result->msg);
2286
+ $msg_hist .= "$from: $msg<br />";
2287
+ }
2288
+ echo $msg_hist;
2289
+ }
2290
+
2291
+ function wplc_admin_accept_chat($cid) {
2292
+ $user_ID = get_current_user_id();
2293
+ wplc_change_chat_status(sanitize_text_field($cid), 3,$user_ID);
2294
+ return true;
2295
+ }
2296
+
2297
+ add_action('admin_head', 'wplc_update_chat_statuses');
2298
+
2299
+
2300
+ //add_action("wplc_hook_superadmin_head","wplc_hook_control_superadmin_head",10);
2301
+ // Deprecated as this as now been added to wplc_heartbeat.js
2302
+ function wplc_hook_control_superadmin_head() {
2303
+ $wplc_current_user = get_current_user_id();
2304
+
2305
+ if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true )) {
2306
+ $ajax_nonce = wp_create_nonce("wplc");
2307
+ ?>
2308
+ <script type="text/javascript">
2309
+ jQuery(function () {
2310
+
2311
+
2312
+ var wplc_set_transient = null;
2313
+
2314
+ wplc_set_transient = setInterval(function () {
2315
+ wpcl_admin_set_transient();
2316
+ }, 60000);
2317
+ wpcl_admin_set_transient();
2318
+ function wpcl_admin_set_transient() {
2319
+ var data = {
2320
+ action: 'wplc_admin_set_transient',
2321
+ security: '<?php echo $ajax_nonce; ?>'
2322
+
2323
+ };
2324
+ jQuery.post(ajaxurl, data, function (response) {
2325
+
2326
+ });
2327
+ }
2328
+
2329
+ });
2330
+ </script>
2331
+ <?php
2332
+ }
2333
+ }
2334
+
2335
+
2336
+ function wplc_superadmin_javascript() {
2337
+ $wplc_settings = get_option("WPLC_SETTINGS");
2338
+
2339
+ if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1 && (!isset($_GET['action']) || $_GET['action'] !== "history") ){
2340
+
2341
+ //Using node, remote scripts please
2342
+ if ( isset( $wplc_settings['wplc_enable_all_admin_pages'] ) && $wplc_settings['wplc_enable_all_admin_pages'] === '1' ) {
2343
+ /* Run admin JS on all admin pages */
2344
+ if ( isset( $_GET['action'] ) && $_GET['action'] == "history" ) { }else {
2345
+ wplc_admin_remote_dashboard_scripts($wplc_settings);
2346
+ }
2347
+ } else {
2348
+ /* Only run admin JS on the chat dashboard page */
2349
+ if ( isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu' && !isset( $_GET['action'] ) ) {
2350
+ wplc_admin_remote_dashboard_scripts($wplc_settings);
2351
+ }
2352
+ }
2353
+
2354
+ if( isset( $_GET['page'] ) && $_GET['page'] === "wplivechat-menu-offline-messages"){
2355
+ wplc_admin_output_js();
2356
+ }
2357
+ } else {
2358
+ do_action("wplc_hook_superadmin_head");
2359
+
2360
+ if ( isset( $_GET['page'] ) && isset( $_GET['action'] ) && $_GET['page'] == "wplivechat-menu" && ( $_GET['action'] != 'welcome' && $_GET['action'] != 'credits' ) ) {
2361
+ /* admin chat box page */
2362
+ if (function_exists("wplc_register_pro_version")) {
2363
+ wplc_return_pro_admin_chat_javascript(sanitize_text_field($_GET['cid']));
2364
+ } else {
2365
+
2366
+ /** set the global chat data here so we dont need to keep getting it from the DB or Cloud server */
2367
+ global $admin_chat_data;
2368
+ $admin_chat_data = wplc_get_chat_data($_GET['cid'], __LINE__);
2369
+
2370
+ wplc_return_admin_chat_javascript(sanitize_text_field($_GET['cid']));
2371
+
2372
+
2373
+ }
2374
+ do_action("wplc_hook_admin_javascript_chat");
2375
+ } else {
2376
+ /* load this on every other admin page */
2377
+ if (function_exists("wplc_register_pro_version")) {
2378
+ wplc_pro_admin_javascript();
2379
+ } else {
2380
+ wplc_admin_javascript();
2381
+ }
2382
+ do_action("wplc_hook_admin_javascript");
2383
+ }
2384
+
2385
+
2386
+ ?>
2387
+ <script type="text/javascript">
2388
+
2389
+
2390
+ function wplc_desktop_notification() {
2391
+ if (typeof Notification !== 'undefined') {
2392
+ if (!Notification) {
2393
+ return;
2394
+ }
2395
+ if (Notification.permission !== "granted")
2396
+ Notification.requestPermission();
2397
+
2398
+ var wplc_desktop_notification = new Notification('<?php _e('New chat received', 'wplivechat'); ?>', {
2399
+ icon: wplc_notification_icon_url,
2400
+ body: "<?php _e("A new chat has been received. Please go the 'Live Chat' page to accept the chat", "wplivechat"); ?>"
2401
+ });
2402
+ //Notification.close()
2403
+ }
2404
+ }
2405
+
2406
+ </script>
2407
+ <?php
2408
+
2409
+ }
2410
+ }
2411
+
2412
+ function old_wplc_superadmin_javascript() {
2413
+
2414
+ if (isset($_GET['page']) && ($_GET['page'] == 'wplivechat-menu' || $_GET['page'] == 'wplivechat-menu-settings' || $_GET['page'] == 'wplivechat-menu-offline-messages' || $_GET['page'] == 'wplc-pro-custom-fields' ) ) {
2415
+
2416
+ if (!isset($_GET['action'])) {
2417
+ if (function_exists("wplc_register_pro_version")) {
2418
+ wplc_pro_admin_javascript();
2419
+ } else {
2420
+ wplc_admin_javascript();
2421
+ }
2422
+ do_action("wplc_hook_admin_javascript");
2423
+ } // main page
2424
+ else if ( isset($_GET['action']) && ( $_GET['action'] != 'welcome' && $_GET['action'] != 'credits' && $_GET['action'] != 'history' ) ) {
2425
+ if (function_exists("wplc_register_pro_version")) {
2426
+ wplc_return_pro_admin_chat_javascript(sanitize_text_field($_GET['cid']));
2427
+ } else {
2428
+
2429
+ /** set the global chat data here so we dont need to keep getting it from the DB or Cloud server */
2430
+ global $admin_chat_data;
2431
+ $admin_chat_data = wplc_get_chat_data($_GET['cid'], __LINE__);
2432
+
2433
+ wplc_return_admin_chat_javascript(sanitize_text_field($_GET['cid']));
2434
+
2435
+
2436
+ }
2437
+ do_action("wplc_hook_admin_javascript_chat");
2438
+ }
2439
+ }
2440
+
2441
+
2442
+ do_action("wplc_hook_superadmin_head");
2443
+
2444
+ ?>
2445
+ <script type="text/javascript">
2446
+
2447
+
2448
+ function wplc_desktop_notification() {
2449
+ if (typeof Notification !== 'undefined') {
2450
+ if (!Notification) {
2451
+ return;
2452
+ }
2453
+ if (Notification.permission !== "granted")
2454
+ Notification.requestPermission();
2455
+
2456
+ var wplc_desktop_notification = new Notification('<?php _e('New chat received', 'wplivechat'); ?>', {
2457
+ icon: wplc_notification_icon_url,
2458
+ body: "<?php _e("A new chat has been received. Please go the 'Live Chat' page to accept the chat", "wplivechat"); ?>"
2459
+ });
2460
+ //Notification.close()
2461
+ }
2462
+ }
2463
+
2464
+ </script>
2465
+ <?php
2466
+ }
2467
+
2468
+
2469
+ /**
2470
+ * Admin JS set up
2471
+ * @return void
2472
+ * @since 6.0.00
2473
+ * @author Nick Duncan <nick@codecabin.co.za>
2474
+ */
2475
+ function wplc_admin_javascript() {
2476
+
2477
+ $wplc_settings = get_option("WPLC_SETTINGS");
2478
+ if ( isset( $wplc_settings['wplc_enable_all_admin_pages'] ) && $wplc_settings['wplc_enable_all_admin_pages'] === '1' ) {
2479
+ /* Run admin JS on all admin pages */
2480
+ if ( isset( $_GET['action'] ) && $_GET['action'] == "history" ) { return; }
2481
+ else {
2482
+ wplc_admin_output_js();
2483
+ }
2484
+ } else {
2485
+ /* Only run admin JS on the chat dashboard page */
2486
+ if ( isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu' && !isset( $_GET['action'] ) ) {
2487
+ wplc_admin_output_js();
2488
+ }
2489
+ }
2490
+
2491
+
2492
+
2493
+
2494
+
2495
+
2496
+
2497
+ }
2498
+
2499
+ /**
2500
+ * Outputs the admin JS on to the relevant pages, controlled by wplc_admin_javascript();
2501
+ *
2502
+ * @return void
2503
+ * @since 7.1.00
2504
+ * @author Nick Duncan
2505
+ */
2506
+ function wplc_admin_output_js() {
2507
+ $continue = apply_filters( "wplc_version_check_continue", true );
2508
+ if ($continue === true) {
2509
+
2510
+
2511
+ $ajax_nonce = wp_create_nonce("wplc");
2512
+ global $wplc_version;
2513
+
2514
+ $wplc_current_user = get_current_user_id();
2515
+ if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true )) {
2516
+
2517
+ wp_register_script('wplc-admin-js', plugins_url('js/wplc_u_admin.js', __FILE__), false, $wplc_version, false);
2518
+ wp_enqueue_script('wplc-admin-js');
2519
+ $not_icon = plugins_url('/images/wplc_notification_icon.png', __FILE__);
2520
+
2521
+ $wplc_wav_file = plugins_url('/ring.wav', __FILE__);
2522
+ $wplc_wav_file = apply_filters("wplc_filter_wav_file",$wplc_wav_file);
2523
+ wp_localize_script('wplc-admin-js', 'wplc_wav_file', $wplc_wav_file);
2524
+
2525
+ wp_localize_script('wplc-admin-js', 'wplc_ajax_nonce', $ajax_nonce);
2526
+
2527
+ wp_localize_script('wplc-admin-js', 'wplc_notification_icon', $not_icon);
2528
+
2529
+ $extra_data = apply_filters("wplc_filter_admin_javascript",array());
2530
+ wp_localize_script('wplc-admin-js', 'wplc_extra_data', $extra_data);
2531
+
2532
+ $ajax_url = admin_url('admin-ajax.php');
2533
+ $wplc_ajax_url = apply_filters("wplc_filter_ajax_url",$ajax_url);
2534
+ wp_localize_script('wplc-admin-js', 'wplc_ajaxurl', $wplc_ajax_url);
2535
+ wp_localize_script('wplc-admin-js', 'wplc_ajaxurl_home', admin_url( 'admin-ajax.php' ) );
2536
+
2537
+ $wpc_ma_js_strings = array(
2538
+ 'remove_agent' => __('Remove', 'wplivechat'),
2539
+ 'nonce' => wp_create_nonce("wplc"),
2540
+ 'user_id' => get_current_user_id(),
2541
+ 'typing_string' => __('Typing...', 'wplivechat')
2542
+
2543
+ );
2544
+ wp_localize_script('wplc-admin-js', 'wplc_admin_strings', $wpc_ma_js_strings);
2545
+
2546
+ }
2547
+ }
2548
+ }
2549
+
2550
+ function wplc_admin_menu_layout() {
2551
+
2552
+
2553
+
2554
+
2555
+ do_action("wplc_hook_admin_menu_layout");
2556
+ if (function_exists("wplc_register_pro_version")) {
2557
+ global $wplc_pro_version;
2558
+ if (floatval($wplc_pro_version) < 4 || $wplc_pro_version == "4.1.0" || $wplc_pro_version == "4.1.1") {
2559
+ ?>
2560
+ <div class='error below-h1'>
2561
+
2562
+ <p><?php _e("Dear Pro User", "wplivechat") ?><br /></p>
2563
+ <p><?php _e("You are using an outdated version of <strong>WP Live Chat Support Pro</strong>. Please", "wplivechat") ?> <a href="https://wp-livechat.com/get-updated-version/" target=\"_BLANK\"><?php _e("update to at least version", "wplivechat") ?> 4.0</a> <?php _e("to ensure all functionality is in working order", "wplivechat") ?>.</p>
2564
+ <p><strong><?php _e("You're live chat box on your website has been temporarily disabled until the Pro plugin has been updated. This is to ensure a smooth and hassle-free user experience for both yourself and your visitors.", "wplivechat") ?></strong></p>
2565
+ <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>
2566
+ <p><?php _e("If you are having difficulty updating the plugin, please contact", "wplivechat") ?> nick@wp-livechat.com</p>
2567
+
2568
+ </div>
2569
+ <?php
2570
+ }
2571
+ $wplc_ver = str_replace('.', '', $wplc_pro_version);
2572
+ $wplc_ver = intval($wplc_ver);
2573
+ if ($wplc_ver < 501) {
2574
+ ?>
2575
+ <div class='error below-h1'>
2576
+
2577
+ <p><?php _e("Dear Pro User", "wplivechat") ?><br /></p>
2578
+ <p><?php _e("You are using an outdated version of <strong>WP Live Chat Support Pro</strong>.", "wplivechat") ?></p>
2579
+ <p>
2580
+ <strong><?php _e("Please update to the latest version of WP Live Chat Support Pro", 'wplivechat'); ?>
2581
+ <a href="https://wp-livechat.com/get-updated-version/" target=\"_BLANK\"> <?php _e("Version 5.0.1", "wplivechat"); ?></a>
2582
+ <?php _e("to ensure everything is working correctly.", "wplivechat"); ?>
2583
+ </strong>
2584
+ </p>
2585
+ <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>
2586
+ <p><?php _e("If you are having difficulty updating the plugin, please contact", "wplivechat") ?> nick@wp-livechat.com</p>
2587
+
2588
+ </div>
2589
+ <?php
2590
+ }
2591
+ }
2592
+ if ( ( get_option("WPLC_V8_FIRST_TIME") == true && !class_exists("APC_Object_Cache") ) || ( isset( $_GET['action'] ) && ( $_GET['action'] == 'welcome' || $_GET['action'] == 'credits' ) ) ){
2593
+ include 'includes/welcome_page.php';
2594
+ update_option('WPLC_V8_FIRST_TIME', false);
2595
+ } else {
2596
+
2597
+ update_option('WPLC_V8_FIRST_TIME', false);
2598
+ $wplc_settings = get_option("WPLC_SETTINGS");
2599
+ if ( isset( $wplc_settings['wplc_use_node_server'] ) && $wplc_settings['wplc_use_node_server'] == 1 ) {
2600
+ //Node in use, load remote dashboard
2601
+ if ( $_GET['page'] === 'wplivechat-menu') {
2602
+ wplc_admin_dashboard_layout_node('dashboard');
2603
+
2604
+ if( isset($_GET['action']) ){
2605
+ wplc_admin_menu_layout_display();
2606
+ }
2607
+ } else {
2608
+ // we'll control this in admin_footer
2609
+ //wplc_admin_dashboard_layout_node('other');
2610
+ }
2611
+
2612
+ } else {
2613
+ if (function_exists("wplc_register_pro_version")) {
2614
+ wplc_pro_admin_menu_layout_display();
2615
+ } else {
2616
+ wplc_admin_menu_layout_display();
2617
+ }
2618
+ }
2619
+ }
2620
+ }
2621
+
2622
+
2623
+
2624
+ function wplc_first_time_tutorial() {
2625
+ if (!get_option('WPLC_FIRST_TIME_TUTORIAL')) {
2626
+
2627
+ global $wplc_basic_plugin_url;
2628
+ ?>
2629
+
2630
+
2631
+ <div id="wplcftt" style='margin-top:30px; margin-bottom:20px; width: 65%; background-color: #FFF; box-shadow: 1px 1px 3px #ccc; display:block; padding:10px; text-align:center; margin-left:auto; margin-right:auto;'>
2632
+ <img src='<?php echo $wplc_basic_plugin_url; ?>/images/wplc_notification_icon.png' width="130" align="center" />
2633
+ <h1 style='font-weight: 300; font-size: 50px; line-height: 50px;'><strong style="color: #ec822c;"><?php _e("Congratulations","wplivechat"); ?></strong></h1>
2634
+ <h2><strong><?php _e("You are now accepting live chat requests on your site.","wplivechat"); ?></strong></h2>
2635
+ <p><?php _e("The live chat box has automatically been enabled on your website.","wplivechat"); ?></p>
2636
+ <p><?php _e("Chat notifications will start appearing once visitors send a request.","wplivechat"); ?></p>
2637
+ <p><?php _e("You may <a href='?page=wplivechat-menu-settings' target='_BLANK'>modify your chat box settings here.","wplivechat"); ?></a></p>
2638
+ <p><?php _e("Experiencing issues?","wplivechat"); ?> <a href="https://wp-livechat.com/documentation/troubleshooting/" target="_BLANK" title=""><?php _e("Visit our troubleshooting section.","wplivechat"); ?></a></p>
2639
+
2640
+ <p><button id="wplc_close_ftt" class="button button-secondary"><?php _e("Hide","wplivechat"); ?></button></p>
2641
+
2642
+ </div>
2643
+
2644
+ <?php }
2645
+ }
2646
+
2647
+
2648
+ /**
2649
+ * Control the content below the visitor count
2650
+ * @return void
2651
+ * @since 6.0.00
2652
+ * @author Nick Duncan <nick@codecabin.co.za>
2653
+ */
2654
+ add_filter("wplc_filter_chat_dahsboard_visitors_online_bottom","wplc_filter_control_chat_dashboard_visitors_online_bottom",10);
2655
+ function wplc_filter_control_chat_dashboard_visitors_online_bottom($text) {
2656
+ $text = "<hr />";
2657
+ $text .= "<p class='wplc-agent-info' id='wplc-agent-info'>";
2658
+ $text .= " <span class='wplc_agents_online'>1</span>";
2659
+ $text .= " <a href='javascript:void(0);'>".__("Agent(s) online","wplivechat")."</a>";
2660
+ $text .= "</p>";
2661
+ return $text;
2662
+ }
2663
+
2664
+
2665
+ add_action("wplc_hook_chat_dashboard_bottom","wplc_hook_control_chat_dashboard_bottom",10);
2666
+ /**
2667
+ * Decides whether or not to show the available extensions for this area.
2668
+ * @return void
2669
+ * @since 6.0.00
2670
+ * @author Nick Duncan <nick@codecabin.co.za>
2671
+ */
2672
+ function wplc_hook_control_chat_dashboard_bottom() {
2673
+ echo "<p id='wplc_footer_message' style='display:none;'>";
2674
+ ?>
2675
+ <?php _e("With the Pro add-on of WP Live Chat Support, you can", "wplivechat"); ?>
2676
+ <a href="http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate1" title="<?php _e("see who's online and initiate chats", "wplivechat"); ?>" target=\"_BLANK\">
2677
+ <?php _e("initiate chats", "wplivechat"); ?>
2678
+ </a> <?php _e("with your online visitors with the click of a button.", "wplivechat"); ?>
2679
+ <a href="http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate2" title="<?php _e("Buy the Pro add-on now.", "wplivechat"); ?>" target=\"_BLANK\">
2680
+ <strong>
2681
+ <?php _e("Buy the Pro add-on now.", "wplivechat"); ?>
2682
+ </strong>
2683
+ </a>
2684
+ <?php
2685
+ echo "</p>";
2686
+
2687
+
2688
+
2689
+ }
2690
+
2691
+
2692
+ function wplc_admin_menu_layout_display() {
2693
+
2694
+ $wplc_current_user = get_current_user_id();
2695
+
2696
+ if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true ) ){
2697
+ /*
2698
+ -- modified in in 6.0.04 --
2699
+
2700
+ if(current_user_can('wplc_ma_agent') || current_user_can('manage_options')){
2701
+ */
2702
+ do_action("wplc_hook_admin_menu_layout_display_top");
2703
+
2704
+ wplc_stats("chat_dashboard");
2705
+
2706
+ global $wplc_basic_plugin_url;
2707
+ if (!isset($_GET['action'])) {
2708
+ ?>
2709
+ <style>
2710
+ #wplc-support-tabs a.wplc-support-link {
2711
+ background: url('<?php echo $wplc_basic_plugin_url; ?>/images/support.png');
2712
+ right: 0px;
2713
+ top: 250px;
2714
+ height: 108px;
2715
+ width: 45px;
2716
+ margin: 0;
2717
+ padding: 0;
2718
+ position: fixed;
2719
+ z-index: 9999;
2720
+ display:block;
2721
+ }
2722
+ </style>
2723
+ <div class='wplc_network_issue' style='display:none;'>
2724
+
2725
+ </div>
2726
+
2727
+ <div id="wplc-support-tabs">
2728
+ <a class="wplc-support-link wplc-rotate" href="?page=wplivechat-menu-support-page"></a>
2729
+ </div>
2730
+ <div class='wplc_page_title'>
2731
+ <img src='<?php echo WPLC_BASIC_PLUGIN_URL; ?>images/wplc-logo.png' class='wplc-logo' />
2732
+ <?php wplc_first_time_tutorial(); ?>
2733
+ <?php do_action("wplc_hook_chat_dashboard_above"); ?>
2734
+
2735
+ <p><?php _e("Please note: This window must be open in order to receive new chat notifications.", "wplivechat"); ?></p>
2736
+ </div>
2737
+
2738
+ <?php
2739
+ $continue = apply_filters( "wplc_version_check_continue", true );
2740
+ if ($continue !== true) {
2741
+
2742
+ echo "<hr />";
2743
+ echo "<center>";
2744
+ echo "<h1>".$continue."</h1>";
2745
+ echo "<p>".sprintf( __( 'Need help? <a href="%s" target="_BLANK">contact us</a>.', 'wplivechat'),'https://wp-livechat.com/contact-us/')."</p>";
2746
+ echo "</center>";
2747
+
2748
+
2749
+ } else {
2750
+
2751
+ ?>
2752
+
2753
+
2754
+ <div id="wplc_sound"></div>
2755
+
2756
+ <div id="wplc_admin_chat_holder">
2757
+ <div id='wplc_admin_chat_info_new'>
2758
+ <div class='wplc_chat_vis_count_box'>
2759
+ <?php do_action("wplc_hook_chat_dahsboard_visitors_online_top"); ?>
2760
+ <span class='wplc_vis_online'>0</span>
2761
+ <span style='text-transform:uppercase;'>
2762
+ <?php _e("Visitors online","wplivechat"); ?>
2763
+ </span>
2764
+ <?php echo apply_filters("wplc_filter_chat_dahsboard_visitors_online_bottom",""); ?>
2765
+
2766
+
2767
+ </div>
2768
+
2769
+ <?php do_action("wplc_after_chat_visitor_count_hook"); ?>
2770
+
2771
+ </div>
2772
+
2773
+ <div id="wplc_admin_chat_area_new">
2774
+ <div style="display:block;padding:10px;">
2775
+ <ul class='wplc_chat_ul_header'>
2776
+ <li><span class='wplc_header_vh wplc_headerspan_v'><?php _e("Visitor","wplivechat"); ?></span></li>
2777
+ <li><span class='wplc_header_vh wplc_headerspan_t'><?php _e("Time","wplivechat"); ?></span></li>
2778
+ <li><span class='wplc_header_vh wplc_headerspan_nr'><?php _e("Type","wplivechat"); ?></span></li>
2779
+ <li><span class='wplc_header_vh wplc_headerspan_dev'><?php _e("Device","wplivechat"); ?></span></li>
2780
+ <li><span class='wplc_header_vh wplc_headerspan_d'><?php _e("Data","wplivechat"); ?></span></li>
2781
+ <li><span class='wplc_header_vh wplc_headerspan_s'><?php _e("Status","wplivechat"); ?></span></li>
2782
+ <li><span class='wplc_header_vh wplc_headerspan_a'><?php _e("Action","wplivechat"); ?></span></li>
2783
+ </ul>
2784
+ <ul id='wplc_chat_ul'>
2785
+ </ul>
2786
+ <br />
2787
+ <hr />
2788
+ <?php do_action("wplc_hook_chat_dashboard_bottom"); ?>
2789
+
2790
+ </div>
2791
+
2792
+ </div>
2793
+ </div>
2794
+ <?php } ?>
2795
+
2796
+
2797
+
2798
+
2799
+ <?php
2800
+ } else {
2801
+ if (isset($_GET['aid'])) { $aid = $_GET['aid']; } else { $aid = null; }
2802
+ do_action("wplc_hook_admin_menu_layout_display_1",$_GET['action'],$_GET['cid'],$aid);
2803
+
2804
+ if (!is_null($aid)) {
2805
+ do_action("wplc_hook_update_agent_id",$_GET['cid'],$aid);
2806
+ }
2807
+
2808
+ do_action("wplc_hook_admin_menu_layout_display_1",$_GET['action'],$_GET['cid'],$aid);
2809
+
2810
+ if ($_GET['action'] == 'ac') {
2811
+ do_action('wplc_hook_accept_chat',$_GET,$aid);
2812
+ }
2813
+ do_action("wplc_hook_admin_menu_layout_display",$_GET['action'],$_GET['cid'],$aid);
2814
+ }
2815
+ } else {
2816
+ ?>
2817
+
2818
+ <h1><?php _e("Chat Dashboard","wplivechat"); ?></h1>
2819
+ <div id="welcome-panel" class="welcome-panel">
2820
+ <div class="welcome-panel-content">
2821
+ <h2><?php _e("Oh no!","wplivechat"); ?></h2>
2822
+ <p class="about-description">
2823
+ <?php _e(
2824
+ "You do not have access to this page as <strong>you are not a chat agent</strong>.",
2825
+ "wplivechat"
2826
+ ); ?>
2827
+ </p>
2828
+ <p>Users with access to this page are as follows:</p>
2829
+ <p>
2830
+ <?php
2831
+ $user_array = get_users(array(
2832
+ 'meta_key' => 'wplc_ma_agent',
2833
+ ));
2834
+ echo "<ol>";
2835
+ if ($user_array) {
2836
+ foreach ($user_array as $user) {
2837
+ echo "<li> ".$user->display_name . " (ID: ".$user->ID.")</li>";
2838
+ }
2839
+ }
2840
+ echo "</ol>";
2841
+ ?>
2842
+ </p>
2843
+ </div>
2844
+ </div>
2845
+ <?php
2846
+ }
2847
+ }
2848
+
2849
+ add_action("wplc_hook_change_status_on_answer","wplc_hook_control_change_status_on_answer",10,2);
2850
+ function wplc_hook_control_change_status_on_answer($get_data, $chat_data = false) {
2851
+
2852
+ $user_ID = get_current_user_id();
2853
+ wplc_change_chat_status(sanitize_text_field($get_data['cid']), 3,$user_ID );
2854
+ wplc_record_chat_notification("joined",$get_data['cid'],array("aid"=>$user_ID));
2855
+ }
2856
+
2857
+
2858
+ add_action('wplc_hook_accept_chat','wplc_hook_control_accept_chat',10,2);
2859
+ function wplc_hook_control_accept_chat($get_data,$aid) {
2860
+
2861
+ global $admin_chat_data;
2862
+
2863
+ if (!$admin_chat_data) {
2864
+ $chat_data = wplc_get_chat_data($get_data['cid'], __LINE__);
2865
+ } else {
2866
+ if (isset($admin_chat_data->id) && intval($admin_chat_data->id) === intval($get_data['cid'])) {
2867
+ $chat_data = $admin_chat_data;
2868
+ } else {
2869
+ /* chat ID's dont match, get the data for the correct chat ID */
2870
+ $chat_data = wplc_get_chat_data($get_data['cid'], __LINE__);
2871
+ }
2872
+ }
2873
+
2874
+
2875
+
2876
+
2877
+
2878
+ do_action("wplc_hook_accept_chat_url",$get_data, $chat_data);
2879
+
2880
+ do_action("wplc_hook_change_status_on_answer",$get_data, $chat_data);
2881
+
2882
+
2883
+ if (function_exists("wplc_register_pro_version")) {
2884
+ /* backwards compatibility */
2885
+ wplc_pro_draw_chat_area(sanitize_text_field($get_data['cid']));
2886
+ } else {
2887
+ do_action("wplc_hook_draw_chat_area",$get_data, $chat_data);
2888
+
2889
+ }
2890
+
2891
+
2892
+ }
2893
+
2894
+ /**
2895
+ * Hook to accept chat
2896
+ *
2897
+ * @since 7.1.00
2898
+ * @param
2899
+ * @return void
2900
+ * @author Nick Duncan (nick@codecabin.co.za)
2901
+ *
2902
+ */
2903
+ add_action( 'wplc_hook_accept_chat_url' , 'wplc_b_hook_control_accept_chat_url', 5, 2);
2904
+ remove_action( 'wplc_hook_accept_chat_url' , 'wplc_ma_hook_control_accept_chat_url', 10, 2); /* remove the older Pro hook as this was moved now to the basic version in 7.1.00 */
2905
+ function wplc_b_hook_control_accept_chat_url($get_data, $chat_data = false) {
2906
+ if (!isset($get_data['agent_id'])) {
2907
+ /* free version */
2908
+ wplc_b_update_agent_id(sanitize_text_field($get_data['cid']), get_current_user_id());
2909
+ } else {
2910
+ wplc_b_update_agent_id(sanitize_text_field($get_data['cid']), sanitize_text_field($get_data['agent_id']));
2911
+ }
2912
+
2913
+ }
2914
+
2915
+ /**
2916
+ * Assign the chat to the agent
2917
+ *
2918
+ * Replaces the same function of a different name in the older pro version
2919
+ *
2920
+ * @since 7.1.00
2921
+ * @param
2922
+ * @return void
2923
+ * @author Nick Duncan (nick@codecabin.co.za)
2924
+ *
2925
+ */
2926
+ function wplc_b_update_agent_id($cid, $aid){
2927
+ global $wpdb;
2928
+ global $wplc_tblname_chats;
2929
+ $sql = "SELECT * FROM `$wplc_tblname_chats` WHERE `id` = '$cid' LIMIT 1";
2930
+ $result = $wpdb->get_row($sql);
2931
+ if ($result) {
2932
+ if(intval($result->status) != 3){
2933
+ $update = "UPDATE `$wplc_tblname_chats` SET `agent_id` = '$aid' WHERE `id` = '$cid' LIMIT 1";
2934
+ $wpdb->query($update);
2935
+ }
2936
+ }
2937
+ }
2938
+
2939
+
2940
+
2941
+ add_action("wplc_hook_chat_dashboard_bottom","wplc_hook_control_app_chat_dashboard_bottom",10);
2942
+ function wplc_hook_control_app_chat_dashboard_bottom() {
2943
+ //echo "<p>Tired of logging in to accept chats? Use our <a href='https://wp-livechat.com/extensions/mobile-desktop-app-extension/?utm_source=plugin&utm_medium=plugin&utm_campaign=main_app' target='_BLANK'>Android app</a> or <a href='https://wp-livechat.com/extensions/mobile-desktop-app-extension/?utm_source=plugin&utm_medium=plugin&utm_campaign=main_desktop' target='_BLANK'>desktop app</a> to monitor visitors, accept and initiate chats.</p>";
2944
+ }
2945
+
2946
+ add_action("wplc_hook_draw_chat_area","wplc_hook_control_draw_chat_area",10,2);
2947
+ function wplc_hook_control_draw_chat_area($get_data, $chat_data = false) {
2948
+
2949
+ wplc_draw_chat_area(sanitize_text_field($get_data['cid']), $chat_data);
2950
+ }
2951
+
2952
+ function wplc_draw_chat_area($cid, $chat_data = false) {
2953
+
2954
+ global $wpdb;
2955
+ global $wplc_tblname_chats;
2956
+
2957
+ $results = $wpdb->get_results(
2958
+ "
2959
+ SELECT *
2960
+ FROM $wplc_tblname_chats
2961
+ WHERE `id` = '$cid'
2962
+ LIMIT 1
2963
+ "
2964
+ );
2965
+ if ($results) { } else { $results[0] = null; } /* if chat ID doesnt exist, create the variable anyway to avoid an error. Hopefully the Chat ID exists on the server..! */
2966
+
2967
+
2968
+ $result = apply_filters("wplc_filter_chat_area_data", $results[0], $cid);
2969
+
2970
+
2971
+ ?>
2972
+ <style>
2973
+
2974
+ .wplc-clear-float-message{
2975
+ clear: both;
2976
+ }
2977
+
2978
+ .rating{
2979
+ background-color: lightgray;
2980
+ width: 80px;
2981
+ padding: 2px;
2982
+ border-radius: 4px;
2983
+ text-align: center;
2984
+ color: white;
2985
+ display: inline-block;
2986
+ float: right;
2987
+ }
2988
+
2989
+ .rating-bad {
2990
+ background-color: #AF0B0B !important;
2991
+ }
2992
+
2993
+ .rating-good {
2994
+ background-color: #368437 !important;
2995
+ }
2996
+
2997
+
2998
+ </style>
2999
+ <?php
3000
+
3001
+ $user_data = maybe_unserialize($result->ip);
3002
+ $user_ip = isset($user_data['ip']) ? $user_data['ip'] : 'Unknown';
3003
+ $browser = isset($user_data['user_agent']) ? wplc_return_browser_string($user_data['user_agent']) : "Unknown";
3004
+ $browser_image = wplc_return_browser_image($browser, "16");
3005
+
3006
+
3007
+ global $wplc_basic_plugin_url;
3008
+ if ($result->status == 1) {
3009
+ $status = __("Previous", "wplivechat");
3010
+ } else {
3011
+ $status = __("Active", "wplivechat");
3012
+ }
3013
+
3014
+ if($user_ip == ""){
3015
+ $user_ip = __('IP Address not recorded', 'wplivechat');
3016
+ } else {
3017
+ $user_ip = "<a href='http://www.ip-adress.com/ip_tracer/" . $user_ip . "' title='".__('Whois for' ,'wplivechat')." ".$user_ip."' target='_BLANK'>".$user_ip."</a>";
3018
+ }
3019
+
3020
+ echo "<h2>$status " . __( 'Chat with', 'wplivechat' ) . " " . sanitize_text_field($result->name) . "</h2>";
3021
+ if ( isset( $_GET['action'] ) && 'history' === $_GET['action'] ) {
3022
+ echo "<span class='wplc-history__date'><strong>" . __( 'Starting Time:', 'wplivechat' ) . "</strong>" . date( 'Y-m-d H:i:s', current_time( strtotime( $result->timestamp ) ) ) . "</span>";
3023
+ echo "<span class='wplc-history__date wplc-history__date-end'><strong>" . __( 'Ending Time:', 'wplivechat' ) . "</strong>" . date( 'Y-m-d H:i:s', current_time( strtotime( $result->last_active_timestamp ) ) ) . "</span>";
3024
+ }
3025
+ echo "<style>#adminmenuwrap { display:none; } #adminmenuback { display:none; } #wpadminbar { display:none; } #wpfooter { display:none; } .update-nag { display:none; }</style>";
3026
+
3027
+ echo "<div class=\"end_chat_div\">";
3028
+
3029
+ do_action("wplc_admin_chat_area_before_end_chat_button", $result);
3030
+
3031
+ echo "<a href=\"javascript:void(0);\" class=\"wplc_admin_close_chat button\" id=\"wplc_admin_close_chat\">" . __("End chat", "wplivechat") . "</a>";
3032
+
3033
+ do_action("wplc_admin_chat_area_after_end_chat_button", $result);
3034
+
3035
+ echo "</div>";
3036
+
3037
+ do_action("wplc_add_js_admin_chat_area", $cid, $chat_data);
3038
+
3039
+ echo "<div id='admin_chat_box'>";
3040
+
3041
+ $result->continue = true;
3042
+
3043
+ do_action("wplc_hook_wplc_draw_chat_area",$result);
3044
+
3045
+ if (!$result->continue) { return; }
3046
+
3047
+ echo"<div class='admin_chat_box'><div class='admin_chat_box_inner' id='admin_chat_box_area_" . $result->id . "'>".apply_filters( "wplc_chat_box_draw_chat_box_inner", "", $cid)."</div><div class='admin_chat_box_inner_bottom'>" . wplc_return_chat_response_box($cid, $result) . "</div>";
3048
+
3049
+
3050
+ echo "</div>";
3051
+ echo "<div class='admin_visitor_info'>";
3052
+ do_action("wplc_hook_admin_visitor_info_display_before",$cid);
3053
+
3054
+
3055
+ echo " <div style='float:left; width:100px;'><img src=\"//www.gravatar.com/avatar/" . md5($result->email) . "\" class=\"admin_chat_img\" /></div>";
3056
+ echo " <div style='float:left;'>";
3057
+
3058
+ echo " <div class='admin_visitor_info_box1'>";
3059
+ echo " <span class='admin_chat_name'>" . sanitize_text_field($result->name) . "</span>";
3060
+ echo " <span class='admin_chat_email'>" . sanitize_text_field($result->email) . "</span>";
3061
+ echo " </div>";
3062
+ echo " </div>";
3063
+
3064
+ echo " <div class='admin_visitor_advanced_info'>";
3065
+ echo " <strong>" . __("Site Info", "wplivechat") . "</strong>";
3066
+ echo " <hr />";
3067
+ echo " <span class='part1'>" . __("Chat initiated on:", "wplivechat") . "</span> <span class='part2'>" . esc_url($result->url) . "</span>";
3068
+ echo " </div>";
3069
+
3070
+ echo " <div class='admin_visitor_advanced_info'>";
3071
+ echo " <strong>" . __("Advanced Info", "wplivechat") . "</strong>";
3072
+ echo " <hr />";
3073
+ echo " <span class='part1'>" . __("Browser:", "wplivechat") . "</span><span class='part2'> $browser <img src='" . $wplc_basic_plugin_url . "/images/$browser_image' alt='$browser' title='$browser' /><br />";
3074
+ echo " <span class='part1'>" . __("IP Address:", "wplivechat") . "</span><span class='part2'> ".sanitize_text_field($user_ip);
3075
+ echo " </div>";
3076
+ echo "<hr />";
3077
+
3078
+ echo (apply_filters("wplc_filter_advanced_info","", sanitize_text_field($result->id), sanitize_text_field($result->name), $result));
3079
+
3080
+ echo " <div id=\"wplc_sound_update\"></div>";
3081
+
3082
+ echo "<div class='wplc_bottom_chat_info_container'>";
3083
+ echo "<h3>".__("Add-ons","wplivechat")."</h3>";
3084
+ do_action("wplc_hook_admin_visitor_info_display_after",$cid);
3085
+ echo "<a href='".admin_url('admin.php?page=wplivechat-menu-extensions-page')."' class='button button-primary' target='_BLANK'>".__("Get more add-ons","wplivechat")."</a>";
3086
+ echo "</div>";
3087
+
3088
+ echo "</div>";
3089
+
3090
+ if ($result->status != 1) {
3091
+
3092
+ do_action("wplc_hook_admin_below_chat_box",$result);
3093
+ }
3094
+
3095
+ }
3096
+
3097
+
3098
+ add_action("wplc_hook_admin_below_chat_box","wplc_hook_control_admin_below_chat_box",10);
3099
+ function wplc_hook_control_admin_below_chat_box() {
3100
+ echo "<div class='admin_chat_quick_controls'>";
3101
+ echo " <p style=\"text-align:left; font-size:11px;\">" . __('Press ENTER to send your message', 'wplivechat') . "</p>";
3102
+ echo " " . __("Assign Quick Response", "wplivechat") . " <select name='wplc_macros_select' class='wplc_macros_select' disabled><option>" . __('Select', 'wplivechat') . "</option></select> <a href='https://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=quick_resposnes' title='" . __('Add Quick Responses to your Live Chat', 'wplivechat') . "' target='_BLANK'>" . __("Pro version only", "wplivechat") . "</a>";
3103
+ echo " </div>";
3104
+ echo "</div>";
3105
+
3106
+ }
3107
+
3108
+ function wplc_return_chat_response_box($cid, $chat_data = false) {
3109
+
3110
+ $ret = "<div class=\"chat_response_box\">";
3111
+ $ret .= apply_filters("wplc_filter_typing_control_div","");
3112
+ $ret .= "<input type='text' name='wplc_admin_chatmsg' id='wplc_admin_chatmsg' value='' placeholder='" . __("type here...", "wplivechat") . "' />";
3113
+
3114
+ $ret .= apply_filters("wplc_filter_chat_upload","");
3115
+ $ret .= (!function_exists("nifty_text_edit_div") ? apply_filters("wplc_filter_chat_text_editor_upsell","") : apply_filters("wplc_filter_chat_text_editor",""));
3116
+
3117
+ $ret .= "<input id='wplc_admin_cid' type='hidden' value='$cid' />";
3118
+ $ret .= "<input id='wplc_admin_send_msg' type='button' value='" . __("Send", "wplivechat") . "' style=\"display:none;\" />";
3119
+ $ret .= "</div>";
3120
+ return $ret;
3121
+ }
3122
+
3123
+ function wplc_return_admin_chat_javascript($cid) {
3124
+ $ajax_nonce = wp_create_nonce("wplc");
3125
+ global $wplc_version;
3126
+
3127
+ $wplc_settings = get_option("WPLC_SETTINGS");
3128
+
3129
+ wp_register_script('wplc-admin-chat-server', plugins_url('js/wplc_server.js', __FILE__), false, $wplc_version, false);
3130
+ wp_enqueue_script('wplc-admin-chat-server');
3131
+
3132
+ wp_localize_script( 'wplc-admin-chat-server', 'wplc_datetime_format', array(
3133
+ 'date_format' => get_option( 'date_format' ),
3134
+ 'time_format' => get_option( 'time_format' ),
3135
+ ) );
3136
+
3137
+ global $admin_chat_data;
3138
+ if (!$admin_chat_data) {
3139
+ $cdata = wplc_get_chat_data($cid, __LINE__);
3140
+ } else {
3141
+ /* copy the stored admin chat data variable - more efficient */
3142
+ $cdata = $admin_chat_data;
3143
+ }
3144
+
3145
+ $other = maybe_unserialize($cdata->other);
3146
+
3147
+ if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
3148
+ if (isset($other['socket']) && ($other['socket'] == true || $other['socket'] == "true")) {
3149
+ if ( isset( $_GET['action'] ) && $_GET['action'] === 'history') {
3150
+ wp_localize_script('wplc-admin-chat-server', 'wplc_use_node_server', "false");
3151
+ } else {
3152
+ wp_localize_script('wplc-admin-chat-server', 'wplc_use_node_server', "true");
3153
+ wp_localize_script('wplc-admin-chat-server', 'wplc_localized_string_is_typing_single', __(" is typing...","wplivechat"));
3154
+ }
3155
+
3156
+ $wplc_node_token = get_option("wplc_node_server_secret_token");
3157
+ if(!$wplc_node_token){
3158
+ if(function_exists("wplc_node_server_token_regenerate")){
3159
+ wplc_node_server_token_regenerate();
3160
+ $wplc_node_token = get_option("wplc_node_server_secret_token");
3161
+ }
3162
+ }
3163
+ wp_localize_script('wplc-admin-chat-server', 'bleeper_api_key', $wplc_node_token);
3164
+ }
3165
+ }
3166
+
3167
+ /**
3168
+ * Create a JS object for all Agent ID's and Gravatar MD5's
3169
+ */
3170
+ $user_array = get_users(array(
3171
+ 'meta_key' => 'wplc_ma_agent',
3172
+ ));
3173
+
3174
+ $a_array = array();
3175
+ if ($user_array) {
3176
+ foreach ($user_array as $user) {
3177
+ $a_array[$user->ID] = array();
3178
+ $a_array[$user->ID]['name'] = $user->display_name;
3179
+ $a_array[$user->ID]['md5'] = md5( $user->user_email );
3180
+ }
3181
+ }
3182
+ wp_localize_script('wplc-admin-chat-server', 'wplc_agent_data', $a_array);
3183
+
3184
+ /**
3185
+ * Get the CURRENT agent's data
3186
+ */
3187
+ if(isset($_GET['aid'])){
3188
+ $agent_data = get_user_by('ID', intval($_GET['aid']));
3189
+ wp_localize_script('wplc-admin-chat-server', 'wplc_admin_agent_name', $agent_data->display_name);
3190
+ wp_localize_script('wplc-admin-chat-server', 'wplc_admin_agent_email', md5($agent_data->user_email));
3191
+ } else {
3192
+ $agent_data = get_user_by('ID', intval(get_current_user_id()));
3193
+ wp_localize_script('wplc-admin-chat-server', 'wplc_admin_agent_name', $agent_data->display_name);
3194
+ wp_localize_script('wplc-admin-chat-server', 'wplc_admin_agent_email', md5($agent_data->user_email));
3195
+ }
3196
+
3197
+
3198
+ wp_register_script('wplc-admin-chat-js', plugins_url('js/wplc_u_admin_chat.js', __FILE__), array('wplc-admin-chat-server'), $wplc_version, false);
3199
+ wp_enqueue_script('wplc-admin-chat-js');
3200
+
3201
+
3202
+ global $wplc_pro_version;
3203
+ $wplc_ver = str_replace('.', '', $wplc_pro_version);
3204
+ $checker = intval($wplc_ver);
3205
+ if (isset($wplc_settings['wplc_theme'])) { $wplc_theme = $wplc_settings['wplc_theme']; } else { $wplc_theme = "theme-default"; }
3206
+
3207
+ if ( (isset($wplc_theme) && $checker >= 6000 ) || (! function_exists("wplc_pro_version_control") ) ) {
3208
+ if($wplc_theme == 'theme-default') {
3209
+ wp_register_style('wplc-theme-palette-default', plugins_url('/css/themes/theme-default.css', __FILE__), array(), $wplc_version);
3210
+ wp_enqueue_style('wplc-theme-palette-default');
3211
+
3212
+ }
3213
+ else if($wplc_theme == 'theme-1') {
3214
+ wp_register_style('wplc-theme-palette-1', plugins_url('/css/themes/theme-1.css', __FILE__), array(), $wplc_version);
3215
+ wp_enqueue_style('wplc-theme-palette-1');
3216
+
3217
+ }
3218
+ else if($wplc_theme == 'theme-2') {
3219
+ wp_register_style('wplc-theme-palette-2', plugins_url('/css/themes/theme-2.css', __FILE__), array(), $wplc_version);
3220
+ wp_enqueue_style('wplc-theme-palette-2');
3221
+
3222
+ }
3223
+ else if($wplc_theme == 'theme-3') {
3224
+ wp_register_style('wplc-theme-palette-3', plugins_url('/css/themes/theme-3.css', __FILE__), array(), $wplc_version);
3225
+ wp_enqueue_style('wplc-theme-palette-3');
3226
+
3227
+ }
3228
+ else if($wplc_theme == 'theme-4') {
3229
+ wp_register_style('wplc-theme-palette-4', plugins_url('/css/themes/theme-4.css', __FILE__), array(), $wplc_version);
3230
+ wp_enqueue_style('wplc-theme-palette-4');
3231
+
3232
+ }
3233
+ else if($wplc_theme == 'theme-5') {
3234
+ wp_register_style('wplc-theme-palette-5', plugins_url('/css/themes/theme-5.css', __FILE__), array(), $wplc_version);
3235
+ wp_enqueue_style('wplc-theme-palette-5');
3236
+
3237
+ }
3238
+ else if($wplc_theme == 'theme-6') {
3239
+ /* custom */
3240
+ /* handled elsewhere */
3241
+
3242
+
3243
+
3244
+ }
3245
+ }
3246
+ $wplc_settings = get_option("WPLC_SETTINGS");
3247
+ $wplc_user_data = get_user_by( 'id', get_current_user_id() );
3248
+
3249
+ if (isset($cdata->agent_id)) {
3250
+ $wplc_agent_data = get_user_by( 'id', intval( $cdata->agent_id ) );
3251
+ }
3252
+
3253
+
3254
+ if( isset($wplc_settings['wplc_show_name']) && $wplc_settings['wplc_show_name'] == '1' ){ $wplc_show_name = true; } else { $wplc_show_name = false; }
3255
+ if( isset($wplc_settings['wplc_show_avatar']) && $wplc_settings['wplc_show_avatar'] ){ $wplc_show_avatar = true; } else { $wplc_show_avatar = false; }
3256
+ if( isset($wplc_settings['wplc_show_date']) && $wplc_settings['wplc_show_date'] == '1' ){ $wplc_show_date = true; } else { $wplc_show_date = false; }
3257
+ if( isset($wplc_settings['wplc_show_time']) && $wplc_settings['wplc_show_time'] == '1' ){ $wplc_show_time = true; } else { $wplc_show_time = false; }
3258
+
3259
+ $wplc_chat_detail = array( 'name' => $wplc_show_name, 'avatar' => $wplc_show_avatar, 'date' => $wplc_show_date, 'time' => $wplc_show_time );
3260
+
3261
+
3262
+ wp_enqueue_script('wplc-admin-chat-js');
3263
+ wp_localize_script( 'wplc-admin-chat-js', 'wplc_show_chat_detail', $wplc_chat_detail );
3264
+
3265
+
3266
+
3267
+ if (!empty( $wplc_agent_data ) ) {
3268
+ wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_name', $wplc_agent_data->display_name );
3269
+ wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_email', md5( $wplc_agent_data->user_email ) );
3270
+ } else {
3271
+ wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_name', ' ' );
3272
+ wp_localize_script( 'wplc-admin-chat-js', 'wplc_agent_email', ' ' );
3273
+ }
3274
+
3275
+ wp_localize_script('wplc-admin-chat-js', 'wplc_chat_name', $cdata->name);
3276
+ wp_localize_script('wplc-admin-chat-js', 'wplc_chat_email', md5($cdata->email));
3277
+
3278
+ if(class_exists("WP_REST_Request")) {
3279
+ wp_localize_script('wplc-admin-chat-js', 'wplc_restapi_enabled', '1');
3280
+ wp_localize_script('wplc-admin-chat-js', 'wplc_restapi_token', get_option('wplc_api_secret_token'));
3281
+ wp_localize_script('wplc-admin-chat-js', 'wplc_restapi_endpoint', rest_url('wp_live_chat_support/v1'));
3282
+ } else {
3283
+ wp_localize_script('wplc-admin-chat-js', 'wplc_restapi_enabled', '0');
3284
+ }
3285
+
3286
+
3287
+ if (function_exists("wplc_pro_get_admin_picture")) {
3288
+ $src = wplc_pro_get_admin_picture();
3289
+ if ($src) {
3290
+ $image = "<img src=" . $src . " width='20px' id='wp-live-chat-2-img'/>";
3291
+ } else {
3292
+ $image = " ";
3293
+ }
3294
+ } else {
3295
+ $image = " ";
3296
+ }
3297
+ $admin_pic = $image;
3298
+ wp_localize_script('wplc-admin-chat-js', 'wplc_localized_string_is_typing', __("is typing...","wplivechat"));
3299
+ wp_localize_script('wplc-user-script', 'wplc_localized_string_admin_name', apply_filters( 'wplc_filter_admin_name', 'Admin' ) );
3300
+ wp_localize_script('wplc-admin-chat-js', 'wplc_ajax_nonce', $ajax_nonce);
3301
+ wp_localize_script('wplc-admin-chat-js', 'admin_pic', $admin_pic);
3302
+
3303
+ $wplc_ding_file = plugins_url('/ding.mp3', __FILE__);
3304
+ $wplc_ding_file = apply_filters( 'wplc_filter_message_sound', $wplc_ding_file );
3305
+ wp_localize_script('wplc-admin-chat-js', 'wplc_ding_file', $wplc_ding_file);
3306
+
3307
+ $extra_data = apply_filters("wplc_filter_admin_javascript",array());
3308
+ wp_localize_script('wplc-admin-chat-js', 'wplc_extra_data', $extra_data);
3309
+
3310
+ if (isset($wplc_settings['wplc_display_name']) && $wplc_settings['wplc_display_name'] == 1) {
3311
+ $display_name = 'display';
3312
+ } else {
3313
+ $display_name = 'hide';
3314
+ }
3315
+ if (isset($wplc_settings['wplc_enable_msg_sound']) && intval($wplc_settings['wplc_enable_msg_sound']) == 1) {
3316
+ $enable_ding = '1';
3317
+ } else {
3318
+ $enable_ding = '0';
3319
+ }
3320
+ if (isset($_COOKIE['wplc_email']) && $_COOKIE['wplc_email'] != "") {
3321
+ $wplc_user_email_address = sanitize_text_field($_COOKIE['wplc_email']);
3322
+ } else {
3323
+ $wplc_user_email_address = " ";
3324
+ }
3325
+
3326
+ wp_localize_script('wplc-admin-chat-js', 'wplc_name', $display_name);
3327
+ wp_localize_script('wplc-admin-chat-js', 'wplc_enable_ding', $enable_ding);
3328
+
3329
+ $ajax_url = admin_url('admin-ajax.php');
3330
+ $home_ajax_url = $ajax_url;
3331
+
3332
+ $wplc_ajax_url = apply_filters("wplc_filter_ajax_url",$ajax_url);
3333
+ wp_localize_script('wplc-admin-chat-js', 'wplc_ajaxurl', $wplc_ajax_url);
3334
+ wp_localize_script('wplc-admin-chat-js', 'wplc_home_ajaxurl', $home_ajax_url);
3335
+
3336
+
3337
+
3338
+ $wplc_url = admin_url('admin.php?page=wplivechat-menu&action=ac&cid=' . $cid);
3339
+ wp_localize_script('wplc-admin-chat-js', 'wplc_url', $wplc_url);
3340
+
3341
+
3342
+ $wplc_string1 = __("User has opened the chat window", "wplivechat");
3343
+ $wplc_string2 = __("User has minimized the chat window", "wplivechat");
3344
+ $wplc_string3 = __("User has maximized the chat window", "wplivechat");
3345
+ $wplc_string4 = __("The chat has been ended", "wplivechat");
3346
+ wp_localize_script('wplc-admin-chat-js', 'wplc_string1', $wplc_string1);
3347
+ wp_localize_script('wplc-admin-chat-js', 'wplc_string2', $wplc_string2);
3348
+ wp_localize_script('wplc-admin-chat-js', 'wplc_string3', $wplc_string3);
3349
+ wp_localize_script('wplc-admin-chat-js', 'wplc_string4', $wplc_string4);
3350
+ wp_localize_script('wplc-admin-chat-js', 'wplc_cid', $cid);
3351
+
3352
+
3353
+ do_action("wplc_hook_admin_chatbox_javascript");
3354
+
3355
+ }
3356
+
3357
+ function wplc_activate() {
3358
+ wplc_handle_db();
3359
+ if (!get_option("WPLC_SETTINGS")) {
3360
+ $wplc_alt_text = __("Please click \'Start Chat\' to initiate a chat with an agent", "wplivechat");
3361
+ $wplc_default_visitor_name = __( "Guest", "wplivechat" );
3362
+ $wplc_admin_email = get_option('admin_email');
3363
+
3364
+ $wplc_default_settings_array = array(
3365
+ "wplc_settings_align" => "2",
3366
+ "wplc_settings_enabled" => "1",
3367
+ "wplc_powered_by_link" => "0",
3368
+ "wplc_settings_fill" => "ed832f",
3369
+ "wplc_settings_font" => "FFFFFF",
3370
+ "wplc_settings_color1" => "ED832F",
3371
+ "wplc_settings_color2" => "FFFFFF",
3372
+ "wplc_settings_color3" => "EEEEEE",
3373
+ "wplc_settings_color4" => "666666",
3374
+ "wplc_theme" => "theme-default",
3375
+ "wplc_newtheme" => "theme-2",
3376
+ "wplc_require_user_info" => '1',
3377
+ "wplc_loggedin_user_info" => '1',
3378
+ "wplc_user_alternative_text" => $wplc_alt_text,
3379
+ "wplc_user_default_visitor_name" => $wplc_default_visitor_name,
3380
+ "wplc_enabled_on_mobile" => '1',
3381
+ "wplc_display_name" => '1',
3382
+ "wplc_record_ip_address" => '0',
3383
+ "wplc_pro_chat_email_address" => $wplc_admin_email,
3384
+ "wplc_pro_fst1" => __("Questions?", "wplivechat"),
3385
+ "wplc_pro_fst2" => __("Chat with us", "wplivechat"),
3386
+ "wplc_pro_fst3" => __("Start live chat", "wplivechat"),
3387
+ "wplc_pro_sst1" => __("Start Chat", "wplivechat"),
3388
+ "wplc_pro_sst1_survey" => __("Or chat to an agent now", "wplivechat"),
3389
+ "wplc_pro_sst1e_survey" => __("Chat ended", "wplivechat"),
3390
+ "wplc_pro_sst2" => __("Connecting. Please be patient...", "wplivechat"),
3391
+ "wplc_pro_tst1" => __("Reactivating your previous chat...", "wplivechat"),
3392
+ "wplc_pro_na" => __("Chat offline. Leave a message", "wplivechat"),
3393
+ "wplc_pro_intro" => __("Hello. Please input your details so that I may help you.", "wplivechat"),
3394
+ "wplc_pro_offline1" => __("We are currently offline. Please leave a message and we'll get back to you shortly.", "wplivechat"),
3395
+ "wplc_pro_offline2" => __("Sending message...", "wplivechat"),
3396
+ "wplc_pro_offline3" => __("Thank you for your message. We will be in contact soon.", "wplivechat"),
3397
+ "wplc_pro_offline_btn" => __("Leave a message", "wplivechat"),
3398
+ "wplc_pro_offline_btn_send" => __("Send message", "wplivechat"),
3399
+ "wplc_user_enter" => __("Press ENTER to send your message", "wplivechat"),
3400
+ "wplc_text_chat_ended" => __("The chat has been ended by the operator.", "wplivechat"),
3401
+ "wplc_close_btn_text" => __("close", "wplivechat"),
3402
+ "wplc_user_welcome_chat" => __("Welcome. How may I help you?", "wplivechat"),
3403
+ 'wplc_welcome_msg' => __("Please standby for an agent. While you wait for the agent you may type your message.","wplivechat")
3404
+
3405
+ );
3406
+
3407
+ //Added V8: Default Settings array filter
3408
+ $wplc_default_settings_array = apply_filters("wplc_activate_default_settings_array", $wplc_default_settings_array);
3409
+
3410
+ add_option('WPLC_SETTINGS', $wplc_default_settings_array);
3411
+ }
3412
+
3413
+
3414
+
3415
+
3416
+
3417
+
3418
+ $admins = get_role('administrator');
3419
+ if( $admins !== null ) { $admins->add_cap('wplc_ma_agent'); }
3420
+
3421
+
3422
+ $uid = get_current_user_id();
3423
+ update_user_meta($uid, 'wplc_ma_agent', 1);
3424
+ update_user_meta($uid, "wplc_chat_agent_online", time());
3425
+
3426
+ add_option("WPLC_HIDE_CHAT", "true");
3427
+
3428
+
3429
+ do_action("wplc_activate_hook");
3430
+ }
3431
+
3432
+
3433
+
3434
+ function wplc_handle_db() {
3435
+ global $wpdb;
3436
+ global $wplc_version;
3437
+ global $wplc_tblname_chats;
3438
+ global $wplc_tblname_msgs;
3439
+ global $wplc_tblname_offline_msgs;
3440
+
3441
+ $sql = "
3442
+ CREATE TABLE " . $wplc_tblname_chats . " (
3443
+ id int(11) NOT NULL AUTO_INCREMENT,
3444
+ timestamp datetime NOT NULL,
3445
+ name varchar(700) NOT NULL,
3446
+ email varchar(700) NOT NULL,
3447
+ ip varchar(700) NOT NULL,
3448
+ status int(11) NOT NULL,
3449
+ session varchar(100) NOT NULL,
3450
+ url varchar(700) NOT NULL,
3451
+ last_active_timestamp datetime NOT NULL,
3452
+ agent_id INT(11) NOT NULL,
3453
+ other LONGTEXT NOT NULL,
3454
+ rel varchar(40) NOT NULL,
3455
+ PRIMARY KEY (id)
3456
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
3457
+ ";
3458
+
3459
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
3460
+ dbDelta($sql);
3461
+
3462
+
3463
+
3464
+
3465
+ $sql = '
3466
+ CREATE TABLE ' . $wplc_tblname_msgs . ' (
3467
+ id int(11) NOT NULL AUTO_INCREMENT,
3468
+ chat_sess_id int(11) NOT NULL,
3469
+ msgfrom varchar(150) CHARACTER SET utf8 NOT NULL,
3470
+ msg LONGTEXT CHARACTER SET utf8 NOT NULL,
3471
+ timestamp datetime NOT NULL,
3472
+ status INT(3) NOT NULL,
3473
+ originates INT(3) NOT NULL,
3474
+ other LONGTEXT NOT NULL,
3475
+ rel varchar(40) NOT NULL,
3476
+ afrom INT(10) NOT NULL,
3477
+ ato INT(10) NOT NULL,
3478
+ PRIMARY KEY (id)
3479
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
3480
+ ';
3481
+
3482
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
3483
+ @dbDelta($sql);
3484
+
3485
+ /* check for previous versions containing 'from' instead of 'msgfrom' */
3486
+ $results = $wpdb->get_results("DESC $wplc_tblname_msgs");
3487
+ $founded = 0;
3488
+ foreach ($results as $row ) {
3489
+ if ($row->Field == "from") {
3490
+ $founded++;
3491
+ }
3492
+ }
3493
+
3494
+ if ($founded>0) { $wpdb->query("ALTER TABLE ".$wplc_tblname_msgs." CHANGE `from` `msgfrom` varchar(150)"); }
3495
+
3496
+
3497
+ $sql2 = "
3498
+ CREATE TABLE " . $wplc_tblname_offline_msgs . " (
3499
+ id int(11) NOT NULL AUTO_INCREMENT,
3500
+ timestamp datetime NOT NULL,
3501
+ name varchar(700) NOT NULL,
3502
+ email varchar(700) NOT NULL,
3503
+ message varchar(700) NOT NULL,
3504
+ ip varchar(700) NOT NULL,
3505
+ user_agent varchar(700) NOT NULL,
3506
+ PRIMARY KEY (id)
3507
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
3508
+ ";
3509
+
3510
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
3511
+ @dbDelta($sql2);
3512
+
3513
+ add_option("wplc_db_version", $wplc_version);
3514
+ update_option("wplc_db_version", $wplc_version);
3515
+ }
3516
+
3517
+ function wplc_add_user_stylesheet() {
3518
+ global $wplc_version;
3519
+ if(function_exists('wplc_display_chat_contents')){
3520
+ $show_chat_contents = wplc_display_chat_contents();
3521
+ } else {
3522
+ $show_chat_contents = 1;
3523
+ }
3524
+ if($show_chat_contents >= 1){
3525
+ $wplc_settings = get_option( 'WPLC_SETTINGS' );
3526
+ if ( isset( $wplc_settings ) && isset( $wplc_settings['wplc_enable_font_awesome'] ) && '1' === $wplc_settings['wplc_enable_font_awesome'] ) {
3527
+ wp_register_style( 'wplc-font-awesome', plugins_url( '/css/font-awesome.min.css', __FILE__ ) );
3528
+
3529
+ wp_enqueue_style( 'wplc-font-awesome' );
3530
+ }
3531
+ wp_register_style('wplc-style', plugins_url('/css/wplcstyle.css', __FILE__), array(), $wplc_version);
3532
+ wp_enqueue_style('wplc-style');
3533
+
3534
+ if( isset( $wplc_settings['wplc_elem_trigger_id'] ) && trim( $wplc_settings['wplc_elem_trigger_id'] ) !== "" ) {
3535
+ if( isset( $wplc_settings['wplc_elem_trigger_type'] ) ){
3536
+ if ( $wplc_settings['wplc_elem_trigger_type'] === "0" ) {
3537
+ /* class */
3538
+ $wplc_elem_style_prefix = ".";
3539
+ } else {
3540
+ /* ID */
3541
+ $wplc_elem_style_prefix = "#";
3542
+ }
3543
+ }
3544
+
3545
+ $wplc_elem_inline_style = $wplc_elem_style_prefix.stripslashes( $wplc_settings['wplc_elem_trigger_id'] ).":hover { cursor:pointer; }";
3546
+ wp_add_inline_style( 'wplc-style', stripslashes( $wplc_elem_inline_style ) );
3547
+ }
3548
+
3549
+ // Serve the icon up over HTTPS if needs be
3550
+ //$icon = plugins_url('images/chaticon.png', __FILE__);
3551
+ $icon = plugins_url('images/iconRetina.png', __FILE__);
3552
+ $close_icon = plugins_url('images/iconCloseRetina.png', __FILE__);
3553
+
3554
+
3555
+ if ( isset( $wplc_settings['wplc_settings_bg'] ) ) {
3556
+ if ( $wplc_settings['wplc_settings_bg'] == "0" ) { $bg = false; } else { $bg = esc_attr( $wplc_settings['wplc_settings_bg'] ); }
3557
+ } else { $bg = "cloudy.jpg"; }
3558
+ if ($bg) {
3559
+ $bg = plugins_url('images/bg/'.$bg, __FILE__);
3560
+ $bg_string = "#wp-live-chat-4 { background:url('$bg') repeat; background-size: cover; }";
3561
+ } else { $bg_string = "#wp-live-chat-4 { background-color: #fff; }"; }
3562
+
3563
+ if( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] ){ $icon = preg_replace('/^http:\/\//', 'https:\/\/', $icon); }
3564
+ if( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] ){ $close_icon = preg_replace('/^http:\/\//', 'https:\/\/', $close_icon); }
3565
+ $icon = apply_filters("wplc_filter_chaticon",$icon);
3566
+
3567
+ $close_icon = apply_filters("wplc_filter_chaticon_close",$close_icon);
3568
+
3569
+ $wplc_elem_inline_style = "#wp-live-chat-header { background:url('$icon') no-repeat; background-size: cover; } #wp-live-chat-header.active { background:url('$close_icon') no-repeat; background-size: cover; } $bg_string";
3570
+ wp_add_inline_style( 'wplc-style', stripslashes( $wplc_elem_inline_style ) );
3571
+
3572
+
3573
+
3574
+ global $wplc_pro_version;
3575
+ $wplc_ver = str_replace('.', '', $wplc_pro_version);
3576
+ $checker = intval($wplc_ver);
3577
+
3578
+ if (function_exists("wplc_pro_version_control") && $checker < 6000) {
3579
+ /* old pro version backwards compatibility */
3580
+ wp_register_style('wplc-style-pro', plugins_url('/css/wplcstyle_old.css', __FILE__));
3581
+ wp_enqueue_style('wplc-style-pro');
3582
+
3583
+
3584
+ }
3585
+
3586
+
3587
+
3588
+ $wplc_settings = get_option('WPLC_SETTINGS');
3589
+ if (isset($wplc_settings['wplc_theme'])) { $wplc_theme = $wplc_settings['wplc_theme']; } else { $wplc_theme = "theme-default"; }
3590
+
3591
+ if ( (isset($wplc_theme) && $checker >= 6000 ) || (! function_exists("wplc_pro_version_control") ) ) {
3592
+ if($wplc_theme == 'theme-default') {
3593
+ wp_register_style('wplc-theme-palette-default', plugins_url('/css/themes/theme-default.css', __FILE__), array(), $wplc_version);
3594
+ wp_enqueue_style('wplc-theme-palette-default');
3595
+
3596
+ }
3597
+ else if($wplc_theme == 'theme-1') {
3598
+ wp_register_style('wplc-theme-palette-1', plugins_url('/css/themes/theme-1.css', __FILE__), array(), $wplc_version);
3599
+ wp_enqueue_style('wplc-theme-palette-1');
3600
+
3601
+ }
3602
+ else if($wplc_theme == 'theme-2') {
3603
+ wp_register_style('wplc-theme-palette-2', plugins_url('/css/themes/theme-2.css', __FILE__), array(), $wplc_version);
3604
+ wp_enqueue_style('wplc-theme-palette-2');
3605
+
3606
+ }
3607
+ else if($wplc_theme == 'theme-3') {
3608
+ wp_register_style('wplc-theme-palette-3', plugins_url('/css/themes/theme-3.css', __FILE__), array(), $wplc_version);
3609
+ wp_enqueue_style('wplc-theme-palette-3');
3610
+
3611
+ }
3612
+ else if($wplc_theme == 'theme-4') {
3613
+ wp_register_style('wplc-theme-palette-4', plugins_url('/css/themes/theme-4.css', __FILE__), array(), $wplc_version);
3614
+ wp_enqueue_style('wplc-theme-palette-4');
3615
+
3616
+ }
3617
+ else if($wplc_theme == 'theme-5') {
3618
+ wp_register_style('wplc-theme-palette-5', plugins_url('/css/themes/theme-5.css', __FILE__), array(), $wplc_version);
3619
+ wp_enqueue_style('wplc-theme-palette-5');
3620
+
3621
+ }
3622
+ else if($wplc_theme == 'theme-6') {
3623
+ /* custom */
3624
+ /* handled elsewhere */
3625
+
3626
+
3627
+
3628
+ }
3629
+
3630
+
3631
+
3632
+
3633
+
3634
+ if (isset($wplc_settings['wplc_newtheme'])) { $wplc_newtheme = $wplc_settings['wplc_newtheme']; } else { $wplc_newtheme = "theme-2"; }
3635
+ if (isset($wplc_newtheme)) {
3636
+ if($wplc_newtheme == 'theme-1') {
3637
+ wp_register_style('wplc-theme-classic', plugins_url('/css/themes/classic.css', __FILE__), array(), $wplc_version);
3638
+ wp_enqueue_style('wplc-theme-classic');
3639
+
3640
+ }
3641
+ else if($wplc_newtheme == 'theme-2') {
3642
+ wp_register_style('wplc-theme-modern', plugins_url('/css/themes/modern.css', __FILE__), array(), $wplc_version);
3643
+ wp_enqueue_style('wplc-theme-modern');
3644
+
3645
+ }
3646
+ }
3647
+
3648
+ if ($wplc_settings["wplc_settings_align"] == 1) {
3649
+ wp_register_style('wplc-theme-position', plugins_url('/css/themes/position-bottom-left.css', __FILE__), array(), $wplc_version);
3650
+ wp_enqueue_style('wplc-theme-position');
3651
+ } else if ($wplc_settings["wplc_settings_align"] == 2) {
3652
+ wp_register_style('wplc-theme-position', plugins_url('/css/themes/position-bottom-right.css', __FILE__), array(), $wplc_version);
3653
+ wp_enqueue_style('wplc-theme-position');
3654
+ } else if ($wplc_settings["wplc_settings_align"] == 3) {
3655
+ wp_register_style('wplc-theme-position', plugins_url('/css/themes/position-left.css', __FILE__), array(), $wplc_version);
3656
+ wp_enqueue_style('wplc-theme-position');
3657
+ } else if ($wplc_settings["wplc_settings_align"] == 4) {
3658
+ wp_register_style('wplc-theme-position', plugins_url('/css/themes/position-right.css', __FILE__), array(), $wplc_version);
3659
+ wp_enqueue_style('wplc-theme-position');
3660
+ } else {
3661
+ wp_register_style('wplc-theme-position', plugins_url('/css/themes/position-bottom-right.css', __FILE__), array(), $wplc_version);
3662
+ wp_enqueue_style('wplc-theme-position');
3663
+ }
3664
+
3665
+ }
3666
+
3667
+ // Gutenberg template styles - user
3668
+ wp_register_style( 'wplc-gutenberg-template-styles-user', plugins_url( '/includes/blocks/wplc-chat-box/wplc_gutenberg_template_styles.css', __FILE__ ) );
3669
+ wp_enqueue_style( 'wplc-gutenberg-template-styles-user' );
3670
+
3671
+ // GIF integration styles - user
3672
+ wp_register_style( 'wplc-gif-integration-user', plugins_url( '/css/wplc_gif_integration.css', __FILE__ ) );
3673
+ wp_enqueue_style( 'wplc-gif-integration-user' );
3674
+ }
3675
+ if(function_exists('wplc_ce_activate')){
3676
+ if(function_exists('wplc_ce_load_user_styles')){
3677
+ wplc_ce_load_user_styles();
3678
+ }
3679
+ }
3680
+ }
3681
+
3682
+
3683
+ add_action( 'init', 'wplc_online_check_script', 10 );
3684
+ /**
3685
+ * Load the JS that allows us to integrate into the WP Heartbeat
3686
+ * @return void
3687
+ */
3688
+ function wplc_online_check_script() {
3689
+ global $wplc_version;
3690
+ if (esc_attr( get_the_author_meta( 'wplc_ma_agent', get_current_user_id() ) ) == "1"){
3691
+ $ajax_nonce = wp_create_nonce("wplc");
3692
+ wp_register_script( 'wplc-heartbeat', plugins_url( 'js/wplc_heartbeat.js', __FILE__ ), array( 'jquery' ), $wplc_version, true );
3693
+ wp_enqueue_script( 'wplc-heartbeat' );
3694
+ wp_localize_script( 'wplc-heartbeat', 'wplc_transient_nonce', $ajax_nonce );
3695
+
3696
+ $wplc_ajax_url = apply_filters("wplc_filter_ajax_url", admin_url('admin-ajax.php'));
3697
+ wp_localize_script('wplc-heartbeat', 'wplc_ajaxurl', $wplc_ajax_url);
3698
+ }
3699
+ }
3700
+
3701
+ /**
3702
+ * Heartbeat integrations
3703
+ *
3704
+ */
3705
+ add_filter( 'heartbeat_received', 'wplc_heartbeat_receive', 10, 2 );
3706
+ add_filter( 'heartbeat_nopriv_received', 'wplc_heartbeat_receive', 10, 2 );
3707
+ function wplc_heartbeat_receive( $response, $data ) {
3708
+ if ( $data['client'] == 'wplc_heartbeat' ) {
3709
+ if (esc_attr( get_the_author_meta( 'wplc_ma_agent', get_current_user_id() ) ) == "1"){
3710
+ update_user_meta(get_current_user_id(), "wplc_chat_agent_online", time());
3711
+ wplc_hook_control_set_transient();
3712
+ }
3713
+ }
3714
+ return $response;
3715
+ }
3716
+
3717
+
3718
+
3719
+ /**
3720
+ * Loads the admin stylesheets for the chat dashboard and settings pages
3721
+ * @return void
3722
+ */
3723
+ function wplc_add_admin_stylesheet() {
3724
+ global $wplc_version;
3725
+
3726
+ wp_register_style( 'wplc-ace-styles', plugins_url( '/css/ace.css', __FILE__ ) );
3727
+ wp_enqueue_style( 'wplc-ace-styles' );
3728
+
3729
+ wp_register_style( 'wplc-fontawesome-iconpicker', plugins_url( '/css/fontawesome-iconpicker.css', __FILE__ ) );
3730
+ wp_enqueue_style( 'wplc-fontawesome-iconpicker' );
3731
+
3732
+ $wplc_settings = get_option("WPLC_SETTINGS");
3733
+ if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1 && (!isset($_GET['action']) || $_GET['action'] !== "history") ){
3734
+ //if(isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu'){
3735
+ //Using node, remote styles please
3736
+ //Using node, remote scripts please
3737
+ if ( isset( $wplc_settings['wplc_enable_all_admin_pages'] ) && $wplc_settings['wplc_enable_all_admin_pages'] === '1' ) {
3738
+ /* Run admin JS on all admin pages */
3739
+ wplc_admin_remote_dashboard_styles();
3740
+ } else {
3741
+ /* Only run admin JS on the chat dashboard page */
3742
+ if ( isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu' && !isset( $_GET['action'] ) ) {
3743
+ wplc_admin_remote_dashboard_styles();
3744
+ }
3745
+ }
3746
+
3747
+ wp_register_style( 'wplc-admin-remote-addition-styles', plugins_url( '/css/remote_dash_styles.css', __FILE__ ), array(), $wplc_version );
3748
+ wp_enqueue_style( 'wplc-admin-remote-addition-styles' );
3749
+
3750
+ //}
3751
+ }
3752
+ //Special new check to see if we need to add the node history styling
3753
+ if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1 && isset($_GET['action']) && $_GET['action'] == 'history'){
3754
+ wp_register_style( 'wplc-admin-node-history-styles', plugins_url( '/css/node_history_styles.css', __FILE__ ) );
3755
+ wp_enqueue_style( 'wplc-admin-node-history-styles' );
3756
+ }
3757
+
3758
+ if (isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu' && isset($_GET['action']) && ($_GET['action'] == "ac" || $_GET['action'] == "history" ) ) {
3759
+ wp_register_style('wplc-admin-chat-box-style', plugins_url('/css/admin-chat-box-style.css', __FILE__ ), false, $wplc_version );
3760
+ wp_enqueue_style('wplc-admin-chat-box-style');
3761
+ }
3762
+
3763
+ wp_register_style( 'wplc-font-awesome', plugins_url('css/font-awesome.min.css', __FILE__ ), false, $wplc_version );
3764
+ wp_enqueue_style( 'wplc-font-awesome' );
3765
+
3766
+ if (isset($_GET['page']) && ($_GET['page'] == 'wplivechat-menu' || $_GET['page'] == 'wplivechat-menu-api-keys-page' || $_GET['page'] == 'wplivechat-menu-extensions-page' || $_GET['page'] == 'wplivechat-menu-settings' || $_GET['page'] == 'wplivechat-menu-offline-messages' || $_GET['page'] == 'wplivechat-menu-history' || $_GET['page'] == 'wplivechat-menu-missed-chats' || $_GET['page'] == 'wplivechat-menu-dashboard')) {
3767
+ wp_register_style( 'wplc-jquery-ui', plugins_url( '/css/jquery-ui.css', __FILE__ ), false, $wplc_version );
3768
+ wp_enqueue_style( 'wplc-jquery-ui' );
3769
+
3770
+ wp_enqueue_script( 'jquery-ui-core' );
3771
+ wp_enqueue_script( 'jquery-effects-core' );
3772
+
3773
+ // Gutenberg template styles - admin
3774
+ wp_register_style( 'wplc-gutenberg-template-styles', plugins_url( '/includes/blocks/wplc-chat-box/wplc_gutenberg_template_styles.css', __FILE__ ) );
3775
+ wp_enqueue_style( 'wplc-gutenberg-template-styles' );
3776
+
3777
+ wp_register_style( 'wplc-admin-styles', plugins_url( '/css/admin_styles.css', __FILE__ ), false, $wplc_version );
3778
+ wp_enqueue_style( 'wplc-admin-styles' );
3779
+
3780
+ // Old admin chat style
3781
+ if ((!isset($wplc_settings['wplc_use_node_server'])) || ($wplc_settings['wplc_use_node_server'] != 1)) {
3782
+ wp_register_style( 'wplc-chat-style', plugins_url( '/css/chat-style.css', __FILE__ ), false, $wplc_version );
3783
+ wp_enqueue_style( 'wplc-chat-style' );
3784
+
3785
+ // New admin chat style
3786
+ } else if (isset($wplc_settings['wplc_use_node_server']) && ($wplc_settings['wplc_use_node_server'] == 1)) {
3787
+ wp_register_style( 'wplc-admin-chat-style', plugins_url( '/css/admin-chat-style.css', __FILE__ ), false, $wplc_version );
3788
+ wp_enqueue_style( 'wplc-admin-chat-style' );
3789
+ }
3790
+ }
3791
+
3792
+ // Gif Integration styles - admin
3793
+ wp_register_style( 'wplc-gif-integration', plugins_url( '/css/wplc_gif_integration.css', __FILE__ ) );
3794
+ wp_enqueue_style( 'wplc-gif-integration' );
3795
+
3796
+ // This loads the chat styling on all admin pages as we are using the popout dashboard
3797
+ if ( isset( $wplc_settings['wplc_use_node_server'] ) && ( $wplc_settings['wplc_use_node_server'] == 1 ) && ( isset( $wplc_settings['wplc_enable_all_admin_pages'] ) && $wplc_settings['wplc_enable_all_admin_pages'] === '1') ) {
3798
+
3799
+ wp_register_style( 'wplc-admin-chat-style', plugins_url( '/css/admin-chat-style.css', __FILE__ ), false, $wplc_version );
3800
+ wp_enqueue_style( 'wplc-admin-chat-style' );
3801
+ }
3802
+
3803
+ if (isset($_GET['page']) && $_GET['page'] == "wplivechat-menu-support-page") {
3804
+ wp_register_style('fontawesome', plugins_url('css/font-awesome.min.css', __FILE__ ), false, $wplc_version );
3805
+ wp_enqueue_style('fontawesome');
3806
+ wp_register_style('wplc-support-page-css', plugins_url('css/support-css.css', __FILE__ ), false, $wplc_version );
3807
+ wp_enqueue_style('wplc-support-page-css');
3808
+ }
3809
+
3810
+ if(isset($_GET['immersive_mode'])){
3811
+ wp_add_inline_style( 'wplc-admin-style', "#wpcontent { margin-left: 0px !important;} #wpadminbar, #wpfooter, #adminmenumain {display: none !important;}" );
3812
+ }
3813
+ }
3814
+
3815
+ if (isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu-settings') {
3816
+ add_action('admin_print_scripts', 'wplc_admin_scripts_basic');
3817
+ }
3818
+
3819
+ /**
3820
+ * Loads the admin scripts for the chat dashboard and settings pages
3821
+ * @return void
3822
+ */
3823
+ function wplc_admin_scripts_basic() {
3824
+
3825
+ $gutenberg_default_html = '<!-- Default HTML -->
3826
+ <div class="wplc_block">
3827
+ <span class="wplc_block_logo">{wplc_logo}</span>
3828
+ <span class="wplc_block_text">{wplc_text}</span>
3829
+ <span class="wplc_block_icon">{wplc_icon}</span>
3830
+ </div>';
3831
+
3832
+ if (isset($_GET['page']) && $_GET['page'] == "wplivechat-menu-settings") {
3833
+ wp_enqueue_script('jquery');
3834
+ wp_enqueue_script('jquery-ui-core');
3835
+ wp_enqueue_script('jquery-ui-tooltip');
3836
+ wp_register_script('my-wplc-color', plugins_url('js/jscolor.js', __FILE__), false, '1.4.1', false);
3837
+ wp_enqueue_script('my-wplc-color');
3838
+ wp_enqueue_script('jquery-ui-tabs');
3839
+ wp_register_script('my-wplc-tabs', plugins_url('js/wplc_tabs.js', __FILE__), array('jquery-ui-core'), '', true);
3840
+ wp_enqueue_script('my-wplc-tabs');
3841
+ wp_enqueue_media();
3842
+ wp_register_script('wplc-fontawesome-iconpicker', plugins_url('js/fontawesome-iconpicker.js', __FILE__), array('jquery'), '', true);
3843
+ wp_enqueue_script('wplc-fontawesome-iconpicker');
3844
+ wp_register_script('wplc-gutenberg', plugins_url('js/wplc_gutenberg.js', __FILE__), array('jquery'), '', true);
3845
+ wp_enqueue_script('wplc-gutenberg');
3846
+ wp_localize_script( 'wplc-gutenberg', 'default_html', $gutenberg_default_html );
3847
+ }
3848
+ }
3849
+
3850
+ /**
3851
+ * Loads basic version's settings page
3852
+ * @return void
3853
+ */
3854
+ function wplc_admin_settings_layout() {
3855
+ wplc_settings_page_basic();
3856
+ }
3857
+
3858
+ /**
3859
+ * Loads the dashboard page
3860
+ * @return void
3861
+ */
3862
+ function wplc_admin_dashboard_layout() {
3863
+ include 'includes/dashboard_page.php';
3864
+ }
3865
+
3866
+ add_action("wplc_hook_history_draw_area","wplc_hook_control_history_draw_area",10,1);
3867
+ /**
3868
+ * Display normal history page
3869
+ * @param int $cid Chat ID
3870
+ * @return void
3871
+ * @since 6.1.00
3872
+ * @author Nick Duncan <nick@codecabin.co.za>
3873
+ */
3874
+ function wplc_hook_control_history_draw_area($cid) {
3875
+ wplc_draw_chat_area($cid);
3876
+ }
3877
+
3878
+ /**
3879
+ * What to display for the chat history
3880
+ * @param int $cid Chat ID
3881
+ * @return void
3882
+ * @since 6.1.00
3883
+ * @author Nick Duncan <nick@codecabin.co.za>
3884
+ */
3885
+ function wplc_admin_view_chat_history($cid) {
3886
+ do_action("wplc_hook_history_draw_area",$cid);
3887
+ }
3888
+
3889
+
3890
+ add_action( 'wplc_hook_admin_menu_layout_display' , 'wplc_hook_control_history_get_control', 1, 3);
3891
+ /**
3892
+ * Control history GET calls
3893
+ * @param string $action The GET action
3894
+ * @param int $cid The chat id
3895
+ * @param int $aid AID
3896
+ * @return void
3897
+ * @since 6.1.00
3898
+ * @author Nick Duncan <nick@codecabin.co.za>
3899
+ */
3900
+ function wplc_hook_control_history_get_control($action,$cid,$aid) {
3901
+
3902
+ if ($action == 'history') {
3903
+ wplc_admin_view_chat_history(sanitize_text_field($cid));
3904
+ } else if ($action == 'download_history'){
3905
+
3906
+ //Moved into the init hook as of version 6.0.01 due to different functionality
3907
+
3908
+ //wplc_admin_download_history(sanitize_text_field($_GET['type']), sanitize_text_field($cid));
3909
+ }
3910
+
3911
+
3912
+ }
3913
+
3914
+
3915
+ add_action("wplc_hook_chat_history","wplc_hook_control_chat_history");
3916
+ /**
3917
+ * Renders the chat history content
3918
+ * @return string
3919
+ */
3920
+ function wplc_hook_control_chat_history() {
3921
+
3922
+ if (is_admin()) {
3923
+
3924
+ global $wpdb;
3925
+ global $wplc_tblname_chats;
3926
+ global $wplc_tblname_msgs;
3927
+
3928
+ if(isset($_GET['wplc_action']) && $_GET['wplc_action'] == 'remove_cid'){
3929
+ if(isset($_GET['cid'])){
3930
+ if(isset($_GET['wplc_confirm'])){
3931
+ //Confirmed - delete
3932
+ $delete_sql = "
3933
+ DELETE FROM $wplc_tblname_chats
3934
+ WHERE `id` = '".intval($_GET['cid'])."'
3935
+ ";
3936
+ $delete_messages = "
3937
+ DELETE FROM $wplc_tblname_msgs
3938
+ WHERE `chat_sess_id` = '".intval($_GET['cid'])."'
3939
+ ";
3940
+
3941
+ $wplc_was_error = false;
3942
+
3943
+ $wpdb->query($delete_sql);
3944
+ if ($wpdb->last_error) { $wplc_was_error = true; }
3945
+ $wpdb->query($delete_messages);
3946
+ if ($wpdb->last_error) { $wplc_was_error = true; }
3947
+
3948
+ if ($wplc_was_error) {
3949
+ echo "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>
3950
+ ".__("Error: Could not delete chat", "wplivechat")."<br>
3951
+ </div>";
3952
+ } else {
3953
+ echo "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;border-color:#67d552;'>
3954
+ ".__("Chat Deleted", "wplivechat")."<br>
3955
+ </div>";
3956
+ }
3957
+
3958
+ } else {
3959
+ //Prompt
3960
+ echo "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>
3961
+ ".__("Are you sure you would like to delete this chat?", "wplivechat")."<br>
3962
+ <a class='button' href='?page=wplivechat-menu-history&wplc_action=remove_cid&cid=".sanitize_text_field( $_GET['cid'] )."&wplc_confirm=1''>".__("Yes", "wplivechat")."</a> <a class='button' href='?page=wplivechat-menu-history'>".__("No", "wplivechat")."</a>
3963
+ </div>";
3964
+ }
3965
+ }
3966
+ }
3967
+
3968
+ $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
3969
+ $limit = 20; // number of rows in page
3970
+ $offset = ( $pagenum - 1 ) * $limit;
3971
+ $total = $wpdb->get_var( "SELECT COUNT(`id`) FROM $wplc_tblname_chats" );
3972
+ $num_of_pages = ceil( $total / $limit );
3973
+
3974
+ $results = $wpdb->get_results(
3975
+ "
3976
+ SELECT *
3977
+ FROM $wplc_tblname_chats
3978
+ WHERE `name` NOT LIKE 'agent-to-agent chat'
3979
+ ORDER BY `timestamp` DESC
3980
+ LIMIT $limit OFFSET $offset
3981
+ "
3982
+ );
3983
+ echo "
3984
+ <form method=\"post\" >
3985
+ <input type=\"submit\" value=\"".__('Delete History', 'wplivechat')."\" class='button' name=\"wplc-delete-chat-history\" /><br /><br />
3986
+ </form>
3987
+
3988
+ <table class=\"wp-list-table wplc_list_table widefat fixed \" cellspacing=\"0\">
3989
+ <thead>
3990
+ <tr>
3991
+ <th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><span>" . __("Date", "wplivechat") . "</span></th>
3992
+ <th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><span>" . __("Name", "wplivechat") . "</span></th>
3993
+ <th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\">" . __("Email", "wplivechat") . "</th>
3994
+ <th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\">" . __("URL", "wplivechat") . "</th>
3995
+ <th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\">" . __("Status", "wplivechat") . "</th>
3996
+ <th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><span>" . __("Action", "wplivechat") . "</span></th>
3997
+ </tr>
3998
+ </thead>
3999
+ <tbody id=\"the-list\" class='list:wp_list_text_link'>
4000
+ ";
4001
+ if (!$results) {
4002
+ echo "<tr><td></td><td>" . __("No chats available at the moment", "wplivechat") . "</td></tr>";
4003
+ } else {
4004
+ foreach ($results as $result) {
4005
+ unset($trstyle);
4006
+ unset($actions);
4007
+
4008
+ $tcid = sanitize_text_field( $result->id );
4009
+
4010
+
4011
+ $url = admin_url('admin.php?page=wplivechat-menu&action=history&cid=' . $tcid);
4012
+ $url2 = admin_url('admin.php?page=wplivechat-menu&action=download_history&type=csv&cid=' . $tcid);
4013
+ $url3 = "?page=wplivechat-menu-history&wplc_action=remove_cid&cid=" . $tcid;
4014
+ $actions = "
4015
+ <a href='$url' class='button' title='".__('View Chat History', 'wplivechat')."' target='_BLANK' id=''><i class='fa fa-eye'></i></a> <a href='$url2' class='button' title='".__('Download Chat History', 'wplivechat')."' target='_BLANK' id=''><i class='fa fa-download'></i></a> <a href='$url3' class='button'><i class='fa fa-trash-o'></i></a>
4016
+ ";
4017
+ $trstyle = "style='height:30px;'";
4018
+
4019
+ echo "<tr id=\"record_" . $tcid . "\" $trstyle>";
4020
+ echo "<td class='chat_id column-chat_d'>" . date("Y-m-d H:i:s", current_time( strtotime( $result->timestamp ) ) ) . "</td>";
4021
+ echo "<td class='chat_name column_chat_name' id='chat_name_" . $tcid . "'><img src=\"//www.gravatar.com/avatar/" . md5($result->email) . "?s=40\" /> " . sanitize_text_field($result->name) . "</td>";
4022
+ echo "<td class='chat_email column_chat_email' id='chat_email_" . $tcid . "'><a href='mailto:" . sanitize_text_field($result->email) . "' title='Email " . ".$result->email." . "'>" . sanitize_text_field ($result->email) . "</a></td>";
4023
+ echo "<td class='chat_name column_chat_url' id='chat_url_" . $tcid . "'>" . esc_url($result->url) . "</td>";
4024
+ echo "<td class='chat_status column_chat_status' id='chat_status_" . $tcid . "'><strong>" . wplc_return_status($result->status) . "</strong></td>";
4025
+ echo "<td class='chat_action column-chat_action' id='chat_action_" . $tcid . "'>$actions</td>";
4026
+ echo "</tr>";
4027
+ }
4028
+ }
4029
+ echo "</table>";
4030
+
4031
+ $page_links = paginate_links( array(
4032
+ 'base' => add_query_arg( 'pagenum', '%#%' ),
4033
+ 'format' => '',
4034
+ 'prev_text' => __( '&laquo;', 'wplivechat' ),
4035
+ 'next_text' => __( '&raquo;', 'wplivechat' ),
4036
+ 'total' => $num_of_pages,
4037
+ 'current' => $pagenum
4038
+ ) );
4039
+
4040
+ if ( $page_links ) {
4041
+ echo '<div class="tablenav"><div class="tablenav-pages" style="margin: 1em 0;float:none;text-align:center;">' . $page_links . '</div></div>';
4042
+ }
4043
+ }
4044
+
4045
+
4046
+ }
4047
+
4048
+ /**
4049
+ * Loads the chat history layout to accommodate basic/pro versions
4050
+ * @return string
4051
+ */
4052
+ function wplc_admin_history_layout() {
4053
+ wplc_stats("history");
4054
+ echo"<div class=\"wrap wplc_wrap\"><div id=\"icon-edit\" class=\"icon32 icon32-posts-post\"><br></div><h2>" . __("WP Live Chat History", "wplivechat") . "</h2>";
4055
+
4056
+ do_action("wplc_before_history_table_hook");
4057
+
4058
+ if(function_exists("wplc_ce_activate")){
4059
+ wplc_ce_admin_display_history();
4060
+ } else if (function_exists("wplc_register_pro_version")) {
4061
+ wplc_pro_admin_display_history();
4062
+ } else {
4063
+ do_action("wplc_hook_chat_history");
4064
+ }
4065
+ }
4066
+
4067
+
4068
+ add_action("wplc_hook_chat_missed","wplc_hook_control_missed_chats",10);
4069
+ /**
4070
+ * Loads missed chats contents
4071
+ * @return string
4072
+ */
4073
+ function wplc_hook_control_missed_chats() {
4074
+ if (function_exists('wplc_admin_display_missed_chats')) { wplc_admin_display_missed_chats(); }
4075
+ }
4076
+
4077
+ /**
4078
+ * Loads the missed chats page wrapper
4079
+ * @return string
4080
+ */
4081
+ function wplc_admin_missed_chats() {
4082
+ wplc_stats("missed");
4083
+ echo "<div class=\"wrap wplc_wrap\"><div id=\"icon-edit\" class=\"icon32 icon32-posts-post\"><br></div><h2>" . __("WP Live Chat Missed Chats", "wplivechat") . "</h2>";
4084
+ do_action("wplc_hook_chat_missed");
4085
+ }
4086
+
4087
+ add_action("wplc_hook_offline_messages_display","wplc_hook_control_offline_messages_display",10);
4088
+ /**
4089
+ * Loads the offline messages page contents
4090
+ * @return string
4091
+ */
4092
+ function wplc_hook_control_offline_messages_display() {
4093
+ if (function_exists("wplc_admin_display_offline_messages_new")) { wplc_admin_display_offline_messages_new(); } else {
4094
+ if (function_exists("wplc_register_pro_version")) {
4095
+ if (function_exists('wplc_pro_admin_display_offline_messages')) {
4096
+ wplc_pro_admin_display_offline_messages();
4097
+ } else {
4098
+ echo "<div class='updated'><p>" . __('Please update to the latest version of WP Live Chat Support Pro to start recording any offline messages.', 'wplivechat') . "</p></div>";
4099
+ }
4100
+ } else {
4101
+ echo "<br /><br >" . _('This option is only available in the ', 'wplivechat') . "<a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=history1\" title=\"" . __("Pro Add-on", "wplivechat") . "\" target=\"_BLANK\">" . __('Pro Add-on', 'wplivechat') . "</a> of WP Live Chat. <a href=\"http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=missed_chats2\" title=\"" . __("Pro Add-on", "wplivechat") . "\" target=\"_BLANK\"></a>";
4102
+ }
4103
+ }
4104
+
4105
+ }
4106
+
4107
+ /**
4108
+ * Control who should see the offline messages
4109
+ * @return void
4110
+ */
4111
+ function wplc_admin_offline_messages() {
4112
+ wplc_stats("offline_messages");
4113
+ echo"<div class=\"wrap wplc_wrap\"><div id=\"icon-edit\" class=\"icon32 icon32-posts-post\"><br></div><h2>" . __("WP Live Chat Offline Messages", "wplivechat") . "</h2>";
4114
+ do_action("wplc_hook_offline_messages_display");
4115
+ }
4116
+
4117
+ /**
4118
+ * Output the offline messages in an HTML table
4119
+ * @return void
4120
+ */
4121
+ function wplc_admin_display_offline_messages_new() {
4122
+
4123
+ global $wpdb;
4124
+ global $wplc_tblname_offline_msgs;
4125
+
4126
+ echo "
4127
+ <table class=\"wp-list-table wplc_list_table widefat \" cellspacing=\"0\">
4128
+ <thead>
4129
+ <tr>
4130
+ <th class='manage-column column-id'><span>" . __("Date", "wplivechat") . "</span></th>
4131
+ <th scope='col' id='wplc_name_colum' class='manage-column column-id'><span>" . __("Name", "wplivechat") . "</span></th>
4132
+ <th scope='col' id='wplc_email_colum' class='manage-column column-id'>" . __("Email", "wplivechat") . "</th>
4133
+ <th scope='col' id='wplc_message_colum' class='manage-column column-id'>" . __("Message", "wplivechat") . "</th>
4134
+ <th scope='col' id='wplc_message_colum' class='manage-column column-id'>" . __("Actions", "wplivechat") . "</th>
4135
+ </tr>
4136
+ </thead>
4137
+ <tbody id=\"the-list\" class='list:wp_list_text_link'>";
4138
+
4139
+ $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
4140
+ $limit = 20; // number of rows in page
4141
+ $offset = ( $pagenum - 1 ) * $limit;
4142
+ $total = $wpdb->get_var( "SELECT COUNT(`id`) FROM $wplc_tblname_offline_msgs" );
4143
+ $num_of_pages = ceil( $total / $limit );
4144
+
4145
+ $sql = "SELECT * FROM $wplc_tblname_offline_msgs ORDER BY `timestamp` DESC LIMIT $limit OFFSET $offset";
4146
+
4147
+ $results = $wpdb->get_results($sql);
4148
+
4149
+ if (!$results) {
4150
+ echo "<tr><td></td><td>" . __("You have not received any offline messages.", "wplivechat") . "</td></tr>";
4151
+ } else {
4152
+ foreach ($results as $result) {
4153
+ echo "<tr id=\"record_" . $result->id . "\">";
4154
+ echo "<td class='chat_id column-chat_d'>" . $result->timestamp . "</td>";
4155
+ echo "<td class='chat_name column_chat_name' id='chat_name_" . $result->id . "'><img src=\"//www.gravatar.com/avatar/" . md5($result->email) . "?s=30\" /> " . $result->name . "</td>";
4156
+ echo "<td class='chat_email column_chat_email' id='chat_email_" . $result->id . "'><a href='mailto:" . $result->email . "' title='Email " . ".$result->email." . "'>" . $result->email . "</a></td>";
4157
+ echo "<td class='chat_name column_chat_url' id='chat_url_" . $result->id . "'>" . nl2br($result->message) . "</td>";
4158
+ echo "<td class='chat_name column_chat_delete'><button class='button wplc_delete_message' title='".__('Delete Message', 'wplivechat')."' class='wplc_delete_message' mid='".$result->id."'><i class='fa fa-times'></i></button></td>";
4159
+ echo "</tr>";
4160
+ }
4161
+ }
4162
+
4163
+ echo "
4164
+ </tbody>
4165
+ </table>";
4166
+
4167
+ $page_links = paginate_links( array(
4168
+ 'base' => add_query_arg( 'pagenum', '%#%' ),
4169
+ 'format' => '',
4170
+ 'prev_text' => __( '&laquo;', 'wplivechat' ),
4171
+ 'next_text' => __( '&raquo;', 'wplivechat' ),
4172
+ 'total' => $num_of_pages,
4173
+ 'current' => $pagenum
4174
+ ) );
4175
+
4176
+ if ( $page_links ) {
4177
+ echo '<div class="tablenav"><div class="tablenav-pages" style="margin: 1em 0;float:none;text-align:center;">' . $page_links . '</div></div>';
4178
+ }
4179
+ }
4180
+
4181
+ /**
4182
+ * Loads the basic/pro version's settings pages
4183
+ * @return string
4184
+ */
4185
+ function wplc_settings_page_basic() {
4186
+ if (function_exists("wplc_register_pro_version")) {
4187
+ wplc_settings_page_pro();
4188
+ } else {
4189
+ include 'includes/settings_page.php';
4190
+ }
4191
+ }
4192
+
4193
+ /**
4194
+ * Updates chat statistics
4195
+ * @param string $sec Specify which array key of the stats you'd like access to
4196
+ * @return void
4197
+ */
4198
+ function wplc_stats($sec) {
4199
+ $wplc_stats = get_option("wplc_stats");
4200
+ if ($wplc_stats) {
4201
+ if (isset($wplc_stats[$sec]["views"])) {
4202
+ $wplc_stats[$sec]["views"] = $wplc_stats[$sec]["views"] + 1;
4203
+ $wplc_stats[$sec]["last_accessed"] = date("Y-m-d H:i:s");
4204
+ } else {
4205
+ $wplc_stats[$sec]["views"] = 1;
4206
+ $wplc_stats[$sec]["last_accessed"] = date("Y-m-d H:i:s");
4207
+ $wplc_stats[$sec]["first_accessed"] = date("Y-m-d H:i:s");
4208
+ }
4209
+
4210
+
4211
+ } else {
4212
+
4213
+ $wplc_stats[$sec]["views"] = 1;
4214
+ $wplc_stats[$sec]["last_accessed"] = date("Y-m-d H:i:s");
4215
+ $wplc_stats[$sec]["first_accessed"] = date("Y-m-d H:i:s");
4216
+
4217
+
4218
+ }
4219
+ update_option("wplc_stats",$wplc_stats);
4220
+
4221
+ }
4222
+
4223
+
4224
+ add_action("wplc_hook_head","wplc_hook_control_head");
4225
+ /**
4226
+ * Deletes the chat history on submission of POST
4227
+ * @return bool
4228
+ */
4229
+ function wplc_hook_control_head() {
4230
+ if (isset($_POST['wplc-delete-chat-history'])) {
4231
+ wplc_del_history();
4232
+ }
4233
+ }
4234
+
4235
+ /**
4236
+ * Deletes all chat history
4237
+ * @return bool
4238
+ */
4239
+ function wplc_del_history(){
4240
+ global $wpdb;
4241
+ global $wplc_tblname_chats;
4242
+ global $wplc_tblname_msgs;
4243
+ $wpdb->query("TRUNCATE TABLE $wplc_tblname_chats");
4244
+ $wpdb->query("TRUNCATE TABLE $wplc_tblname_msgs");
4245
+ }
4246
+
4247
+ add_filter("wplc_filter_chat_header_extra_attr","wplc_filter_control_chat_header_extra_attr",10,1);
4248
+ /**
4249
+ * Controls if the chat window should popup or not
4250
+ * @param array $wplc_extra_attr Extra chat data passed
4251
+ * @return string
4252
+ */
4253
+ function wplc_filter_control_chat_header_extra_attr($wplc_extra_attr) {
4254
+ $wplc_acbc_data = get_option("WPLC_SETTINGS");
4255
+ if (isset($wplc_acbc_data['wplc_auto_pop_up'])) { $extr_string = $wplc_acbc_data['wplc_auto_pop_up']; $wplc_extra_attr .= " wplc-auto-pop-up=\"".$extr_string."\""; }
4256
+
4257
+ return $wplc_extra_attr;
4258
+ }
4259
+
4260
+ /**
4261
+ * Admin side headers used to save settings
4262
+ * @return string
4263
+ */
4264
+ function wplc_head_basic() {
4265
+ global $wpdb;
4266
+
4267
+ do_action("wplc_hook_head");
4268
+
4269
+
4270
+ if (isset($_POST['wplc_save_settings'])) {
4271
+
4272
+ do_action("wplc_hook_admin_settings_save");
4273
+ if (isset($_POST['wplc_settings_align'])) { $wplc_data['wplc_settings_align'] = esc_attr($_POST['wplc_settings_align']); }
4274
+ if (isset($_POST['wplc_settings_bg'])) { $wplc_data['wplc_settings_bg'] = esc_attr($_POST['wplc_settings_bg']); }
4275
+ if (isset($_POST['wplc_environment'])) { $wplc_data['wplc_environment'] = esc_attr($_POST['wplc_environment']); }
4276
+ if (isset($_POST['wplc_settings_fill'])) { $wplc_data['wplc_settings_fill'] = esc_attr($_POST['wplc_settings_fill']); }
4277
+ if (isset($_POST['wplc_settings_font'])) { $wplc_data['wplc_settings_font'] = esc_attr($_POST['wplc_settings_font']); }
4278
+
4279
+ if (isset($_POST['wplc_settings_color1'])) { $wplc_data['wplc_settings_color1'] = esc_attr($_POST['wplc_settings_color1']); /* backwards compatibility for pro */ $wplc_data['wplc_settings_fill'] = esc_attr($_POST['wplc_settings_color1']); }
4280
+ if (isset($_POST['wplc_settings_color2'])) { $wplc_data['wplc_settings_color2'] = esc_attr($_POST['wplc_settings_color2']); /* backwards compatibility for pro */ $wplc_data['wplc_settings_font'] = esc_attr($_POST['wplc_settings_color2']); }
4281
+ if (isset($_POST['wplc_settings_color3'])) { $wplc_data['wplc_settings_color3'] = esc_attr($_POST['wplc_settings_color3']); }
4282
+ if (isset($_POST['wplc_settings_color4'])) { $wplc_data['wplc_settings_color4'] = esc_attr($_POST['wplc_settings_color4']); }
4283
+
4284
+ if (isset($_POST['wplc_settings_enabled'])) { $wplc_data['wplc_settings_enabled'] = esc_attr($_POST['wplc_settings_enabled']); }
4285
+ if (isset($_POST['wplc_powered_by_link'])) { $wplc_data['wplc_powered_by_link'] = esc_attr($_POST['wplc_powered_by_link']); }
4286
+ if (isset($_POST['wplc_auto_pop_up'])) { $wplc_data['wplc_auto_pop_up'] = esc_attr($_POST['wplc_auto_pop_up']); }
4287
+ if (isset($_POST['wplc_require_user_info'])) { $wplc_data['wplc_require_user_info'] = esc_attr($_POST['wplc_require_user_info']); } else { $wplc_data['wplc_require_user_info'] = "0"; }
4288
+ if (isset($_POST['wplc_user_default_visitor_name']) && $_POST['wplc_user_default_visitor_name'] != '') { $wplc_data['wplc_user_default_visitor_name'] = esc_attr($_POST['wplc_user_default_visitor_name']); } else { $wplc_data['wplc_user_default_visitor_name'] = __("Guest", "wplivechat"); }
4289
+ if (isset($_POST['wplc_loggedin_user_info'])) { $wplc_data['wplc_loggedin_user_info'] = esc_attr($_POST['wplc_loggedin_user_info']); } else { $wplc_data['wplc_loggedin_user_info'] = "0"; }
4290
+ if (isset($_POST['wplc_user_alternative_text']) && $_POST['wplc_user_alternative_text'] != '') { $wplc_data['wplc_user_alternative_text'] = esc_attr($_POST['wplc_user_alternative_text']); } else { $wplc_data['wplc_user_alternative_text'] = __("Please click 'Start Chat' to initiate a chat with an agent", "wplivechat"); }
4291
+ if (isset($_POST['wplc_enabled_on_mobile'])) { $wplc_data['wplc_enabled_on_mobile'] = esc_attr($_POST['wplc_enabled_on_mobile']); } else { $wplc_data['wplc_enabled_on_mobile'] = "0"; }
4292
+ if (isset($_POST['wplc_display_name'])) { $wplc_data['wplc_display_name'] = esc_attr($_POST['wplc_display_name']); }
4293
+ if (isset($_POST['wplc_display_to_loggedin_only'])) { $wplc_data['wplc_display_to_loggedin_only'] = esc_attr($_POST['wplc_display_to_loggedin_only']); }
4294
+
4295
+ if (isset($_POST['wplc_redirect_to_thank_you_page'])) { $wplc_data['wplc_redirect_to_thank_you_page'] = esc_attr($_POST['wplc_redirect_to_thank_you_page']); }
4296
+ if (isset($_POST['wplc_redirect_thank_you_url'])) { $wplc_data['wplc_redirect_thank_you_url'] = urlencode(str_replace("https:", "", str_replace("http:", "", $_POST['wplc_redirect_thank_you_url']) ) ); }
4297
+
4298
+ if (isset($_POST['wplc_is_gif_integration_enabled'] )){ $wplc_data['wplc_is_gif_integration_enabled'] = esc_attr($_POST['wplc_is_gif_integration_enabled']); }
4299
+ if (isset($_POST['wplc_preferred_gif_provider'])) { $wplc_data['wplc_preferred_gif_provider'] = esc_attr($_POST['wplc_preferred_gif_provider']); }
4300
+ if (isset($_POST['wplc_giphy_api_key'])) { $wplc_data['wplc_giphy_api_key'] = esc_attr($_POST['wplc_giphy_api_key']); }
4301
+ if (isset($_POST['wplc_tenor_api_key'])) { $wplc_data['wplc_tenor_api_key'] = esc_attr($_POST['wplc_tenor_api_key']); }
4302
+
4303
+ $wplc_data['wplc_disable_emojis'] = !empty($_POST['wplc_disable_emojis']);
4304
+
4305
+ /** DEPRECATED BY GDPR */
4306
+ /*if(isset($_POST['wplc_record_ip_address'])){ $wplc_data['wplc_record_ip_address'] = esc_attr($_POST['wplc_record_ip_address']); } else { $wplc_data['wplc_record_ip_address'] = "0"; }*/
4307
+
4308
+ $wplc_data['wplc_record_ip_address'] = "0";
4309
+
4310
+ if(isset($_POST['wplc_enable_msg_sound'])){ $wplc_data['wplc_enable_msg_sound'] = esc_attr($_POST['wplc_enable_msg_sound']); } else { $wplc_data['wplc_enable_msg_sound'] = "0"; }
4311
+
4312
+ if(isset($_POST['wplc_enable_visitor_sound'])){ $wplc_data['wplc_enable_visitor_sound'] = esc_attr($_POST['wplc_enable_visitor_sound']); } else { $wplc_data['wplc_enable_visitor_sound'] = "0"; }
4313
+
4314
+
4315
+ if(isset($_POST['wplc_enable_font_awesome'])){ $wplc_data['wplc_enable_font_awesome'] = esc_attr($_POST['wplc_enable_font_awesome']); } else { $wplc_data['wplc_enable_font_awesome'] = "0"; }
4316
+ if(isset($_POST['wplc_enable_all_admin_pages'])){ $wplc_data['wplc_enable_all_admin_pages'] = esc_attr($_POST['wplc_enable_all_admin_pages']); } else { $wplc_data['wplc_enable_all_admin_pages'] = "0"; }
4317
+
4318
+ if (isset($_POST['wplc_pro_na'])) { $wplc_data['wplc_pro_na'] = esc_attr($_POST['wplc_pro_na']); }
4319
+ if (isset($_POST['wplc_hide_when_offline'])) { $wplc_data['wplc_hide_when_offline'] = esc_attr($_POST['wplc_hide_when_offline']); }
4320
+ if (isset($_POST['wplc_pro_chat_email_address'])) { $wplc_data['wplc_pro_chat_email_address'] = esc_attr($_POST['wplc_pro_chat_email_address']); }
4321
+
4322
+ if (isset($_POST['wplc_pro_chat_email_offline_subject'])) { $wplc_data['wplc_pro_chat_email_offline_subject'] = esc_attr($_POST['wplc_pro_chat_email_offline_subject']); }
4323
+
4324
+ if (isset($_POST['wplc_pro_offline1'])) { $wplc_data['wplc_pro_offline1'] = esc_attr($_POST['wplc_pro_offline1']); }
4325
+ if (isset($_POST['wplc_pro_offline2'])) { $wplc_data['wplc_pro_offline2'] = esc_attr($_POST['wplc_pro_offline2']); }
4326
+ if (isset($_POST['wplc_pro_offline3'])) { $wplc_data['wplc_pro_offline3'] = esc_attr($_POST['wplc_pro_offline3']); }
4327
+ if (isset($_POST['wplc_pro_offline_btn'])) { $wplc_data['wplc_pro_offline_btn'] = esc_attr($_POST['wplc_pro_offline_btn']); }
4328
+ if (isset($_POST['wplc_pro_offline_btn_send'])) { $wplc_data['wplc_pro_offline_btn_send'] = esc_attr($_POST['wplc_pro_offline_btn_send']); }
4329
+ if (isset($_POST['wplc_using_localization_plugin'])){ $wplc_data['wplc_using_localization_plugin'] = esc_attr($_POST['wplc_using_localization_plugin']); }
4330
+
4331
+
4332
+ if (isset($_POST['wplc_pro_fst1'])) { $wplc_data['wplc_pro_fst1'] = esc_attr($_POST['wplc_pro_fst1']); }
4333
+ if (isset($_POST['wplc_pro_fst2'])) { $wplc_data['wplc_pro_fst2'] = esc_attr($_POST['wplc_pro_fst2']); }
4334
+ if (isset($_POST['wplc_pro_fst3'])) { $wplc_data['wplc_pro_fst3'] = esc_attr($_POST['wplc_pro_fst3']); }
4335
+ if (isset($_POST['wplc_pro_sst1'])) { $wplc_data['wplc_pro_sst1'] = esc_attr($_POST['wplc_pro_sst1']); }
4336
+ if (isset($_POST['wplc_pro_sst1_survey'])) { $wplc_data['wplc_pro_sst1_survey'] = esc_attr($_POST['wplc_pro_sst1_survey']); }
4337
+ if (isset($_POST['wplc_pro_sst1e_survey'])) { $wplc_data['wplc_pro_sst1e_survey'] = esc_attr($_POST['wplc_pro_sst1e_survey']); }
4338
+ if (isset($_POST['wplc_pro_sst2'])) { $wplc_data['wplc_pro_sst2'] = esc_attr($_POST['wplc_pro_sst2']); }
4339
+ if (isset($_POST['wplc_pro_tst1'])) { $wplc_data['wplc_pro_tst1'] = esc_attr($_POST['wplc_pro_tst1']); }
4340
+ if (isset($_POST['wplc_pro_intro'])) { $wplc_data['wplc_pro_intro'] = esc_attr($_POST['wplc_pro_intro']); }
4341
+ if (isset($_POST['wplc_user_enter'])) { $wplc_data['wplc_user_enter'] = esc_attr($_POST['wplc_user_enter']); }
4342
+ if (isset($_POST['wplc_text_chat_ended'])) { $wplc_data['wplc_text_chat_ended'] = esc_attr($_POST['wplc_text_chat_ended']); }
4343
+ if (isset($_POST['wplc_close_btn_text'])) { $wplc_data['wplc_close_btn_text'] = esc_attr($_POST['wplc_close_btn_text']); }
4344
+ if (isset($_POST['wplc_user_welcome_chat'])) { $wplc_data['wplc_user_welcome_chat'] = esc_attr($_POST['wplc_user_welcome_chat']); }
4345
+ if (isset($_POST['wplc_welcome_msg'])) { $wplc_data['wplc_welcome_msg'] = esc_attr($_POST['wplc_welcome_msg']); }
4346
+
4347
+
4348
+ if(isset($_POST['wplc_animation'])){ $wplc_data['wplc_animation'] = esc_attr($_POST['wplc_animation']); }
4349
+ if(isset($_POST['wplc_theme'])){ $wplc_data['wplc_theme'] = esc_attr($_POST['wplc_theme']); }
4350
+ if(isset($_POST['wplc_newtheme'])){ $wplc_data['wplc_newtheme'] = esc_attr($_POST['wplc_newtheme']); }
4351
+
4352
+ if(isset($_POST['wplc_elem_trigger_action'])){ $wplc_data['wplc_elem_trigger_action'] = esc_attr($_POST['wplc_elem_trigger_action']); } else{ $wplc_data['wplc_elem_trigger_action'] = "0"; }
4353
+ if(isset($_POST['wplc_elem_trigger_type'])){ $wplc_data['wplc_elem_trigger_type'] = esc_attr($_POST['wplc_elem_trigger_type']); } else { $wplc_data['wplc_elem_trigger_type'] = "0";}
4354
+ if(isset($_POST['wplc_elem_trigger_id'])){ $wplc_data['wplc_elem_trigger_id'] = esc_attr($_POST['wplc_elem_trigger_id']); } else { $wplc_data['wplc_elem_trigger_id'] = ""; }
4355
+
4356
+ if(isset($_POST['wplc_agent_select']) && $_POST['wplc_agent_select'] != "") {
4357
+ $user_array = get_users(array(
4358
+ 'meta_key' => 'wplc_ma_agent',
4359
+ ));
4360
+ if ($user_array) {
4361
+ foreach ($user_array as $user) {
4362
+ $uid = $user->ID;
4363
+ $wplc_ma_user = new WP_User( $uid );
4364
+ $wplc_ma_user->remove_cap( 'wplc_ma_agent' );
4365
+ delete_user_meta($uid, "wplc_ma_agent");
4366
+ delete_user_meta($uid, "wplc_chat_agent_online");
4367
+ }
4368
+ }
4369
+
4370
+
4371
+ $uid = intval($_POST['wplc_agent_select']);
4372
+ $wplc_ma_user = new WP_User( $uid );
4373
+ $wplc_ma_user->add_cap( 'wplc_ma_agent' );
4374
+ update_user_meta($uid, "wplc_ma_agent", 1);
4375
+ update_user_meta($uid, "wplc_chat_agent_online", time());
4376
+
4377
+ }
4378
+
4379
+
4380
+ if(isset($_POST['wplc_ban_users_ip'])){
4381
+ $wplc_banned_ip_addresses = explode('<br />', nl2br(sanitize_text_field($_POST['wplc_ban_users_ip'])));
4382
+ foreach($wplc_banned_ip_addresses as $key => $value) {
4383
+ $data[$key] = trim($value);
4384
+ }
4385
+ $wplc_banned_ip_addresses = maybe_serialize($data);
4386
+
4387
+ update_option('WPLC_BANNED_IP_ADDRESSES', $wplc_banned_ip_addresses);
4388
+ }
4389
+
4390
+ if( isset( $_POST['wplc_show_date'] ) ){ $wplc_data['wplc_show_date'] = '1'; } else { $wplc_data['wplc_show_date'] = '0'; }
4391
+ if( isset( $_POST['wplc_show_time'] ) ){ $wplc_data['wplc_show_time'] = '1'; } else { $wplc_data['wplc_show_time'] = '0'; }
4392
+
4393
+ if( isset( $_POST['wplc_show_name'] ) ){ $wplc_data['wplc_show_name'] = '1'; } else { $wplc_data['wplc_show_name'] = '0'; }
4394
+ if( isset( $_POST['wplc_show_avatar'] ) ){ $wplc_data['wplc_show_avatar'] = '1'; } else { $wplc_data['wplc_show_avatar'] = '0'; }
4395
+ $wplc_data = apply_filters("wplc_settings_save_filter_hook", $wplc_data);
4396
+
4397
+ if (isset($_POST['wplc_user_no_answer'])) { $wplc_data["wplc_user_no_answer"] = esc_attr($_POST['wplc_user_no_answer']); } else { $wplc_data["wplc_user_no_answer"] = __("There is No Answer. Please Try Again Later.", "wplivechat"); }
4398
+
4399
+ update_option('WPLC_SETTINGS', $wplc_data);
4400
+ if (isset($_POST['wplc_hide_chat'])) {
4401
+ update_option("WPLC_HIDE_CHAT", true);
4402
+ } else {
4403
+ update_option("WPLC_HIDE_CHAT", false);
4404
+ }
4405
+
4406
+
4407
+ $wplc_advanced_settings = array();
4408
+ if (isset($_POST['wplc_iterations'])) { $wplc_advanced_settings['wplc_iterations'] = esc_attr($_POST['wplc_iterations']); }
4409
+ if (isset($_POST['wplc_delay_between_loops'])) { $wplc_advanced_settings['wplc_delay_between_loops'] = esc_attr($_POST['wplc_delay_between_loops']); }
4410
+ update_option("wplc_advanced_settings",$wplc_advanced_settings);
4411
+
4412
+
4413
+ update_option('wplc_mail_type', $_POST['wplc_mail_type']);
4414
+ update_option('wplc_mail_host', $_POST['wplc_mail_host']);
4415
+ update_option('wplc_mail_port', $_POST['wplc_mail_port']);
4416
+ update_option('wplc_mail_username', $_POST['wplc_mail_username']);
4417
+ update_option('wplc_mail_password', $_POST['wplc_mail_password']);
4418
+
4419
+
4420
+ add_action( 'admin_notices', 'wplc_save_settings_action' );
4421
+ }
4422
+ if (isset($_POST['action']) && $_POST['action'] == "wplc_submit_find_us") {
4423
+ if (function_exists('curl_version')) {
4424
+ $request_url = "http://www.wp-livechat.com/apif/rec.php";
4425
+ $ch = curl_init();
4426
+ curl_setopt($ch, CURLOPT_URL, $request_url);
4427
+ curl_setopt($ch, CURLOPT_POST, 1);
4428
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
4429
+ curl_setopt($ch, CURLOPT_REFERER, $_SERVER['HTTP_HOST']);
4430
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
4431
+ $output = curl_exec($ch);
4432
+ curl_close($ch);
4433
+ }
4434
+ echo "<div class=\"updated\"><p>" . __("Thank You for your feedback!", "wplivechat") . "</p></div>";
4435
+ @wp_redirect( admin_url("/admin.php?page=wplivechat-menu&override=1") );
4436
+ }
4437
+ if( isset( $_GET['override'] ) && $_GET['override'] == '1' ){
4438
+ update_option( "WPLC_V8_FIRST_TIME", false);
4439
+ }
4440
+ }
4441
+
4442
+ function wplc_save_settings_action() { ?>
4443
+ <div class='notice notice-success updated wplc_settings_save_notice'>
4444
+ <?php _e("Your settings have been saved.", "wplivechat"); ?>
4445
+ </div>
4446
+ <?php }
4447
+
4448
+ add_action('wp_logout', 'wplc_logout');
4449
+ /**
4450
+ * Deletes the chat transient when a user logs out
4451
+ * @return bool
4452
+ */
4453
+ function wplc_logout() {
4454
+ delete_transient('wplc_is_admin_logged_in');
4455
+ }
4456
+
4457
+ /**
4458
+ * Returns the home page of the user's side
4459
+ * @return string
4460
+ */
4461
+ function wplc_get_home_path() {
4462
+ $home = get_option('home');
4463
+ $siteurl = site_url();
4464
+ if (!empty($home) && 0 !== strcasecmp($home, $siteurl)) {
4465
+ $wp_path_rel_to_home = str_ireplace($home, '', $siteurl); /* $siteurl - $home */
4466
+ $pos = strripos(str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']), trailingslashit($wp_path_rel_to_home));
4467
+ $home_path = substr($_SERVER['SCRIPT_FILENAME'], 0, $pos);
4468
+ $home_path = trailingslashit($home_path);
4469
+ } else {
4470
+ $home_path = ABSPATH;
4471
+ }
4472
+ return str_replace('\\', '/', $home_path);
4473
+ }
4474
+
4475
+ /**
4476
+ * Error checks used to ensure the user's resources meet the plugin's requirements
4477
+ */
4478
+ if(isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu-settings'){
4479
+ if(is_admin()){
4480
+
4481
+ // Only show these warning messages to Legacy users as they will be affected, not Node users.
4482
+ $wplc_settings = get_option("WPLC_SETTINGS");
4483
+ if (isset( $wplc_settings['wplc_use_node_server'] ) && intval( $wplc_settings['wplc_use_node_server'] ) == 1 ) { } else {
4484
+
4485
+ $wplc_error_count = 0;
4486
+ $wplc_admin_warnings = "<div class='error'>";
4487
+ if(!function_exists('set_time_limit')){
4488
+ $wplc_admin_warnings .= "
4489
+ <p>".__("WPLC: set_time_limit() is not enabled on this server. You may experience issues while using WP Live Chat Support as a result of this. Please get in contact your host to get this function enabled.", "wplivechat")."</p>
4490
+ ";
4491
+ $wplc_error_count++;
4492
+ }
4493
+ if(ini_get('safe_mode')){
4494
+ $wplc_admin_warnings .= "
4495
+ <p>".__("WPLC: Safe mode is enabled on this server. You may experience issues while using WP Live Chat Support as a result of this. Please contact your host to get safe mode disabled.", "wplivechat")."</p>
4496
+ ";
4497
+ $wplc_error_count++;
4498
+ }
4499
+ $wplc_admin_warnings .= "</div>";
4500
+ if($wplc_error_count > 0){
4501
+ echo $wplc_admin_warnings;
4502
+ }
4503
+ }
4504
+ }
4505
+ }
4506
+
4507
+ /**
4508
+ * Loads the contents of the extensions menu item
4509
+ * @return string
4510
+ */
4511
+ function wplc_extensions_menu() {
4512
+
4513
+ if (isset($_GET['type']) && $_GET['type'] == "additional") {
4514
+ $additional = "nav-tab-active";
4515
+ $normal = "";
4516
+ } else {
4517
+ $normal = "nav-tab-active";
4518
+ $additional = "";
4519
+ }
4520
+
4521
+ ?>
4522
+ <h2 class="nav-tab-wrapper">
4523
+ <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>
4524
+ <span style='float: right; bottom:-5px; position: relative;'><img src='<?php echo plugins_url('/images/codecabin.png', __FILE__); ?>' style="height:15px;" /></span>
4525
+ </h2>
4526
+ <div id="tab_container">
4527
+
4528
+
4529
+ <?php
4530
+ if (isset($_GET['type']) && $_GET['type'] == "additional") {
4531
+ ?>
4532
+
4533
+ <div class="wplc-extension wplc-plugin">
4534
+ <h3 class="wplc-extension-title"><?php _e("Sola Support Tickets","wplivechat"); ?></h3>
4535
+ <a href="https://wordpress.org/plugins/sola-support-tickets/" title="<?php _e("Sola Support Tickets","wplivechat"); ?>" target="_BLANK">
4536
+ <img width="320" src="<?php echo plugins_url('/images/plugin2.jpg', __FILE__); ?>" class="attachment-showcase wp-post-image" alt="<?php _e("Sola Support Tickets","wplivechat"); ?>" title="<?php _e("Sola Support Tickets","wplivechat"); ?>">
4537
+ </a>
4538
+ <p></p>
4539
+ <p><?php _e("The easiest to use Help Desk & Support Ticket plugin. Create a support help desk quickly and easily with Sola Support Tickets.","wplivechat"); ?></p>
4540
+ <p></p>
4541
+ <a href="https://wordpress.org/plugins/sola-support-tickets/" title="<?php _e("Sola Support Tickets","wplivechat"); ?>" class="button-secondary" target="_BLANK"><?php _e("Get this Plugin","wplivechat"); ?></a>
4542
+ </div>
4543
+
4544
+ <div class="wplc-extension wplc-plugin">
4545
+ <h3 class="wplc-extension-title"><?php _e("Nifty Newsletters","wplivechat"); ?></h3>
4546
+ <a href="https://wordpress.org/plugins/sola-newsletters/" title="<?php _e("Nifty Newsletters","wplivechat"); ?>" target="_BLANK">
4547
+ <img width="320" src="<?php echo plugins_url('/images/plugin1.jpg', __FILE__); ?>" class="attachment-showcase wp-post-image" alt="<?php _e("Nifty Newsletters","wplivechat"); ?>" title="<?php _e("Nifty Newsletters","wplivechat"); ?>">
4548
+ </a>
4549
+ <p></p>
4550
+ <p><?php _e("Create and send newsletters, automatic post notifications and autoresponders that are modern and beautiful with Nifty Newsletters.","wplivechat"); ?></p>
4551
+ <p></p>
4552
+ <a href="https://wordpress.org/plugins/sola-newsletters/" title="<?php _e("Nifty Newsletters","wplivechat"); ?>" class="button-secondary" target="_BLANK"><?php _e("Get this Plugin","wplivechat"); ?></a>
4553
+ </div>
4554
+
4555
+
4556
+ <?php } else {
4557
+ $filter1 = "all";
4558
+ $filter2 = "all";
4559
+
4560
+ if (isset($_GET['filter1'])) { $filter1 = $_GET['filter1']; }
4561
+ if (isset($_GET['filter2'])) { $filter2 = $_GET['filter2']; }
4562
+
4563
+ $style_strong = 'style="font-weight:bold;"';
4564
+ $style_normal = 'style="font-weight:normal;"';
4565
+
4566
+ $filter1_all_style = $style_normal;
4567
+ $filter1_free_style = $style_normal;
4568
+ $filter1_paid_style = $style_normal;
4569
+ $filter2_both_style = $style_normal;
4570
+ $filter2_free_style = $style_normal;
4571
+ $filter2_pro_style = $style_normal;
4572
+
4573
+ if ($filter1 == "all") { $filter1_all_style = $style_strong; }
4574
+ else if ($filter1 == "free") { $filter1_free_style = $style_strong; }
4575
+ else if ($filter1 == "paid") { $filter1_paid_style = $style_strong; }
4576
+ else { $filter1_all_style = $style_strong; }
4577
+ if ($filter2 == "all") { $filter2_both_style = $style_strong; }
4578
+ else if ($filter2 == "free") { $filter2_free_style = $style_strong; }
4579
+ else if ($filter2 == "pro") { $filter2_pro_style = $style_strong; }
4580
+ else { $filter2_both_style = $style_strong; }
4581
+
4582
+
4583
+ echo "<p><div style='display:block; overflow:auto; clear:both;'>";
4584
+ echo "<strong>".__("Price:","wplivechat")."</strong> ";
4585
+ echo "<a href='admin.php?page=wplivechat-menu-extensions-page&filter1=all&filter2=".$filter2."' $filter1_all_style>".__("All","wplivechat")."</a> |";
4586
+ echo "<a href='admin.php?page=wplivechat-menu-extensions-page&filter1=free&filter2=".$filter2."' $filter1_free_style>".__("Free","wplivechat")."</a> |";
4587
+ echo "<a href='admin.php?page=wplivechat-menu-extensions-page&filter1=paid&filter2=".$filter2."' $filter1_paid_style>".__("Paid","wplivechat")."</a>";
4588
+ echo "</div></p>";
4589
+ echo "<p><div style='display:block; overflow:auto; clear:both;'>";
4590
+ echo "<strong>".__("For:","wplivechat")."</strong> ";
4591
+ echo "<a href='admin.php?page=wplivechat-menu-extensions-page&filter2=all&filter1=".$filter1."' $filter2_both_style>".__("Both","wplivechat")."</a> |";
4592
+ echo "<a href='admin.php?page=wplivechat-menu-extensions-page&filter2=free&filter1=".$filter1."' $filter2_free_style>".__("Free version","wplivechat")."</a> |";
4593
+ echo "<a href='admin.php?page=wplivechat-menu-extensions-page&filter2=pro&filter1=".$filter1."' $filter2_pro_style>".__("Pro version","wplivechat")."</a>";
4594
+ echo "</div></p>";
4595
+
4596
+
4597
+ $response = wp_remote_post( "https://ccplugins.co/api-wplc-extensions", array(
4598
+ 'method' => 'POST',
4599
+ 'body' => array(
4600
+ 'action' => 'extensions',
4601
+ 'filter1' => $filter1,
4602
+ 'filter2' => $filter2
4603
+ )
4604
+ )
4605
+ );
4606
+ if(is_array($response) && isset($response['body'])){
4607
+ $data = json_decode($response['body']);
4608
+ global $wplc_version;
4609
+ $wplc_version = str_replace(",","",$wplc_version);
4610
+ if ($data) {
4611
+ $output = "";
4612
+ foreach ($data as $extension) {
4613
+ if (!isset($extension->fromversion)) { $extension->fromversion = 0; }
4614
+ if (intval($wplc_version) >= intval($extension->fromversion)) {
4615
+ $output .= '<div class="wplc-extension">';
4616
+ $output .= '<h3 class="wplc-extension-title">'.$extension->title.'</h3>';
4617
+ $output .= '<a href="'.$extension->link.'" title="'.$extension->title.'" target="_BLANK">';
4618
+ $output .= '<img width="320" height="200" src="'.$extension->image.'" class="attachment-showcase wp-post-image" alt="'.$extension->title.'" title="'.$extension->title.'">';
4619
+ $output .= '</a>';
4620
+ $output .= '<p></p>';
4621
+ $output .= '<p><div class="wplc-extension-label-box">';
4622
+ $output .= '</div></p>';
4623
+ $output .= '<p>'.$extension->description.'</p>';
4624
+ if ($extension->slug != false && is_plugin_active($extension->slug."/".$extension->slug.".php")) {
4625
+ $button = '<a href="javascriot:void(0);" title="" disabled class="button-secondary">'.__("Already installed","wplivechat").'</a>';
4626
+ } else {
4627
+ $button = '<a href="'.$extension->link.'" title="'.$extension->title.'" class="button-secondary" target="_BLANK">'.$extension->button_text.'</a>';
4628
+ }
4629
+ $output .= $button;
4630
+ $output .= '</div>';
4631
+ }
4632
+ }
4633
+ echo $output;
4634
+ }
4635
+
4636
+ }
4637
+ ?>
4638
+
4639
+
4640
+
4641
+ <?php } ?>
4642
+
4643
+ </div>
4644
+ <?php
4645
+ }
4646
+
4647
+ /**
4648
+ * Loads the contents of the support menu item
4649
+ * @return string
4650
+ */
4651
+ function wplc_support_menu() {
4652
+ wplc_stats("support");
4653
+ ?>
4654
+ <h1><?php _e("WP Live Chat Support","wplivechat"); ?></h1>
4655
+ <div class="wplc_row">
4656
+ <div class='wplc_row_col' style='background-color:#FFF;'>
4657
+ <h2><i class="fa fa-book fa-2x"></i> <?php _e("Documentation","wplivechat"); ?></h2>
4658
+ <hr />
4659
+ <p><?php _e("Getting started? Read through some of these articles to help you along your way.","wplivechat"); ?></p>
4660
+ <p><strong><?php _e("Documentation:","wplivechat"); ?></strong></p>
4661
+ <ul>
4662
+ <li><a href='https://wp-livechat.com/documentation/minimum-system-requirements/' target='_BLANK' title='<?php _e("Minimum System Requirements","wplivechat"); ?>'><?php _e("Minimum System Requirements","wplivechat"); ?></a></li>
4663
+ <li><a href='https://wp-livechat.com/documentation/do-i-have-to-be-logged-into-the-dashboard-to-chat-with-visitors/' target='_BLANK' title='<?php _e("Do I have to be logged into the dashboard to chat with visitors?","wplivechat"); ?>'><?php _e("Do I have to be logged into the dashboard to chat with visitors?","wplivechat"); ?></a></li>
4664
+ <li><a href='https://wp-livechat.com/documentation/what-are-quick-responses/' target='_BLANK' title='<?php _e("What are Quick Responses?","wplivechat"); ?>'><?php _e("What are Quick Responses?","wplivechat"); ?></a></li>
4665
+ <li><a href='https://wp-livechat.com/documentation/troubleshooting/is-this-plugin-multi-site-friendly/' target='_BLANK' title='<?php _e("Can I use this plugin on my multi-site?","wplivechat"); ?>'><?php _e("Can I use this plugin on my multi-site?","wplivechat"); ?></a></li>
4666
+ <li><a href='https://wp-livechat.com/documentation/how-do-i-disable-apc-object-cache/' target='_BLANK' title='<?php _e("How do I disable APC Object Cache?","wplivechat"); ?>'><?php _e("How do I disable APC Object Cache?","wplivechat"); ?></a></li>
4667
+ <li><a href='https://wp-livechat.com/documentation/do-you-have-a-mobile-app/' target='_BLANK' title='<?php _e("Do you have a mobile app?","wplivechat"); ?>'><?php _e("Do you have a mobile app?","wplivechat"); ?></a></li>
4668
+ <li><a href='https://wp-livechat.com/documentation/how-do-i-check-for-javascript-errors-on-my-site/' target='_BLANK' title='<?php _e("How do I check for JavaScript errors on my site?","wplivechat"); ?>'><?php _e("How do I check for JavaScript errors on my site?","wplivechat"); ?></a></li>
4669
+ </ul>
4670
+ </div>
4671
+ <div class='wplc_row_col' style='background-color:#FFF;'>
4672
+ <h2><i class="fa fa-exclamation-circle fa-2x"></i> <?php _e("Troubleshooting","wplivechat"); ?></h2>
4673
+ <hr />
4674
+ <p><?php _e("WP Live Chat Support has a diverse and wide range of features which may, from time to time, run into conflicts with the thousands of themes and other plugins on the market.", "wplivechat"); ?></p>
4675
+ <p><strong><?php _e("Common issues:","wplivechat"); ?></strong></p>
4676
+ <ul>
4677
+ <li><a href='https://wp-livechat.com/documentation/troubleshooting/the-chat-box-doesnt-show-up/' target='_BLANK' title='<?php _e("The chat box doesnt show up","wplivechat"); ?>'><?php _e("The chat box doesnt show up","wplivechat"); ?></a></li>
4678
+ <li><a href='https://wp-livechat.com/documentation/the-chat-window-disappears-when-i-logout-or-go-offline/' target='_BLANK' title='<?php _e("The chat window disappears when I logout or go offline","wplivechat"); ?>'><?php _e("The chat window disappears when I logout or go offline","wplivechat"); ?></a></li>
4679
+ <li><a href='https://wp-livechat.com/this-chat-has-already-been-answered-please-close-the-chat-window/' target='_BLANK' title='<?php _e("This chat has already been answered. Please close the chat window","wplivechat"); ?>'><?php _e("This chat has already been answered. Please close the chat window","wplivechat"); ?></a></li>
4680
+ <li><a href='https://wp-livechat.com/messages-only-show-when-i-refresh-the-chat-window/' target='_BLANK' title='<?php _e("Messages only show when I refresh the chat window","wplivechat"); ?>'><?php _e("Messages only show when I refresh the chat window","wplivechat"); ?></a></li>
4681
+ <li><a href='https://wp-livechat.com/documentation/im-not-getting-any-notifications-of-a-new-chat/' target='_BLANK' title='<?php _e("I'm not getting any notifications of a new chat","wplivechat"); ?>'><?php _e("I'm not getting any notifications of a new chat","wplivechat"); ?></a></li>
4682
+ <li><a href='https://wp-livechat.com/the-chat-window-never-goes-offline/' target='_BLANK' title='<?php _e("The chat window never goes offline","wplivechat"); ?>'><?php _e("The chat window never goes offline","wplivechat"); ?></a></li>
4683
+ </ul>
4684
+ </div>
4685
+ <div class='wplc_row_col' style='background-color:#FFF;'>
4686
+ <h2><i class="fa fa-bullhorn fa-2x"></i> <?php _e("Support","wplivechat"); ?></h2>
4687
+ <hr />
4688
+ <p><?php _e("Still need help? Use one of these links below.","wplivechat"); ?></p>
4689
+ <ul>
4690
+ <li><a href='https://wp-livechat.com/support/' target='_BLANK' title='<?php _e("Support desk","wplivechat"); ?>'><?php _e("Support desk","wplivechat"); ?></a></li>
4691
+ <li><a href='https://wp-livechat.com/contact-us/' target='_BLANK' title='<?php _e("Contact us","wplivechat"); ?>'><?php _e("Contact us","wplivechat"); ?></a></li>
4692
+ </ul>
4693
+ </div>
4694
+ </div>
4695
+ <?php
4696
+ }
4697
+ if (!function_exists("wplc_ic_initiate_chat_button")) {
4698
+ add_action('admin_enqueue_scripts', 'wp_button_pointers_load_scripts');
4699
+ }
4700
+ /**
4701
+ * Displays the pointers on teh live chat dashboard for the initiate chat functionality
4702
+ * @param string $hook returns the page name we're on
4703
+ * @return string contents ofthe pointers and their scripts
4704
+ */
4705
+ function wp_button_pointers_load_scripts($hook) {
4706
+ $wplcrun = false;
4707
+ global $wplc_version;
4708
+
4709
+ $wplc_settings = get_option("WPLC_SETTINGS");
4710
+ if ( isset( $wplc_settings['wplc_enable_all_admin_pages'] ) && $wplc_settings['wplc_enable_all_admin_pages'] === '1' ) {
4711
+ /* Run admin JS on all admin pages */
4712
+ $wplcrun = true;
4713
+
4714
+
4715
+ } else {
4716
+
4717
+ if( $hook === 'toplevel_page_wplivechat-menu') { $wplcrun = true; } // stop if we are not on the right page
4718
+ }
4719
+
4720
+
4721
+ if ( $wplcrun ) {
4722
+
4723
+
4724
+
4725
+
4726
+ $pointer_localize_strings = array(
4727
+ "initiate" => "<h3>".__("Initiate Chats","wplivechat")."</h3><p>".__("With the Pro add-on of WP Live Chat Support, you can", "wplivechat")." <a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate1_pointer' title='".__("see who's online and initiate chats", "wplivechat")."' target=\"_BLANK\">".__("initiate chats", "wplivechat")."</a> ".__("with your online visitors with the click of a button.", "wplivechat")." <br /><br /><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=initiate2_pointer' title='".__("Buy the Pro add-on now (once off payment).", "wplivechat")."' target=\"_BLANK\"><strong>".__("Buy the Pro add-on now (once off payment).", "wplivechat")."</strong></a></p>",
4728
+ "chats" => "<h3>".__("Multiple Chats","wplivechat")."</h3><p>".__("With the Pro add-on of WP Live Chat Support, you can", "wplivechat")." <a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=morechats1_pointer' title='".__("accept and handle multiple chats.", "wplivechat")."' target=\"_BLANK\">".__("accept and handle multiple chats.", "wplivechat")."</a><br /><br /><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=morechats2_pointer' title='".__("Buy the Pro add-on now (once off payment).", "wplivechat")."' target=\"_BLANK\"><strong>".__("Buy the Pro add-on now (once off payment).", "wplivechat")."</strong></a></p>",
4729
+ "agent_info" => "<h3>".__("Add unlimited agents","wplivechat")."</h3><p><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=unlimited_agents1_pointer' title='".__("Add unlimited agents", "wplivechat")."' target=\"_BLANK\">".__("Add unlimited agents", "wplivechat")."</a> ".__(" with the Pro add-on of WP Live Chat Support","wplivechat")." "."<a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=unlimited_agents2_pointer' target='_BLANK'>".__("(once off payment).","wplivechat")."</a></p>",
4730
+ "transfer" => "<h3>".__("Transfer Chats","wplivechat")."</h3><p><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=transfer1_pointer' title='".__("Transfer Chats", "wplivechat")."' target=\"_BLANK\">".__("Transfer Chats", "wplivechat")."</a> ".__(" with the Pro add-on of WP Live Chat Support","wplivechat")." "."<a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=transfer2_pointer' target='_BLANK'>".__("(once off payment).","wplivechat")."</a></p>",
4731
+ "direct_to_page" => "<h3>".__("Direct User To Page","wplivechat")."</h3><p><a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=direct_to_page_1' title='".__("Transfer Chats", "wplivechat")."' target=\"_BLANK\">".__("Direct User To Page", "wplivechat")."</a> ".__(" with the Pro add-on of WP Live Chat Support","wplivechat")." "."<a href='http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=direct_to_page_2' target='_BLANK'>".__("(once off payment).","wplivechat")."</a></p>"
4732
+ );
4733
+
4734
+
4735
+ wp_enqueue_style( 'wp-pointer' );
4736
+ wp_enqueue_script( 'wp-pointer' );
4737
+ wp_register_script('wplc-user-admin-pointer', plugins_url('/js/wplc-admin-pointers.js', __FILE__), array('wp-pointer'), $wplc_version);
4738
+ wp_enqueue_script('wplc-user-admin-pointer');
4739
+ wp_localize_script('wplc-user-admin-pointer', 'pointer_localize_strings', $pointer_localize_strings);
4740
+ }
4741
+
4742
+ }
4743
+
4744
+ add_filter( 'admin_footer_text', 'wplc_footer_mod' );
4745
+ /**
4746
+ * Adds the WP Live Chat Support & CODECABIN_ footer contents to the relevant pages
4747
+ * @param string $footer_text current footer text available to us
4748
+ * @return string footer contents with our branding in it
4749
+ */
4750
+ function wplc_footer_mod( $footer_text ) {
4751
+ if (isset($_GET['page']) && ($_GET['page'] == 'wplivechat-menu' || $_GET['page'] == 'wplivechat-menu-extensions-page' || $_GET['page'] == 'wplivechat-menu-settings' || $_GET['page'] == 'wplivechat-menu-offline-messages' || $_GET['page'] == 'wplivechat-menu-history')) {
4752
+ $footer_text_mod = sprintf( __( 'Thank you for using <a href="%1$s" target="_blank">WP Live Chat Support</a>! Please <a href="%2$s" target="_blank">rate us</a> on <a href="%2$s" target="_blank">WordPress.org</a>', 'wplivechat' ),
4753
+ 'https://wp-livechat.com/?utm_source=plugin&utm_medium=link&utm_campaign=footer',
4754
+ 'https://wordpress.org/support/view/plugin-reviews/wp-live-chat-support?filter=5#postform'
4755
+ );
4756
+
4757
+ 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>';
4758
+ } else {
4759
+ return $footer_text;
4760
+ }
4761
+
4762
+ }
4763
+
4764
+ add_filter("wplc_filter_admin_long_poll_chat_loop_iteration","wplc_filter_control_wplc_admin_long_poll_chat_iteration", 1, 3);
4765
+ /**
4766
+ * Alters the admin's long poll chat iteration
4767
+ * @param array $array current chat data available to us
4768
+ * @param array $post_data current post data available to us
4769
+ * @param int $i count for each chat available
4770
+ * @return array additional contents added to the chat data
4771
+ */
4772
+ function wplc_filter_control_wplc_admin_long_poll_chat_iteration($array,$post_data,$i) {
4773
+ if(isset($post_data['action_2']) && $post_data['action_2'] == "wplc_long_poll_check_user_opened_chat"){
4774
+ $chat_status = wplc_return_chat_status(sanitize_text_field($post_data['cid']));
4775
+ if(intval($chat_status) == 3){
4776
+ $array['action'] = "wplc_user_open_chat";
4777
+ }
4778
+ } else {
4779
+
4780
+ if ($post_data['first_run'] === "true") {
4781
+ /* get the chat messages for the first run */
4782
+ $array['chat_history'] = wplc_return_chat_messages($post_data['cid'], false, true, false, false, 'array', false);
4783
+ $array['action'] = "wplc_chat_history";
4784
+
4785
+ } else {
4786
+
4787
+ $new_chat_status = wplc_return_chat_status(sanitize_text_field($post_data['cid']));
4788
+ if($new_chat_status != $post_data['chat_status']){
4789
+ $array['chat_status'] = $new_chat_status;
4790
+ $array['action'] = "wplc_update_chat_status";
4791
+ }
4792
+ $new_chat_message = wplc_return_admin_chat_messages(sanitize_text_field($post_data['cid']));
4793
+
4794
+ if($new_chat_message){
4795
+
4796
+ $array['chat_message'] = $new_chat_message;
4797
+ $array['action'] = "wplc_new_chat_message";
4798
+ }
4799
+ }
4800
+ }
4801
+
4802
+ return $array;
4803
+ }
4804
+
4805
+
4806
+ add_action("wplc_hook_agents_settings","wplc_hook_control_agents_settings", 10);
4807
+ /**
4808
+ * Loads the contents of the chat agents in the settings page
4809
+ * @return string
4810
+ */
4811
+ function wplc_hook_control_agents_settings() {
4812
+ $user_array = get_users(array(
4813
+ 'meta_key' => 'wplc_ma_agent',
4814
+ ));
4815
+
4816
+ echo "<h3>".__('Current Users that are Chat Agents', 'wplivechat')."</h3>";
4817
+ $wplc_agents = "<div class='wplc_agent_container'><ul>";
4818
+
4819
+ if ($user_array) {
4820
+ foreach ($user_array as $user) {
4821
+
4822
+ $wplc_agents .= "<li id=\"wplc_agent_li_".$user->ID."\">";
4823
+ $wplc_agents .= "<p><img src=\"//www.gravatar.com/avatar/" . md5($user->user_email) . "?s=80&d=mm\" /></p>";
4824
+ $check = get_user_meta($user->ID,"wplc_chat_agent_online");
4825
+ if ($check) {
4826
+ $wplc_agents .= "<span class='wplc_status_box wplc_type_returning'>".__("Online","wplivechat")."</span>";
4827
+ }
4828
+ $default_agent_id = $user->ID;
4829
+ $default_agent_user = $user->display_name;
4830
+ $wplc_agents .= "<h3>" . $user->display_name . "</h3>";
4831
+
4832
+ $wplc_agents .= "<small>" . $user->user_email . "</small>";
4833
+
4834
+
4835
+
4836
+
4837
+ $wplc_agents .= "</li>";
4838
+ }
4839
+ }
4840
+ echo $wplc_agents;
4841
+ $temp_line = "<select name='wplc_agent_select' id='wplc_agent_select'><option value=''>".__("Select","wplivechat")."</option>";
4842
+
4843
+ $blogusers = get_users( array( 'role' => 'administrator', 'fields' => array( 'display_name','id','user_email' ) ) );
4844
+ if ($blogusers) {
4845
+ foreach ( $blogusers as $user ) {
4846
+ $is_agent = get_user_meta(esc_html( $user->id ), 'wplc_ma_agent', true);
4847
+ $temp_line2 = '<option id="wplc_selected_agent_'. esc_html( $user->id ) .'" value="' . esc_html( $user->id ) . '">' . esc_html( $user->display_name ) . ' ('.__('Administrator','wplivechat').')</option>';
4848
+ if(!$is_agent){ $temp_line .= $temp_line2; }
4849
+ }
4850
+ }
4851
+
4852
+ $blogusers = get_users( array( 'role' => 'editor', 'fields' => array( 'display_name','id','user_email' ) ) );
4853
+ if ($blogusers) {
4854
+ foreach ( $blogusers as $user ) {
4855
+ $is_agent = get_user_meta(esc_html( $user->id ), 'wplc_ma_agent', true);
4856
+ $temp_line2 = '<option id="wplc_selected_agent_'. esc_html( $user->id ) .'" value="' . esc_html( $user->id ) . '">' . esc_html( $user->display_name ) . ' ('.__('Editor','wplivechat').')</option>';
4857
+ if(!$is_agent){ $temp_line .= $temp_line2; }
4858
+ }
4859
+ }
4860
+
4861
+ $blogusers = get_users( array( 'role' => 'author', 'fields' => array( 'display_name','id','user_email' ) ) );
4862
+ if ($blogusers) {
4863
+ foreach ( $blogusers as $user ) {
4864
+ $is_agent = get_user_meta(esc_html( $user->id ), 'wplc_ma_agent', true);
4865
+ $temp_line2 = '<option id="wplc_selected_agent_'. esc_html( $user->id ) .'" value="' . esc_html( $user->id ) . '">' . esc_html( $user->display_name ) . ' ('.__('Author','wplivechat').')</option>';
4866
+ if(!$is_agent){ $temp_line .= $temp_line2; }
4867
+ }
4868
+ }
4869
+
4870
+ $temp_line .= "</select> ";
4871
+ ?>
4872
+
4873
+
4874
+ <li style='width:150px;' id='wplc_add_new_agent_box'>
4875
+ <p><i class='fa fa-plus-circle fa-4x' style='color:#ccc;' ></i></p>
4876
+ <h3><?php _e("Add New Agent","wplivechat"); ?></h3>
4877
+ <p><button class='button button-secondary' id='wplc_add_agent' disabled style=><?php _e("Add Agent","wplivechat"); ?></button></p>
4878
+ <p style='font-size:0.8em'><?php _e("Add as many agents as you need with the ","wplivechat") ?> <a href="https://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=multipleAgents" target="_BLANK"><?php _e("Pro version.", "wplivechat") ?></a></p>
4879
+ </li>
4880
+ </ul>
4881
+ <?php
4882
+ $agent_text = sprintf( __( 'Change the default chat agent from <strong>%1$s</strong> to ', 'wplivechat' ),
4883
+ $default_agent_user
4884
+
4885
+ );
4886
+ echo $agent_text.$temp_line;
4887
+ ?>
4888
+
4889
+ </div>
4890
+
4891
+ <hr/>
4892
+ <?php
4893
+ }
4894
+
4895
+ /**
4896
+ * Returns chat data specific to a chat ID
4897
+ * @param int $cid Chat ID
4898
+ * @param string $line Line number the function is called on
4899
+ * @return array Contents of the chat based on the ID provided
4900
+ */
4901
+ function wplc_get_chat_data($cid,$line = false) {
4902
+ $result = apply_filters("wplc_filter_get_chat_data",null,$cid);
4903
+ return $result;
4904
+ }
4905
+
4906
+ add_filter( "wplc_filter_get_chat_data", "wplc_get_local_chat_data", 10, 2 );
4907
+ function wplc_get_local_chat_data($result, $cid) {
4908
+ global $wpdb;
4909
+ global $wplc_tblname_chats;
4910
+
4911
+ $sql = "SELECT * FROM $wplc_tblname_chats WHERE `id` = '".intval($cid)."' LIMIT 1";
4912
+ $results = $wpdb->get_results($sql);
4913
+ if (isset($results[0])) { $result = $results[0]; } else { $result = null; }
4914
+
4915
+ return $result;
4916
+
4917
+ }
4918
+
4919
+ /**
4920
+ * Returns chat messages specific to a chat ID
4921
+ * @param int $cid Chat ID
4922
+ * @return array Chat messages based on the ID provided
4923
+ */
4924
+ function wplc_get_chat_messages($cid, $only_read_messages = false, $wplc_settings = false) {
4925
+ global $wpdb;
4926
+ global $wplc_tblname_msgs;
4927
+
4928
+ if (!$wplc_settings) {
4929
+ $wplc_settings = get_option("WPLC_SETTINGS");
4930
+ }
4931
+
4932
+ /**
4933
+ * Identify if the user is using the node server and if they are, display all messages. Otherwise display read only messages (non-node users)
4934
+ */
4935
+ if (isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == '1') {
4936
+
4937
+ $sql = "
4938
+ SELECT * FROM (
4939
+ SELECT *
4940
+ FROM $wplc_tblname_msgs
4941
+ WHERE `chat_sess_id` = '$cid'
4942
+ ORDER BY `timestamp` DESC LIMIT 100
4943
+ ) sub
4944
+ ORDER BY `timestamp` ASC
4945
+ ";
4946
+ } else {
4947
+ if ($only_read_messages) {
4948
+ // only show read messages
4949
+ $sql =
4950
+ "
4951
+ SELECT * FROM (
4952
+ SELECT *
4953
+ FROM $wplc_tblname_msgs
4954
+ WHERE `chat_sess_id` = '$cid' AND `status` = 1
4955
+ ORDER BY `timestamp` DESC LIMIT 100
4956
+ ) sub
4957
+ ORDER BY `timestamp` ASC
4958
+ ";
4959
+ } else {
4960
+ $sql =
4961
+ "
4962
+ SELECT * FROM (
4963
+ SELECT *
4964
+ FROM $wplc_tblname_msgs
4965
+ WHERE `chat_sess_id` = '$cid'
4966
+ ORDER BY `timestamp` DESC LIMIT 100
4967
+ ) sub
4968
+ ORDER BY `timestamp` ASC
4969
+ ";
4970
+ }
4971
+
4972
+ }
4973
+ $results = $wpdb->get_results($sql);
4974
+
4975
+ if (isset($results[0])) { } else { $results = null; }
4976
+ $results = apply_filters("wplc_filter_get_chat_messages",$results,$cid);
4977
+
4978
+ if ($results == "null") {
4979
+ return false;
4980
+ } else {
4981
+ return $results;
4982
+ }
4983
+ }
4984
+
4985
+ /**
4986
+ * Validates extension API keys
4987
+ * @param string $page_content Current page contents in the extensions page
4988
+ * @param array $data Extension data such as name and slug
4989
+ * @return string Updated extensions page contents
4990
+ */
4991
+ function wplc_build_api_check($page_content, $data) {
4992
+ $link = "#";
4993
+ $image = "https://ccplugins.co/api-wplc-extensions/images/add-on0.jpg";
4994
+ if ($data['string'] == "Multiple Agents") {
4995
+ $link = "";
4996
+ $image = "https://ccplugins.co/api-wplc-extensions/images/Agents-Small.jpg";
4997
+ }
4998
+ if ($data['string'] == "Cloud Server") {
4999
+ $link = "";
5000
+ $image = "https://ccplugins.co/api-wplc-extensions/images/Cloud-Small.jpg";
5001
+ }
5002
+ if ($data['string'] == "Advanced Chat Box Control") {
5003
+ $link = "https://wp-livechat.com/extensions/advanced-chat-control/";
5004
+ $image = "https://ccplugins.co/api-wplc-extensions/images/AdvancedChatBox-Small.jpg";
5005
+ }
5006
+ if ($data['string'] == "Choose When Online") {
5007
+ $link = "";
5008
+ $image = "https://ccplugins.co/api-wplc-extensions/images/ChooseOnline-Small.jpg";
5009
+ }
5010
+ if ($data['string'] == "Encryption") {
5011
+ $link = "";
5012
+ $image = "https://ccplugins.co/api-wplc-extensions/images/Encryption-Small.jpg";
5013
+ }
5014
+ if ($data['string'] == "Mobile and Desktop App") {
5015
+ $link = "";
5016
+ $image = "https://ccplugins.co/api-wplc-extensions/images/MobileDesktop-Small.jpg";
5017
+ }
5018
+ if ($data['string'] == "Initiate Chats") {
5019
+ $link = "";
5020
+ $image = "https://ccplugins.co/api-wplc-extensions/images/InitiateChat-Small.jpg";
5021
+ }
5022
+ if ($data['string'] == "Include Exclude Pages") {
5023
+ $link = "";
5024
+ $image = "https://ccplugins.co/api-wplc-extensions/images/IncludeAndExclude-Small.jpg";
5025
+ }
5026
+
5027
+
5028
+ if ($data['string'] == "WP Live Chat Support Pro") {
5029
+ $link = "";
5030
+ $image = "https://ccplugins.co/api-wplc-extensions/images/add-on0.jpg";
5031
+ }
5032
+
5033
+
5034
+ $page_content .= '<div class="wplc-extension" style="height:480px;">';
5035
+ $page_content .= '<a href="'.$link.'" title="'.$data['string'].'" target="_BLANK" style=" text-decoration:none;"><h3 class="wplc-extension-title" style="text-decoration:none;">'.$data['string'].'</h3></a>';
5036
+ $page_content .= '<img width="320" height="200" src="'.$image.'" alt="'.$data['string'].'" title="'.$data['string'].'">';
5037
+ $page_content .= '<p>'.__('API Key','wplivechat').'<br />';
5038
+ $page_content .= " <form name='".$data['form_name']."' action='' method='POST'>";
5039
+ $page_content .= " <input type='text' name='".$data['option_name']."' id='".$data['option_name']."' value='".get_option($data['option_name'])."' style='width: 250px;'/>";
5040
+ $page_content .= " <input type='submit' name='".$data['button']."' id='".$data['button']."' value='".__("Verify","wplivechat")."' />";
5041
+ $page_content .= " </form>";
5042
+ $page_content .= '</p>';
5043
+ $page_content .= '<p>'.__('Status: ','wplivechat');
5044
+ if (isset($data['data']['status']) && $data['data']['status'] == "OK") {
5045
+ update_option($data['is_valid'], 1);
5046
+ $page_content .= "<span style='color: white; font-weight: bold; background-color: green; border-radius: 5px; padding: 3px;'>". __('Valid', 'wplivechat') . '</span>';
5047
+ $page_content .= '<a href="https://wp-livechat.com/my-account/" title="'.__('Manage this extension','wplivechat').'" class="button-secondary" target="_BLANK">'.__('Manage this extension','wplivechat').'</a>';
5048
+ } else {
5049
+ update_option($data['is_valid'], 0);
5050
+ $page_content .= "<span style='color: white; font-weight: bold; background-color: red; border-radius: 5px; padding: 3px;'>" . __('Invalid', 'wplivechat') . '</span>';
5051
+ $page_content .= '<a href="https://wp-livechat.com/my-account/" title="'.__('Manage this extension','wplivechat').'" class="button-secondary" target="_BLANK">'.__('Manage this extension','wplivechat').'</a>';
5052
+ }
5053
+ $page_content .= '</p>';
5054
+ $page_content .= '<div style="dispaly:block; width:100%; height:100px; overflow:auto;">';
5055
+ if (isset($data['data']['domains']) && !empty($data['data']['domains'])) {
5056
+ $page_content .= '<span><strong>'.__("Linked Domains","wplivechat").'</strong></span><ol>';
5057
+ foreach ($data['data']['domains'] as $domain) {
5058
+ $page_content .= '<li>'.$domain.'</li>';
5059
+ }
5060
+ $page_content .= '</ol>';
5061
+ } else {
5062
+ $page_content .= ' <span>'.$data['data']['message'].'</span>';
5063
+
5064
+ }
5065
+ $page_content .= '</div>';
5066
+
5067
+ $page_content .= '</div>';
5068
+
5069
+
5070
+
5071
+
5072
+ return $page_content;
5073
+ }
5074
+
5075
+
5076
+
5077
+ add_filter("wplc_filter_relevant_extensions_main","wplc_filter_control_relevant_extensions_main_proe");
5078
+ /**
5079
+ * Loads additional extension data for the Pro version
5080
+ * @param string $text Current extensions page content
5081
+ * @return string Extensions page content with Pro version extension data
5082
+ */
5083
+ function wplc_filter_control_relevant_extensions_main_proe($text) {
5084
+ if (function_exists("wplc_hook_control_intiate_check")) { return $text; }
5085
+
5086
+ $rel_name = __("Pro Add-on","wplivechat");
5087
+ $rel_image = "https://ccplugins.co/api-wplc-extensions/images/add-on0.jpg";
5088
+ $rel_link = "http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=relevant_pro";
5089
+ $text .= '<div class="wplc-extension relevant_extension">';
5090
+ $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" target="_BLANK" style="float:left;">';
5091
+ $text .= '<img src="'.$rel_image.'" class="attachment-showcase wp-post-image" alt="'.$rel_name.'" title="'.$rel_name.'" >';
5092
+ $text .= '</a>';
5093
+ $text .= '<div class="float:left; padding-left:10px;">';
5094
+ $text .= '<h3 class="wplc-extension-title">'.$rel_name.'</h3>';
5095
+ $text .= '<p>'.__("Get unlimited agents, initiate chats, advanced chat box control, encryption and more with the Pro add-on.","wplivechat").'</p>';
5096
+ $text .= '</div>';
5097
+ $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" class="button-secondary" target="_BLANK">'.__("Get this extension","wplivechat").'</a>';
5098
+ $text .= '</div>';
5099
+
5100
+ return $text;
5101
+ }
5102
+
5103
+
5104
+ add_filter("wplc_filter_relevant_extensions_main","wplc_filter_control_relevant_extensions_main_mobile");
5105
+ /**
5106
+ * Loads additional extension data for the Mobile & Desktop App Extension
5107
+ * @param string $text Current extensions page content
5108
+ * @return string Extensions page content with Mobile & Desktop App extension data
5109
+ */
5110
+ function wplc_filter_control_relevant_extensions_main_mobile($text) {
5111
+ if (function_exists("wplc_mobile_check_if_logged_in")) { return $text; }
5112
+
5113
+ $rel_name = __("Mobile & Desktop App","wplivechat");
5114
+ $rel_image = "https://ccplugins.co/api-wplc-extensions/images/MobileDesktop-Icon.jpg";
5115
+ $rel_link = "https://wp-livechat.com/extensions/mobile-desktop-app-extension/?utm_source=plugin&amp;utm_medium=link&amp;utm_campaign=relevant_mobile";
5116
+ $text .= '<div class="wplc-extension relevant_extension">';
5117
+ $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" target="_BLANK" style="float:left;">';
5118
+ $text .= '<img src="'.$rel_image.'" class="attachment-showcase wp-post-image" alt="'.$rel_name.'" title="'.$rel_name.'" >';
5119
+ $text .= '</a>';
5120
+ $text .= '<div class="float:left; padding-left:10px;">';
5121
+ $text .= '<h3 class="wplc-extension-title">'.$rel_name.'</h3>';
5122
+ $text .= '<p>'.__("Answer chats directly from your mobile phone or desktop with our mobile app and desktop client","wplivechat").'</p>';
5123
+ $text .= '</div>';
5124
+ $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" class="button-secondary" target="_BLANK">'.__("Get this extension","wplivechat").'</a>';
5125
+ $text .= '</div>';
5126
+
5127
+ return $text;
5128
+ }
5129
+
5130
+
5131
+ add_filter("wplc_filter_relevant_extensions_chatbox","wplc_filter_control_relevant_extensions_chatbox_proe");
5132
+ /**
5133
+ * Loads additional extension data for the Pro version - alternative option
5134
+ * @param string $text Current extensions page content
5135
+ * @return string Extensions page content with Pro version extension data
5136
+ */
5137
+ function wplc_filter_control_relevant_extensions_chatbox_proe($text) {
5138
+ if (function_exists("wplc_hook_control_intiate_check")) { return $text; }
5139
+
5140
+ $rel_name = __("Pro Add-on","wplivechat");
5141
+ $rel_image = "https://ccplugins.co/api-wplc-extensions/images/add-on0.jpg";
5142
+ $rel_link = "http://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=relevant_pro_chatbox";
5143
+ $text .= '<div class="wplc-extension relevant_extension">';
5144
+ $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" target="_BLANK" style="float:left;">';
5145
+ $text .= '<img src="'.$rel_image.'" class="attachment-showcase wp-post-image" alt="'.$rel_name.'" title="'.$rel_name.'" >';
5146
+ $text .= '</a>';
5147
+ $text .= '<div class="float:left; padding-left:10px;">';
5148
+ $text .= '<h3 class="wplc-extension-title">'.$rel_name.'</h3>';
5149
+ $text .= '<p>'.__("Get unlimited agents, initiate chats, advanced chat box control, encryption and more with the Pro add-on.","wplivechat").'</p>';
5150
+ $text .= '</div>';
5151
+ $text .= '<a href="'.$rel_link.'" title="'.$rel_name.'" class="button-secondary" target="_BLANK">'.__("Get this extension","wplivechat").'</a>';
5152
+ $text .= '</div>';
5153
+
5154
+ return $text;
5155
+ }
5156
+
5157
+ /**
5158
+ * Add to the chat box settings page
5159
+ * @return void
5160
+ * @since 1.0.00
5161
+ * @author Nick Duncan <nick@codecabin.co.za>
5162
+ */
5163
+ add_action('wplc_hook_admin_settings_chat_box_settings_after','wplc_hook_control_settings_page_relevant_extensions_acbc',9);
5164
+ function wplc_hook_control_settings_page_relevant_extensions_acbc() {
5165
+ $check = apply_filters("wplc_filter_relevant_extensions_chatbox","");
5166
+ if ($check != "") {
5167
+ echo "<hr />";
5168
+ echo "<div style='padding:1%; width:98%; display:block; overflow:auto;'>";
5169
+ echo "<div class='display:block; font-weight:bold;'><strong>".__("Relevant Extensions",'wplivechat')."</strong><br /><br /></div>";
5170
+ echo "";
5171
+ echo $check;
5172
+ echo "";
5173
+ echo "";
5174
+ echo "</div>";
5175
+ }
5176
+ }
5177
+
5178
+ /**
5179
+ * Add to the chat box settings page
5180
+ * @return void
5181
+ * @since 1.0.00
5182
+ * @author Nick Duncan <nick@codecabin.co.za>
5183
+ */
5184
+ add_action('wplc_hook_admin_settings_main_settings_after','wplc_hook_control_settings_page_relevant_extensions_main',9);
5185
+ function wplc_hook_control_settings_page_relevant_extensions_main() {
5186
+ $check = apply_filters("wplc_filter_relevant_extensions_main","");
5187
+ if ($check != "") {
5188
+ echo "<hr />";
5189
+ echo "<div style='padding:1%; width:98%; display:block; overflow:auto;'>";
5190
+ echo "<div class='display:block; font-weight:bold;'><strong>".__("Relevant Extensions",'wplivechat')."</strong><br /><br /></div>";
5191
+ echo "";
5192
+ echo $check;
5193
+ echo "";
5194
+ echo "";
5195
+ echo "</div>";
5196
+ }
5197
+ }
5198
+
5199
+
5200
+
5201
+ add_filter("wplc_filter_hovercard_bottom_before","wplc_filter_control_hovercard_bottom_before_pro",5,1);
5202
+ /**
5203
+ * Adds a powered by link to the hovercard
5204
+ * @param string $content current chat content of the hover card
5205
+ * @return string chat content with the powered by link
5206
+ * @deprecated 7.0.0 rebuilt unknowingly
5207
+ */
5208
+ function wplc_filter_control_hovercard_bottom_before_pro($content) {
5209
+ $wplc_settings = get_option("WPLC_SETTINGS");
5210
+ if(isset($wplc_settings["wplc_powered_by_link"]) && $wplc_settings["wplc_powered_by_link"] == 0){
5211
+
5212
+ } else if(!isset($wplc_settings["wplc_powered_by_link"])) {
5213
+
5214
+ } else{
5215
+ $content .= "<a title='".__("Powered By WP Live Chat Support", "wplivechat")."' target='_blank' rel='nofollow' href='https://wp-livechat.com/?utm_source=poweredby&utm_medium=click&utm_campaign=".esc_html(site_url())."' class='wplc_powered_by_link'>".__("Powered By WP Live Chat Support", "wplivechat")."</a>";
5216
+ }
5217
+ return $content;
5218
+ }
5219
+
5220
+
5221
+
5222
+ add_action('admin_init', 'wplc_admin_download_new_chat_history');
5223
+ /**
5224
+ * Downloads the chat history and adds it to a CSV file
5225
+ * @return file
5226
+ */
5227
+ function wplc_admin_download_new_chat_history(){
5228
+ if(!is_user_logged_in() || !get_user_meta(get_current_user_id(), 'wplc_ma_agent', true) ){
5229
+ return;
5230
+ }
5231
+
5232
+ if (isset($_GET['action']) && $_GET['action'] == "download_history") {
5233
+
5234
+ global $wpdb;
5235
+
5236
+ $chat_id = sanitize_text_field( $_GET['cid'] );
5237
+ $fileName = 'live_chat_history_'.$chat_id.'.csv';
5238
+
5239
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
5240
+ header('Content-Description: File Transfer');
5241
+ header("Content-type: text/csv");
5242
+ header("Content-Disposition: attachment; filename={$fileName}");
5243
+ header("Expires: 0");
5244
+ header("Pragma: public");
5245
+
5246
+ $fh = @fopen( 'php://output', 'w' );
5247
+
5248
+ global $wpdb;
5249
+ global $wplc_tblname_msgs;
5250
+
5251
+ $results = $wpdb->get_results(
5252
+ "
5253
+ SELECT *
5254
+ FROM $wplc_tblname_msgs
5255
+ WHERE `chat_sess_id` = '$chat_id'
5256
+ ORDER BY `timestamp` ASC
5257
+ LIMIT 0, 100
5258
+ "
5259
+ );
5260
+
5261
+ $fields[] = array(
5262
+ 'id' => __('Chat ID', 'wplivechat'),
5263
+ 'msgfrom' => __('From', 'wplivechat'),
5264
+ 'msg' => __('Message', 'wplivechat'),
5265
+ 'time' => __('Timestamp', 'wplivechat'),
5266
+ 'orig' => __('Origin', 'wplivechat'),
5267
+ );
5268
+
5269
+ foreach ($results as $result => $key) {
5270
+ if($key->originates == 2){
5271
+ $user = __('user', 'wplivechat');
5272
+ } else {
5273
+ $user = __('agent', 'wplivechat');
5274
+ }
5275
+
5276
+ $fields[] = array(
5277
+ 'id' => $key->chat_sess_id,
5278
+ 'msgfrom' => $key->msgfrom,
5279
+ 'msg' => apply_filters("wplc_filter_message_control_out",$key->msg),
5280
+ 'time' => $key->timestamp,
5281
+ 'orig' => $user,
5282
+ );
5283
+ }
5284
+
5285
+ foreach($fields as $field){
5286
+ fputcsv($fh, $field, ",", '"');
5287
+ }
5288
+ // Close the file
5289
+ fclose($fh);
5290
+ // Make sure nothing else is sent, our file is done
5291
+ exit;
5292
+
5293
+ }
5294
+ }
5295
+ /**
5296
+ * Retrieves the data to start downloadling the chat history
5297
+ * @param string $type Chat history output type
5298
+ * @param string $cid Chat ID
5299
+ * @return void
5300
+ */
5301
+ function wplc_admin_download_history($type, $cid){
5302
+ if(!is_user_logged_in() || !get_user_meta(get_current_user_id(), 'wplc_ma_agent', true) ){
5303
+ return;
5304
+ }
5305
+
5306
+ global $wpdb;
5307
+ global $wplc_tblname_msgs;
5308
+
5309
+ $results = $wpdb->get_results(
5310
+ "
5311
+ SELECT *
5312
+ FROM $wplc_tblname_msgs
5313
+ WHERE `chat_sess_id` = '$cid'
5314
+ ORDER BY `timestamp` ASC
5315
+ LIMIT 0, 100
5316
+ "
5317
+ );
5318
+
5319
+ $fields[] = array(
5320
+ 'id' => __('Chat ID', 'wplivechat'),
5321
+ 'msgfrom' => __('From', 'wplivechat'),
5322
+ 'msg' => __('Message', 'wplivechat'),
5323
+ 'time' => __('Timestamp', 'wplivechat'),
5324
+ 'orig' => __('Origin', 'wplivechat'),
5325
+ );
5326
+
5327
+ foreach ($results as $result => $key) {
5328
+ if($key->originates == 2){
5329
+ $user = __('user', 'wplivechat');
5330
+ } else {
5331
+ $user = __('agent', 'wplivechat');
5332
+ }
5333
+
5334
+ $fields[] = array(
5335
+ 'id' => $key->chat_sess_id,
5336
+ 'msgfrom' => $key->msgfrom,
5337
+ 'msg' => apply_filters("wplc_filter_message_control_out",$key->msg),
5338
+ 'time' => $key->timestamp,
5339
+ 'orig' => $user,
5340
+ );
5341
+ }
5342
+
5343
+ ob_end_clean();
5344
+
5345
+ wplc_convert_to_csv_new($fields, 'live_chat_history_'.$cid.'.csv', ',');
5346
+
5347
+ exit();
5348
+ }
5349
+
5350
+ /**
5351
+ * Converts contents into a CSV file
5352
+ * @param string $in Contents of file
5353
+ * @param string $out Output of file
5354
+ * @param string $del Delimiter for content
5355
+ * @return void
5356
+ */
5357
+ function wplc_convert_to_csv_new($in, $out, $del){
5358
+
5359
+ $f = fopen('php://memory', 'w');
5360
+
5361
+ foreach ($in as $line) {
5362
+ wplc_fputcsv_eol_new($f, $line, $del, "\r\n");
5363
+ }
5364
+
5365
+ fseek($f, 0);
5366
+
5367
+ header('Content-Type: application/csv');
5368
+
5369
+ header('Content-Disposition: attachement; filename="' . $out . '";');
5370
+
5371
+ fpassthru($f);
5372
+ }
5373
+ /**
5374
+ * Parses content to add to a CSV file
5375
+ * @param string $fp The open file
5376
+ * @param string $array The content to be added to the file
5377
+ * @param string $del Delimiter to use in the file
5378
+ * @param string $eol Content to be written to the file
5379
+ * @return void
5380
+ */
5381
+ function wplc_fputcsv_eol_new($fp, $array, $del, $eol) {
5382
+ fputcsv($fp, $array,$del);
5383
+ if("\n\r" != $eol && 0 === fseek($fp, -1, SEEK_CUR)) {
5384
+ fwrite($fp, $eol);
5385
+ }
5386
+ }
5387
+
5388
+ /**
5389
+ * Adds an API key notice in the plugin's page
5390
+ * @return string
5391
+ */
5392
+ function wplc_plugin_row_invalid_api() {
5393
+ echo '<tr class="active"><td>&nbsp;</td><td colspan="2" style="color:red;">
5394
+ &nbsp; &nbsp; '.__('Your API Key is Invalid. You are not eligible for future updates. Please enter your API key <a href="admin.php?page=wplivechat-menu-api-keys-page">here</a>.','wplivechat').'
5395
+ </td></tr>';
5396
+ }
5397
+
5398
+ /**
5399
+ * Hides the chat when offline
5400
+ * @return int Incremented number if any agents have logged in
5401
+ */
5402
+ function wplc_basic_hide_chat_when_offline(){
5403
+ $wplc_settings = get_option("WPLC_SETTINGS");
5404
+
5405
+ $hide_chat = 0;
5406
+ if (isset($wplc_settings['wplc_hide_when_offline']) && $wplc_settings['wplc_hide_when_offline'] == 1) {
5407
+ /* Hide the window when its offline */
5408
+ $logged_in = apply_filters("wplc_loggedin_filter",false);
5409
+ if (!$logged_in) {
5410
+ $hide_chat++;
5411
+ }
5412
+ } else {
5413
+ $hide_chat = 0;
5414
+ }
5415
+ return $hide_chat;
5416
+ }
5417
+
5418
+ /**
5419
+ * Checks all strings that are added to the chat window
5420
+ * @return void
5421
+ */
5422
+ function wplc_string_check() {
5423
+ $wplc_settings = get_option("WPLC_SETTINGS");
5424
+
5425
+ if (!isset($wplc_settings['wplc_pro_na'])) { $wplc_settings["wplc_pro_na"] = __("Chat offline. Leave a message", "wplivechat"); }
5426
+ if (!isset($wplc_settings['wplc_pro_intro'])) { $wplc_settings["wplc_pro_intro"] = __("Hello. Please input your details so that I may help you.", "wplivechat"); }
5427
+ if (!isset($wplc_settings['wplc_pro_offline1'])) { $wplc_settings["wplc_pro_offline1"] = __("We are currently offline. Please leave a message and we'll get back to you shortly.", "wplivechat"); }
5428
+ if (!isset($wplc_settings['wplc_pro_offline2'])) { $wplc_settings["wplc_pro_offline2"] = __("Sending message...", "wplivechat"); }
5429
+ if (!isset($wplc_settings['wplc_pro_offline3'])) { $wplc_settings["wplc_pro_offline3"] = __("Thank you for your message. We will be in contact soon.", "wplivechat"); }
5430
+ if (!isset($wplc_settings['wplc_pro_offline_btn']) || (isset($wplc_settings['wplc_pro_offline_btn']) && $wplc_settings['wplc_pro_offline_btn'] == "")) { $wplc_settings["wplc_pro_offline_btn"] = __("Leave a message", "wplivechat"); }
5431
+ if (!isset($wplc_settings['wplc_pro_offline_btn_send']) || (isset($wplc_settings['wplc_pro_offline_btn_send']) && $wplc_settings['wplc_pro_offline_btn_send'] == "")) { $wplc_settings["wplc_pro_offline_btn_send"] = __("Send message", "wplivechat"); }
5432
+ if (!isset($wplc_settings['wplc_pro_fst1'])) { $wplc_settings["wplc_pro_fst1"] = __("Questions?", "wplivechat"); }
5433
+ if (!isset($wplc_settings['wplc_pro_fst2'])) { $wplc_settings["wplc_pro_fst2"] = __("Chat with us", "wplivechat"); }
5434
+ if (!isset($wplc_settings['wplc_pro_fst3'])) { $wplc_settings["wplc_pro_fst3"] = __("Start live chat", "wplivechat"); }
5435
+ if (!isset($wplc_settings['wplc_pro_sst1'])) { $wplc_settings["wplc_pro_sst1"] = __("Start Chat", "wplivechat"); }
5436
+ if (!isset($wplc_settings['wplc_pro_sst1_survey'])) { $wplc_settings["wplc_pro_sst1_survey"] = __("Or chat to an agent now", "wplivechat"); }
5437
+ if (!isset($wplc_settings['wplc_pro_sst1e_survey'])) { $wplc_settings["wplc_pro_sst1e_survey"] = __("Chat ended", "wplivechat"); }
5438
+ if (!isset($wplc_settings['wplc_pro_sst2'])) { $wplc_settings["wplc_pro_sst2"] = __("Connecting. Please be patient...", "wplivechat"); }
5439
+ if (!isset($wplc_settings['wplc_pro_tst1'])) { $wplc_settings["wplc_pro_tst1"] = __("Reactivating your previous chat...", "wplivechat"); }
5440
+ if (!isset($wplc_settings['wplc_user_welcome_chat'])) { $wplc_settings["wplc_user_welcome_chat"] = __("Welcome. How may I help you?", "wplivechat"); }
5441
+ if (!isset($wplc_settings['wplc_welcome_msg'])) { $wplc_settings['wplc_welcome_msg'] = __("Please standby for an agent. While you wait for the agent you may type your message.","wplivechat"); }
5442
+ if (!isset($wplc_settings['wplc_user_enter'])) { $wplc_settings["wplc_user_enter"] = __("Press ENTER to send your message", "wplivechat"); }
5443
+ if (!isset($wplc_settings['wplc_close_btn_text'])) { $wplc_settings["wplc_close_btn_text"] = __("close", "wplivechat"); }
5444
+
5445
+ update_option("WPLC_SETTINGS",$wplc_settings);
5446
+
5447
+ }
5448
+
5449
+ add_filter("wplc_filter_chat_text_editor_upsell","nifty_text_edit_upsell",1,1);
5450
+ /**
5451
+ * Used to upsell the advanced text editor in the chat
5452
+ * @param string $msg Current text in the chat window
5453
+ * @return string Additional content added for upselling purposes
5454
+ */
5455
+ function nifty_text_edit_upsell($msg){
5456
+ if(!function_exists("nifty_text_edit_div") && !function_exists("wplc_pro_activate")){
5457
+ //Only show this if in admin area and is not PRO
5458
+ $msg .= "<div id='nifty_text_editor_holder' class='wplc_faded_upsell'>";
5459
+ $msg .= "<i class='nifty_tedit_icon fa fa-bold' id='nifty_tedit_b'></i>";
5460
+ $msg .= "<i class='nifty_tedit_icon fa fa-italic' id='nifty_tedit_i'></i>";
5461
+ $msg .= "<i class='nifty_tedit_icon fa fa-underline' id='nifty_tedit_u'></i>";
5462
+ $msg .= "<i class='nifty_tedit_icon fa fa-strikethrough' id='nifty_tedit_strike'></i>";
5463
+ $msg .= "<i class='nifty_tedit_icon fa fa-square' id='nifty_tedit_mark'></i>";
5464
+ $msg .= "<i class='nifty_tedit_icon fa fa-subscript' id='nifty_tedit_sub'></i>";
5465
+ $msg .= "<i class='nifty_tedit_icon fa fa-superscript' id='nifty_tedit_sup'></i>";
5466
+ $msg .= "<i class='nifty_tedit_icon fa fa-link' id='nifty_tedit_link'></i>";
5467
+ $msg .= "<i class='nifty_tedit_icon'><a target='_BLANK' href='https://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=text_editor'>Pro version only</a></i>";
5468
+ $msg .= "</div>";
5469
+ }
5470
+ return $msg;
5471
+ }
5472
+
5473
+ add_filter("wplc_filter_advanced_info","nifty_rating_advanced_info_upsell",1,4);
5474
+ /**
5475
+ * Chat experience ratings upselling page
5476
+ * @param string $msg current chat window contents
5477
+ * @param int $cid chat ID
5478
+ * @param string $name User's name
5479
+ * @return string current chat window contents with the experience rating content appended
5480
+ */
5481
+ function nifty_rating_advanced_info_upsell($msg, $cid, $name, $chat_data){
5482
+ if(!function_exists("nifty_rating_advanced_info_control") && is_admin() && !function_exists("wplc_pro_activate")){
5483
+ $msg .= "<div class='admin_visitor_advanced_info admin_agent_rating wplc_faded_upsell'>
5484
+ <strong>" . __("Experience Rating", "wplivechat") . "</strong>
5485
+ <div class='rating'><a target='_BLANK' href='https://wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=experience_ratings'>Pro only</a></div>
5486
+ </div>";
5487
+ }
5488
+ return $msg;
5489
+ }
5490
+
5491
+ add_filter("wplc_filter_typing_control_div","wplc_basic_filter_control_return_chat_response_box_before",2,1);
5492
+ function wplc_basic_filter_control_return_chat_response_box_before($string) {
5493
+ remove_filter("wplc_filter_typing_control_div","wplc_pro_filter_control_return_chat_response_box_before");
5494
+ $string = $string. "<div class='typing_indicator wplc-color-2 wplc-color-bg-1'></div>";
5495
+
5496
+ return $string;
5497
+ }
5498
+ add_filter("wplc_filter_typing_control_div_theme_2","wplc_basic_filter_control_return_chat_response_box_before_theme2",2,1);
5499
+ function wplc_basic_filter_control_return_chat_response_box_before_theme2($string) {
5500
+ remove_filter("wplc_filter_typing_control_div_theme_2","wplc_pro_filter_control_return_chat_response_box_before_theme2");
5501
+ $string = $string. "<div class='typing_indicator wplc-color-2 wplc-color-bg-1'></div>";
5502
+
5503
+ return $string;
5504
+ }
5505
+
5506
+
5507
+ add_action("wplc_hook_admin_settings_main_settings_after","wplc_hook_control_admin_settings_chat_box_settings_after",2);
5508
+ /**
5509
+ * Adds the settings to allow the user to change their server environment variables
5510
+ * @return sring */
5511
+ function wplc_hook_control_admin_settings_chat_box_settings_after() {
5512
+
5513
+ $wplc_settings = get_option("WPLC_SETTINGS");
5514
+ if (isset($wplc_settings["wplc_environment"])) { $wplc_environment[intval($wplc_settings["wplc_environment"])] = "SELECTED"; }
5515
+
5516
+ ?>
5517
+ <h4><?php _e("Advanced settings", "wplivechat") ?></h4>
5518
+ <table class='wp-list-table wplc_list_table widefat fixed striped pages' width='700'>
5519
+
5520
+ <?php do_action("wplc_advanced_settings_above_performance", $wplc_settings); ?>
5521
+ </table>
5522
+ <p>&nbsp;</p>
5523
+ <table class='wp-list-table wplc_list_table widefat fixed striped pages' width='700'>
5524
+
5525
+ <tr>
5526
+ <td colspan='2'>
5527
+ <p><em><small><?php _e("Only change these settings if you are experiencing performance issues.","wplivechat"); ?></small></em></p>
5528
+ </td>
5529
+ </tr>
5530
+ </tr>
5531
+ <?php do_action("wplc_advanced_settings_settings"); ?>
5532
+ <tr>
5533
+ <td valign='top'>
5534
+ <?php _e("What type of environment are you on?","wplivechat"); ?>
5535
+ </td>
5536
+ <td valign='top'>
5537
+ <select name='wplc_environment' id='wplc_environment'>
5538
+ <option value='1' <?php if (isset($wplc_environment[1])) { echo $wplc_environment[1]; } ?>><?php _e("Shared hosting - low level plan","wplivechat"); ?></option>
5539
+ <option value='2' <?php if (isset($wplc_environment[2])) { echo $wplc_environment[2]; } ?>><?php _e("Shared hosting - normal plan","wplivechat"); ?></option>
5540
+ <option value='3' <?php if (isset($wplc_environment[3])) { echo $wplc_environment[3]; } ?>><?php _e("VPS","wplivechat"); ?></option>
5541
+ <option value='4' <?php if (isset($wplc_environment[4])) { echo $wplc_environment[4]; } ?>><?php _e("Dedicated server","wplivechat"); ?></option>
5542
+ </select>
5543
+ </td>
5544
+ </tr>
5545
+ <tr>
5546
+ <td valign='top'>
5547
+ <?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>
5548
+ </td>
5549
+ <td valign='top'>
5550
+ <?php
5551
+ $wplc_advanced_settings = get_option("wplc_advanced_settings");
5552
+ ?>
5553
+ <table>
5554
+ <tr>
5555
+ <td><?php _e("Iterations","wplivechat"); ?></td>
5556
+ <td><input id="wplc_iterations" name="wplc_iterations" type="number" max='200' min='10' value="<?php if (isset($wplc_advanced_settings['wplc_iterations'])) { echo $wplc_advanced_settings['wplc_iterations']; } else { echo '55'; } ?>" /></td>
5557
+ </tr>
5558
+ <tr>
5559
+ <td><?php _e("Sleep between iterations","wplivechat"); ?></td>
5560
+ <td>
5561
+ <input id="wplc_delay_between_loops" name="wplc_delay_between_loops" type="number" max='1000000' min='25000' value="<?php if (isset($wplc_advanced_settings['wplc_delay_between_loops'])) { echo $wplc_advanced_settings['wplc_delay_between_loops']; } else { echo '500000'; } ?>" />
5562
+ <small><em><?php _e("microseconds","wplivechat"); ?></em></small>
5563
+ </td>
5564
+ </tr>
5565
+ </table>
5566
+
5567
+ </td>
5568
+ </tr>
5569
+
5570
+ </table>
5571
+ <?php
5572
+ }
5573
+ /**
5574
+ * Basic version's reporting page
5575
+ * @return string
5576
+ */
5577
+ function wplc_basic_reporting_page(){
5578
+
5579
+ $content = "<div class='wrap wplc_wrap'>";
5580
+ $content .= "<h2>".__('WP Live Chat Support Reporting', 'wp-livechat')." (beta) </h2>";
5581
+ $content .= "<table class=\"wp-list-table wplc_list_table widefat fixed form-table\" cellspacing=\"0\" style='width:98%'>";
5582
+ $content .= "<tr>";
5583
+ $content .= "<td style='width:35%; vertical-align:top;'>";
5584
+ $content .= "<img class='reporting_img_main' style='width:99%; height:auto; padding:2px; border:1px lightgray solid;box-shadow: 3px 3px 2px -2px #999;-webkit-box-shadow: 3px 3px 2px -2px #999;-moz-box-shadow: 3px 3px 2px -2px #999;-o-box-shadow: 3px 3px 2px -2px #999;' src='".plugins_url('/images/reporting_sample.jpg', __FILE__)."'>";
5585
+ $content .= "</td>";
5586
+ $content .= "<td style='vertical-align:top;'>";
5587
+ $content .= "<h3>".__('WP Live Chat Support Reporting', 'wp-livechat')."</h3>";
5588
+ $content .= "<p>".__('View comprehensive reports regarding your chat and agent activity.', 'wp-livechat')."</p>";
5589
+
5590
+
5591
+ $content .= "<br><p><strong>".__('Reports', 'wp-livechat').":</strong></p>";
5592
+ $content .= "<ul style='list-style: inherit;margin-left: 22px;'>";
5593
+ $content .= "<li>".__('Chat statistics', 'wp-livechat')."</li>";
5594
+ $content .= "<li>".__('Popular pages', 'wp-livechat')."</li>";
5595
+ $content .= "<li>".__('ROI reporting and tracking (identify which agents produce the most sales)', 'wp-livechat')."</li>";
5596
+ $content .= "<li>".__('User experience ratings (identify which agents produce the happiest customers)', 'wp-livechat')."</li>";
5597
+ $content .= "</ul>";
5598
+
5599
+ if (function_exists("wplc_pro_activate")) {
5600
+ global $wplc_pro_version;
5601
+ if (intval(str_replace(".","",$wplc_pro_version)) < 6300) {
5602
+ $content .= "<p>In order to use reporting, please ensure you are using the latest Pro version (version 6.3.00 or newer).</p>";
5603
+ $content .= "<br><a title='Update Now' href='./update-core.php' style='width: 200px;height: 58px;text-align: center;line-height: 56px;font-size: 18px;' class='button button-primary'>".__("Update now" ,"wplivechat")."</a>";
5604
+ }
5605
+ } else {
5606
+ $content .= "<p>".__('Get all this and more in the ', 'wp-livechat')."<a href='https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=reporting' target='_BLANK'>".__("Pro add-on", "wplivechat")."</a></p>";
5607
+ $content .= "<br><a title='Upgrade Now' href='https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=reporting' style='width: 200px;height: 58px;text-align: center;line-height: 56px;font-size: 18px;' class='button button-primary' target='_BLANK'>".__("Upgrade Now" ,"wplivechat")."</a>";
5608
+ }
5609
+ $content .= "</td>";
5610
+ $content .= "</tr>";
5611
+ $content .= "</table>";
5612
+ $content .= "</div>";
5613
+ echo $content;
5614
+
5615
+ }
5616
+ /**
5617
+ * Basic version's triggers page - used to upsell the feature
5618
+ * @return string
5619
+ */
5620
+ function wplc_basic_triggers_page(){
5621
+ $content = "<div class='wrap wplc_wrap'>";
5622
+ $content .= "<h2>".__('WP Live Chat Support Triggers', 'wp-livechat')." (beta) </h2>";
5623
+ $content .= "<script>
5624
+ var isOn = true;
5625
+ jQuery(function(){
5626
+ jQuery(function(){
5627
+ setInterval(function(){
5628
+ if(isOn){
5629
+ jQuery('.trigger_img_main').fadeOut('fast', function(){
5630
+ jQuery('.trigger_img_sec').fadeIn('slow');
5631
+ jQuery('.trigger_img_sec').fadeIn('slow');
5632
+ });
5633
+ } else {
5634
+ jQuery('.trigger_img_sec').fadeOut('fast');
5635
+ jQuery('.trigger_img_sec').fadeOut('fast', function(){
5636
+ jQuery('.trigger_img_main').fadeIn('slow');
5637
+ });
5638
+ }
5639
+ isOn = !isOn;
5640
+ }, 5000);
5641
+ });
5642
+ });
5643
+ </script>";
5644
+
5645
+ $content .= "<table class=\"wp-list-table wplc_list_table widefat fixed form-table\" cellspacing=\"0\" style='width:98%'>";
5646
+ $content .= "<tr>";
5647
+ $content .= "<td style='width:35%; vertical-align:top;'>";
5648
+ $content .= "<img class='trigger_img_main' style='width:99%; height:auto; padding:2px; border:1px lightgray solid;box-shadow: 3px 3px 2px -2px #999;-webkit-box-shadow: 3px 3px 2px -2px #999;-moz-box-shadow: 3px 3px 2px -2px #999;-o-box-shadow: 3px 3px 2px -2px #999;' src='".plugins_url('/images/trigger_sample.jpg', __FILE__)."'>";
5649
+ $content .= "<img class='trigger_img_sec'style='display: none; width:49%; height:auto; border:1px lightgray solid;box-shadow: 3px 3px 2px -2px #999;-webkit-box-shadow: 3px 3px 2px -2px #999;-moz-box-shadow: 3px 3px 2px -2px #999;-o-box-shadow: 3px 3px 2px -2px #999;' src='".plugins_url('/images/trigger_sample_front.jpg', __FILE__)."'>";
5650
+ $content .= "</td>";
5651
+ $content .= "<td style='vertical-align:top;'>";
5652
+ $content .= "<h3>".__('WP Live Chat Support Triggers', 'wp-livechat')."</h3>";
5653
+ $content .= "<p>".__('Create custom data triggers when users view a certain page, spend a certain amount of time on a page, scroll past a certain point or when their mouse leaves the window.', 'wp-livechat')."</p>";
5654
+
5655
+
5656
+ $content .= "<br><p><strong>".__('Trigger Types', 'wp-livechat').":</strong></p>";
5657
+ $content .= "<ul style='list-style: inherit;margin-left: 22px;'>";
5658
+ $content .= "<li>".__('Page Trigger', 'wp-livechat')."</li>";
5659
+ $content .= "<li>".__('Time Trigger', 'wp-livechat')."</li>";
5660
+ $content .= "<li>".__('Scroll Trigger', 'wp-livechat')."</li>";
5661
+ $content .= "<li>".__('Page Leave Trigger', 'wp-livechat')."</li>";
5662
+ $content .= "</ul>";
5663
+
5664
+ if (function_exists("wplc_pro_activate")) {
5665
+ global $wplc_pro_version;
5666
+ if (intval(str_replace(".","",$wplc_pro_version)) < 6200) {
5667
+ $content .= "<p>In order to use data triggers, please ensure you are using the latest Pro version (version 6.2.00 or newer).</p>";
5668
+ $content .= "<br><a title='Update Now' href='./update-core.php' style='width: 200px;height: 58px;text-align: center;line-height: 56px;font-size: 18px;' class='button button-primary'>".__("Update now" ,"wplivechat")."</a>";
5669
+ }
5670
+ } else {
5671
+ $content .= "<p>".__('Get all this and more in the ', 'wp-livechat')."<a href='https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=data_triggers' target='_BLANK'>".__("Pro add-on", "wplivechat")."</a></p>";
5672
+ $content .= "<br><a title='Upgrade Now' href='https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=data_triggers' style='width: 200px;height: 58px;text-align: center;line-height: 56px;font-size: 18px;' class='button button-primary' target='_BLANK'>".__("Upgrade Now" ,"wplivechat")."</a>";
5673
+ }
5674
+ $content .= "</td>";
5675
+ $content .= "</tr>";
5676
+ $content .= "</table>";
5677
+ $content .= "</div>";
5678
+ echo $content;
5679
+
5680
+ }
5681
+ /**
5682
+ * Basic version's custom fields page - used to upsell the feature
5683
+ * @return string
5684
+ */
5685
+ function wplc_basic_custom_fields_page(){
5686
+ $content = "<div class='wrap wplc_wrap'>";
5687
+ $content .= "<h2>".__('WP Live Chat Support Custom Fields', 'wplivechat')."</h2>";
5688
+ $content .= "<table class=\"wp-list-table wplc_list_table widefat fixed form-table\" cellspacing=\"0\" style='width:98%'>";
5689
+ $content .= "<tr>";
5690
+ $content .= "<td style='width:35%; vertical-align:top;'>";
5691
+ $content .= "<img class='trigger_img_main' style='width:99%; height:auto; padding:2px; border:1px lightgray solid;box-shadow: 3px 3px 2px -2px #999;-webkit-box-shadow: 3px 3px 2px -2px #999;-moz-box-shadow: 3px 3px 2px -2px #999;-o-box-shadow: 3px 3px 2px -2px #999;' src='".plugins_url('/images/trigger_sample.jpg', __FILE__)."'>";
5692
+ $content .= "</td>";
5693
+ $content .= "<td style='vertical-align:top;'>";
5694
+ $content .= "<h3>".__('WP Live Chat Support Custom Fields', 'wp-livechat')."</h3>";
5695
+ $content .= "<p>".__('Create custom fields, allowing your visitors to enter the data you need before starting a chat.', 'wp-livechat')."</p>";
5696
+ $content .= "<br><p><strong>".__('Custom Field Types', 'wp-livechat').":</strong></p>";
5697
+ $content .= "<ul style='list-style: inherit;margin-left: 22px;'>";
5698
+ $content .= "<li>".__('Text Fields', 'wp-livechat')."</li>";
5699
+ $content .= "<li>".__('Dropdown Fields', 'wp-livechat')."</li>";
5700
+ $content .= "</ul>";
5701
+
5702
+ if (function_exists("wplc_pro_activate")) {
5703
+ global $wplc_pro_version;
5704
+ if (intval(str_replace(".","",$wplc_pro_version)) < 7000) {
5705
+ $content .= "<p>In order to use custom fields, please ensure you are using the latest Pro version (version 7.0.0 or newer).</p>";
5706
+ $content .= "<br><a title='Update Now' href='./update-core.php' style='width: 200px;height: 58px;text-align: center;line-height: 56px;font-size: 18px;' class='button button-primary'>".__("Update now" ,"wplivechat")."</a>";
5707
+ }
5708
+ } else {
5709
+ $content .= "<p>".__('Get all this and more in the ', 'wp-livechat')."<a href='https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=custom_fields' target='_BLANK'>".__("Pro add-on", "wplivechat")."</a></p>";
5710
+ $content .= "<br><a title='Upgrade Now' href='https://www.wp-livechat.com/purchase-pro/?utm_source=plugin&utm_medium=link&utm_campaign=custom_fields' style='width: 200px;height: 58px;text-align: center;line-height: 56px;font-size: 18px;' class='button button-primary' target='_BLANK'>".__("Upgrade Now" ,"wplivechat")."</a>";
5711
+ }
5712
+ $content .= "</td>";
5713
+ $content .= "</tr>";
5714
+ $content .= "</table>";
5715
+ $content .= "</div>";
5716
+ echo $content;
5717
+ }
5718
+
5719
+ add_action('wplc_hook_admin_settings_main_settings_after','wplc_powered_by_link_settings_page',2);
5720
+ /**
5721
+ * Adds the necessary checkbox to enable/disable the 'Powered by' link
5722
+ * @return string
5723
+ */
5724
+ function wplc_powered_by_link_settings_page() {
5725
+ $wplc_powered_by = get_option("WPLC_POWERED_BY");
5726
+ ?>
5727
+ <table class='form-table wp-list-table wplc_list_table widefat fixed striped pages' width='700'>
5728
+ <tr>
5729
+ <td width='350' valign='top'>
5730
+ <?php _e("Display a 'Powered by' link in the chat box", "wplivechat") ?>: <i class="fa fa-question-circle wplc_light_grey wplc_settings_tooltip" title="<?php _e("Checking this will display a 'Powered by WP Live Chat Support' caption at the bottom of your chatbox.", 'wplivechat'); ?>"></i>
5731
+ </td>
5732
+ <td>
5733
+ <input type="checkbox" value="1" name="wplc_powered_by" <?php if ( $wplc_powered_by && $wplc_powered_by == 1 ) { echo "checked"; } ?> />
5734
+ </td>
5735
+ </tr>
5736
+ </table>
5737
+ <hr>
5738
+ <?php
5739
+ }
5740
+
5741
+ add_action( "wplc_hook_head", "wplc_powered_by_link_save_settings" );
5742
+ /**
5743
+ * Saves the 'Powered by' link settings
5744
+ * @return void
5745
+ */
5746
+ function wplc_powered_by_link_save_settings(){
5747
+
5748
+ if( isset( $_POST['wplc_save_settings'] ) ){
5749
+
5750
+ if( isset( $_POST['wplc_powered_by'] ) && $_POST['wplc_powered_by'] == '1' ){
5751
+ update_option( "WPLC_POWERED_BY", 1 );
5752
+ } else {
5753
+ update_option( "WPLC_POWERED_BY", 0 );
5754
+ }
5755
+
5756
+ }
5757
+
5758
+ }
5759
+
5760
+ add_filter( "wplc_start_chat_user_form_after_filter", "wplc_powered_by_link_in_chat", 12, 2 );
5761
+ /**
5762
+ * Appends the 'Powered by' link to the chat window
5763
+ * @param string $string the current contents of the chat box
5764
+ * @param int $cid the current chat ID
5765
+ * @return string the chat contents, with the 'Powered by' link appended to it
5766
+ */
5767
+ function wplc_powered_by_link_in_chat( $string ){
5768
+
5769
+ $show_powered_by = get_option( "WPLC_POWERED_BY" );
5770
+
5771
+ if( $show_powered_by == 1){
5772
+ $ret = "<i style='text-align: center; display: block; padding: 5px 0; font-size: 10px;'><a href='https://wp-livechat.com/?utm_source=poweredby&utm_medium=click&utm_campaign=".esc_html(site_url())."'' target='_BLANK' rel='nofollow'>".__("Powered by WP Live Chat Support", "wplivechat")."</a></i>";
5773
+
5774
+ } else {
5775
+
5776
+ $ret = "";
5777
+
5778
+ }
5779
+
5780
+ return $string . $ret;
5781
+
5782
+ }
5783
+
5784
+ add_action( "admin_enqueue_scripts", "wplc_custom_scripts_scripts" );
5785
+ /**
5786
+ * Loads the Ace.js editor for the custom scripts
5787
+ * @return void
5788
+ */
5789
+ function wplc_custom_scripts_scripts(){
5790
+
5791
+ if ( isset( $_GET['page'] ) ) {
5792
+ if ( $_GET['page'] == 'wplivechat-menu-settings' ) {
5793
+ wp_enqueue_script( "wplc-custom-script-tab-ace",'//cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js', array('jquery') );
5794
+ } else if ( $_GET['page'] == 'wplivechat-menu-dashboard' ) {
5795
+ wp_enqueue_script( 'wplc-custom-script-dashboard', plugins_url( '/js/wplc_dashboard.js', __FILE__ ), array('jquery'), null, true );
5796
+ }
5797
+
5798
+ }
5799
+
5800
+ }
5801
+
5802
+ add_filter( "wplc_filter_setting_tabs", "wplc_custom_scripts_tab" );
5803
+ /**
5804
+ * Adds a tab for the custom scripts
5805
+ * @param array $array current array that is made available to us
5806
+ * @return array our tabs array has been added to the array
5807
+ */
5808
+ function wplc_custom_scripts_tab( $array ){
5809
+
5810
+ $array['custom-scripts'] = array(
5811
+ 'href' => '#wplc-custom-scripts',
5812
+ 'icon' => 'fa fa-pencil',
5813
+ 'label' => __("Custom Scripts", "wplivechat")
5814
+ );
5815
+
5816
+ return $array;
5817
+ }
5818
+
5819
+ add_action( "wplc_hook_settings_page_more_tabs", "wplc_custom_scripts_content" );
5820
+ /**
5821
+ * Adds the tab content to the settings page to allow the user to add custom CSS & JS
5822
+ * @return string
5823
+ */
5824
+ function wplc_custom_scripts_content(){
5825
+
5826
+ $wplc_custom_css = get_option( "WPLC_CUSTOM_CSS" );
5827
+ $wplc_custom_js = get_option( "WPLC_CUSTOM_JS" );
5828
+
5829
+ $content = "";
5830
+
5831
+ $content .= "<div id='wplc-custom-scripts'>";
5832
+
5833
+ $content .= "<h2>".__("Custom Scripts", "wplivechat")."</h2>";
5834
+ $content .= "<table class='form-table'>";
5835
+
5836
+ $content .= "<tr>";
5837
+ $content .= "<td width='300'>".__("Custom CSS", "wplivechat")."</td>";
5838
+ $content .= "<td><div id='wplc_custom_css_editor'></div><textarea name='wplc_custom_css' id='wplc_custom_css' style='display: none;' data-editor='css' rows='12'>".strip_tags( stripslashes( $wplc_custom_css ) )."</textarea></td>";
5839
+ $content .= "</tr>";
5840
+
5841
+ $content .= "<tr>";
5842
+ $content .= "<td width='300'>".__("Custom JS", "wplivechat")."</td>";
5843
+ $content .= "<td valign='middle'><div id='wplc_custom_js_editor'></div><textarea name='wplc_custom_js' id='wplc_custom_js' style='display: none;' data-editor='javascript' rows='12'>".strip_tags( stripslashes( $wplc_custom_js ) )."</textarea></td>";
5844
+ $content .= "</tr>";
5845
+
5846
+ $content .= "</table>";
5847
+
5848
+ $content .= "</div>";
5849
+
5850
+ echo $content;
5851
+
5852
+ }
5853
+
5854
+ add_action( "wplc_hook_head", "wplc_custom_scripts_save" );
5855
+ /**
5856
+ * Saves the custom scripts into the options table
5857
+ * @return void
5858
+ */
5859
+ function wplc_custom_scripts_save(){
5860
+
5861
+ if( isset( $_POST['wplc_save_settings'] ) ){
5862
+
5863
+ if( isset( $_POST['wplc_custom_css'] ) ){
5864
+ update_option( "WPLC_CUSTOM_CSS", nl2br( $_POST['wplc_custom_css'] ) );
5865
+ }
5866
+
5867
+ if( isset( $_POST['wplc_custom_js'] ) ){
5868
+ update_option( "WPLC_CUSTOM_JS", nl2br( $_POST['wplc_custom_js'] ) );
5869
+ }
5870
+
5871
+ }
5872
+
5873
+ }
5874
+
5875
+ add_action( "wp_head", "wplc_custom_scripts_frontend" );
5876
+ /**
5877
+ * Display the custom scripts on the front end of the site
5878
+ * @return string
5879
+ */
5880
+ function wplc_custom_scripts_frontend(){
5881
+
5882
+ $wplc_custom_css = get_option( "WPLC_CUSTOM_CSS" );
5883
+ $wplc_custom_js = get_option( "WPLC_CUSTOM_JS" );
5884
+
5885
+ if( $wplc_custom_css ){
5886
+ echo "<!-- WPLC Custom CSS -->";
5887
+ echo "<style>";
5888
+ echo strip_tags( stripslashes( $wplc_custom_css ) );
5889
+ echo "</style>";
5890
+ }
5891
+
5892
+ if( $wplc_custom_js ){
5893
+ echo "<!-- WPLC Custom JS -->";
5894
+ echo "<script>";
5895
+ echo strip_tags( stripslashes( $wplc_custom_js ) );
5896
+ echo "</script>";
5897
+ }
5898
+
5899
+ }
5900
+
5901
+ add_filter( "wplc_offline_message_subject_filter", "wplc_change_offline_message", 10, 1 );
5902
+ /**
5903
+ * Adds a filter to change the email address to the user's preference
5904
+ * @param string $subject The default subject
5905
+ * @return string
5906
+ */
5907
+ function wplc_change_offline_message( $subject ){
5908
+
5909
+ $wplc_settings = get_option( "WPLC_SETTINGS");
5910
+
5911
+ if( isset( $wplc_settings['wplc_pro_chat_email_offline_subject'] ) ){
5912
+ $subject = stripslashes( $wplc_settings['wplc_pro_chat_email_offline_subject'] );
5913
+ }
5914
+
5915
+ return $subject;
5916
+
5917
+ }
5918
+
5919
+ function wplc_basic_version_departments(){
5920
+ echo "<div class='wrap wplc_wrap'>";
5921
+ echo sprintf( "<div class='error'><p>".__("WP Live Chat Support requires WP Live Chat Support Pro Version 7.0.0 or greater in order for departments to function as expected. Please update WP Live Chat Support %s", "wplivechat")."</p></div>", "<a href='".admin_url('update-core.php')."'>".__("here", "wplivechat")."</a>" );
5922
+ echo "</div>";
5923
+
5924
+ $content = "";
5925
+
5926
+ $content .= "<table class=\"wp-list-table wplc_list_table widefat fixed \" cellspacing=\"0\" style='width:98%'>";
5927
+ $content .= "<thead>";
5928
+ $content .= "<tr>";
5929
+ $content .= "<th scope='col'><span>" . __("ID", "wplivechat") . "</span></th>";
5930
+ $content .= "<th scope='col'><span>" . __("Name", "wplivechat") . "</span></th>";
5931
+ $content .= "<th scope='col'><span>" . __("Action", "wplivechat") . "</span></th>";
5932
+ $content .= "</tr>";
5933
+ $content .= "</thead>";
5934
+
5935
+ $content .= "<tr><td>".__("Please update your Pro version to create a department", "wp-livechat")."</td><td></td><td></td></tr>";
5936
+
5937
+ $content .= "</table>";
5938
+
5939
+ echo $content;
5940
+ }
5941
+
5942
+ add_filter( 'wplc_filter_active_chat_box_notification', 'wplc_active_chat_box_notice' );
5943
+
5944
+ if ( ! function_exists( "wplc_active_chat_box_notices" ) ) {
5945
+ add_action( "wplc_hook_chat_dashboard_above", "wplc_active_chat_box_notices" );
5946
+ function wplc_active_chat_box_notices() {
5947
+ $wplc_settings = get_option( "WPLC_SETTINGS" );
5948
+ if ( $wplc_settings["wplc_settings_enabled"] == 2 ) { ?>
5949
+ <div class="wplc-chat-box-notification wplc-chat-box-notification--disabled">
5950
+ <p><?php echo sprintf( __( 'The Live Chat box is currently disabled on your website due to : <a href="%s">General Settings</a>', 'wp-livechat' ), admin_url( 'admin.php?page=wplivechat-menu-settings#tabs-1' ) ) ?></p>
5951
+ </div>
5952
+ <?php
5953
+ } else {
5954
+ //$notice = '<div class="wplc-chat-box-notification">';
5955
+ //$notice .= '<p>' . __( 'The Live Chat box is currently active', 'wp-livechat' ) . '</p>';
5956
+ //$notice .= '</div>';
5957
+ $notice = '';
5958
+ $notice = apply_filters( 'wplc_filter_active_chat_box_notice', $notice );
5959
+ echo $notice;
5960
+ }
5961
+
5962
+ }
5963
+ }
5964
+
5965
+
5966
+ add_filter("wplc_filter_chat_4th_layer_below_input","nifty_chat_ratings_div_backwards_compat",2,2);
5967
+ /**
5968
+ * This adds backwards compatibility to the new look and feel of the modern chat box
5969
+ *
5970
+ * The ' | ' is removed from the rating icons to fit the new look and feel
5971
+ *
5972
+ */
5973
+ function nifty_chat_ratings_div_backwards_compat($msg, $wplc_setting){
5974
+ $msg = str_replace(" | ","", $msg);
5975
+ return $msg;
5976
+
5977
+ }
5978
+
5979
+ /**
5980
+ * Identifies if the chat box should show, scripts should run and the dashboard should display correctly all based on certain versions.
5981
+ *
5982
+ * i.e. This is the part where we force users to upgrade their extensions to make sure everything works correctly.
5983
+ *
5984
+ * Use with caution and always try add backwards compatibility where necessary
5985
+ *
5986
+ * @param bool $continue
5987
+ * @return bool
5988
+ * @since 7.1.00
5989
+ * @author Nick Duncan
5990
+ */
5991
+ add_filter( "wplc_version_check_continue", "wplc_filter_control_version_check_continue", 10, 1 );
5992
+ function wplc_filter_control_version_check_continue( $continue ) {
5993
+
5994
+ /**
5995
+ * Check to see that we are on the cloud server 1.3.00 or newer
5996
+ */
5997
+ if ( function_exists("wplc_cloud_load_updates") ) {
5998
+ global $wplc_cloud_version;
5999
+ $float_version = intval( str_replace(".", "", $wplc_cloud_version ) );
6000
+ if ($float_version < 2000) {
6001
+ return sprintf( "Your chat has been disabled due to a version conflict. Please <a href='%s'>update your cloud extension</a> to 1.3.00 or higher.", admin_url('update-core.php') )."<br />";
6002
+
6003
+ }
6004
+ }
6005
+
6006
+ return $continue;
6007
+
6008
+ }
6009
+
6010
+ /*
6011
+ * Returns the WDT emoji selector
6012
+ */
6013
+ function wplc_emoji_selector_div(){
6014
+ $wplc_settings = get_option("WPLC_SETTINGS");
6015
+
6016
+ // NB: This causes Failed to initVars ReferenceError: wplc_show_date is not defined when uncommented and enabled
6017
+ if(!empty($wplc_settings['wplc_disable_emojis']))
6018
+ return;
6019
+
6020
+ $emoji_container = "";
6021
+ if(isset($wplc_settings['wplc_use_node_server']) && $wplc_settings['wplc_use_node_server'] == 1){
6022
+ $emoji_container = '<div class="wdt-emoji-popup">
6023
+ <a href="#" class="wdt-emoji-popup-mobile-closer"> &times; </a>
6024
+ <div class="wdt-emoji-menu-content">
6025
+ <div id="wdt-emoji-menu-header">
6026
+ <a class="wdt-emoji-tab" data-group-name="People"></a>
6027
+ <a class="wdt-emoji-tab" data-group-name="Nature"></a>
6028
+ <a class="wdt-emoji-tab" data-group-name="Foods"></a>
6029
+ <a class="wdt-emoji-tab" data-group-name="Activity"></a>
6030
+ <a class="wdt-emoji-tab" data-group-name="Places"></a>
6031
+ <a class="wdt-emoji-tab" data-group-name="Objects"></a>
6032
+ <a class="wdt-emoji-tab" data-group-name="Symbols"></a>
6033
+ <a class="wdt-emoji-tab" data-group-name="Flags"></a>
6034
+ </div>
6035
+ <div class="wdt-emoji-scroll-wrapper">
6036
+ <div id="wdt-emoji-menu-items">
6037
+ <input id="wdt-emoji-search" type="text" placeholder="Search">
6038
+ <h3 id="wdt-emoji-search-result-title">Search Results</h3>
6039
+ <div class="wdt-emoji-sections"></div>
6040
+ <div id="wdt-emoji-no-result">No emoji found</div>
6041
+ </div>
6042
+ </div>
6043
+ <div id="wdt-emoji-footer">
6044
+ <div id="wdt-emoji-preview">
6045
+ <span id="wdt-emoji-preview-img"></span>
6046
+ <div id="wdt-emoji-preview-text">
6047
+ <span id="wdt-emoji-preview-name"></span><br>
6048
+ <span id="wdt-emoji-preview-aliases"></span>
6049
+ </div>
6050
+ </div>
6051
+ <div id="wdt-emoji-preview-bundle">
6052
+ <span></span>
6053
+ </div>
6054
+ <span class="wdt-credit">WDT Emoji Bundle</span>
6055
+ </div>
6056
+ </div>
6057
+ </div>';
6058
+ }
6059
+
6060
+ return $emoji_container;
6061
+
6062
+ }
6063
+
6064
+ add_action("wplc_hook_chat_missed","wplc_missed_chats_deprecation_notice",5);
6065
+ /**
6066
+ * Displays a notice to the user that Missed Chats is being deprecated
6067
+ */
6068
+ function wplc_missed_chats_deprecation_notice() {
6069
+ $output = "<div class='update-nag' style='margin-top: 0px;margin-bottom: 5px;'>";
6070
+ $output .= "<strong>" . __("Deprecation Notice", "wplivechat") . "</strong><br>";
6071
+ $output .= "<p>" . __("Please note, missed chat functionality is being deprecated as we will be moving to a customer oriented system in the near future. ", "wplivechat") . "</p>";
6072
+ $output .= "<p>" . __("The new system will offer more insight into your user base while enhancing your experience when retrieving statistics and information. ", "wplivechat") . "</p>";
6073
+ $output .= "<p>" . __("This area will remain active for the time being, however it is recommended that you prepare for this change in the near future. ", "wplivechat") . "</p>";
6074
+ $output .= "</div>";
6075
+
6076
+ echo $output;
6077
+ }
6078
+
6079
+ add_action( 'admin_notices', 'wplc_browser_notifications_admin_warning' );
6080
+ /**
6081
+ * Displays browser notifications warning.
6082
+ *
6083
+ * Only displays if site is insecure (no SSL).
6084
+ */
6085
+ function wplc_browser_notifications_admin_warning() {
6086
+
6087
+ if ( ! is_ssl() && isset( $_GET['page'] ) && $_GET['page'] === 'wplivechat-menu-settings' ) {
6088
+
6089
+ if ( isset( $_GET['wplc_dismiss_notice_bn'] ) && 'true' === $_GET['wplc_dismiss_notice_bn'] ) {
6090
+
6091
+ update_option( 'wplc_dismiss_notice_bn', 'true' );
6092
+
6093
+ }
6094
+
6095
+ if ( get_option( 'wplc_dismiss_notice_bn') !== 'true' ) {
6096
+
6097
+ ?>
6098
+ <div class="notice notice-warning is-dismissible">
6099
+ <p><img src="<?php echo esc_attr( plugins_url( 'images/wplc-logo.png', __FILE__ ) ); ?>" style="width:260px;height:auto;max-width:100%;"></p>
6100
+ <p><strong><?php esc_html_e( 'Browser notifications will no longer function on insecure (non-SSL) sites.', 'wplivechat' ); ?></strong></p>
6101
+ <p><?php esc_html_e( 'Please add an SSL certificate to your site to continue receiving chat notifications in your browser.', 'wplivechat' ); ?></p>
6102
+ <p><a href="?page=<?php echo esc_attr( $_GET['page'] ); ?>&wplc_dismiss_notice_bn=true" id="wplc_dismiss_notice_bn" class="button"><?php esc_html_e( "Don't Show This Again", 'wplivechat' ); ?></a></p>
6103
+ </div>
6104
+ <?php
6105
+
6106
+ }
6107
+ }
6108
+ }
6109
+
6110
+ if ( function_exists( 'wplc_et_first_run_check' ) ) {
6111
+ add_action( 'admin_notices', 'wplc_transcript_admin_notice' );
6112
+ }
6113
+ function wplc_transcript_admin_notice() {
6114
+ printf( '<div class="notice notice-info">%1$s</div>', __( 'Please deactivate WP Live Chat Suport - Email Transcript plugin. Since WP Live Chat Support 8.0.05 there is build in support for Email Transcript.', 'wplivechat' ) );
6115
+ }
6116
+
6117
+ add_action( 'init', 'wplc_transcript_first_run_check' );
6118
+ function wplc_transcript_first_run_check() {
6119
+ if ( ! get_option( "WPLC_ET_FIRST_RUN" ) ) {
6120
+ /* set the default settings */
6121
+ $wplc_et_data['wplc_enable_transcripts'] = 1;
6122
+ $wplc_et_data['wplc_send_transcripts_to'] = 'user';
6123
+ $wplc_et_data['wplc_send_transcripts_when_chat_ends'] = 0;
6124
+ $wplc_et_data['wplc_et_email_body'] = wplc_transcript_return_default_email_body();
6125
+ $wplc_et_data['wplc_et_email_header'] = '<a title="' . get_bloginfo( 'name' ) . '" href="' . get_bloginfo( 'url' ) . '" style="font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #FFF; font-weight: bold; text-decoration: underline;">' . get_bloginfo( 'name' ) . '</a>';
6126
+
6127
+ $default_footer_text = sprintf( __( 'Thank you for chatting with us. If you have any questions, please <a href="%1$s" target="_blank" style="font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #FFF; font-weight: bold; text-decoration: underline;">contact us</a>', 'wplivechat' ),
6128
+ 'mailto:' . get_bloginfo( 'admin_email' )
6129
+ );
6130
+
6131
+ $wplc_et_data['wplc_et_email_footer'] = "<span style='font-family: Arial, Helvetica, sans-serif; font-size: 13px; color: #FFF; font-weight: normal;'>" . $default_footer_text . "</span>";
6132
+
6133
+
6134
+ update_option( 'WPLC_ET_SETTINGS', $wplc_et_data );
6135
+ update_option( "WPLC_ET_FIRST_RUN", true );
6136
+ }
6137
+ }
6138
+
6139
+ add_action( 'wplc_hook_admin_visitor_info_display_after', 'wplc_transcript_add_admin_button' );
6140
+ function wplc_transcript_add_admin_button( $cid ) {
6141
+ $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6142
+ $wplc_enable_transcripts = $wplc_et_settings['wplc_enable_transcripts'];
6143
+ if ( isset( $wplc_enable_transcripts ) && $wplc_enable_transcripts == 1 ) {
6144
+ echo "<p><a href=\"javascript:void(0);\" cid='" . sanitize_text_field( $cid ) . "' class=\"wplc_admin_email_transcript button button-secondary\" id=\"wplc_admin_email_transcript\">" . __( "Email transcript to user", "wplivechat" ) . "</a></p>";
6145
+ }
6146
+ }
6147
+
6148
+ add_action( 'wplc_hook_admin_javascript_chat', 'wplc_transcript_admin_javascript' );
6149
+ function wplc_transcript_admin_javascript() {
6150
+ $wplc_et_ajax_nonce = wp_create_nonce( "wplc_et_nonce" );
6151
+ wp_register_script( 'wplc_transcript_admin', plugins_url( '/js/wplc_transcript.js', __FILE__ ), null, '', true );
6152
+ $wplc_transcript_localizations = array(
6153
+ 'ajax_nonce' => $wplc_et_ajax_nonce,
6154
+ 'string_loading' => __( "Sending transcript...", "wplivechat" ),
6155
+ 'string_title' => __( "Sending Transcript", "wplivechat" ),
6156
+ 'string_close' => __( "Close", "wplivechat" ),
6157
+ 'string_chat_emailed' => __( "The chat transcript has been emailed.", "wplivechat" ),
6158
+ 'string_error1' => sprintf( __( "There was a problem emailing the chat. Please <a target='_BLANK' href='%s'>contact support</a>.", "wplivechat" ), "http://wp-livechat.com/contact-us/?utm_source=plugin&utm_medium=link&utm_campaign=error_emailing_chat" )
6159
+ );
6160
+ wp_localize_script( 'wplc_transcript_admin', 'wplc_transcript_nonce', $wplc_transcript_localizations );
6161
+ wp_enqueue_script( 'wplc_transcript_admin' );
6162
+ }
6163
+
6164
+ add_action( 'wp_ajax_wplc_et_admin_email_transcript', 'wplc_transcript_callback' );
6165
+ function wplc_transcript_callback() {
6166
+ $check = check_ajax_referer( 'wplc_et_nonce', 'security' );
6167
+ if ( $check == 1 ) {
6168
+
6169
+ if ( isset( $_POST['el'] ) && $_POST['el'] === 'endChat' ) {
6170
+ $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6171
+ $transcript_chat_ends = $wplc_et_settings['wplc_send_transcripts_when_chat_ends'];
6172
+ if ( $transcript_chat_ends === 0 ) {
6173
+ wp_die();
6174
+ }
6175
+ }
6176
+
6177
+ if ( $_POST['action'] == "wplc_et_admin_email_transcript" ) {
6178
+ if ( isset( $_POST['cid'] ) ) {
6179
+ $cid = wplc_return_chat_id_by_rel( $_POST['cid'] );
6180
+ echo json_encode( wplc_send_transcript( sanitize_text_field( $cid ) ) );
6181
+ } else {
6182
+ echo json_encode( array( "error" => "no CID" ) );
6183
+ }
6184
+ wp_die();
6185
+ }
6186
+
6187
+ wp_die();
6188
+ }
6189
+ wp_die();
6190
+ }
6191
+
6192
+ function wplc_send_transcript( $cid ) {
6193
+ if ( ! $cid ) {
6194
+ return array( "error" => "no CID", "cid" => $cid );
6195
+ }
6196
+
6197
+ if( ! filter_var($cid, FILTER_VALIDATE_INT) ) {
6198
+ /* We need to identify if this CID is a node CID, and if so, return the WP CID */
6199
+ $cid = wplc_return_chat_id_by_rel($cid);
6200
+ }
6201
+
6202
+ $email = false;
6203
+ $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6204
+
6205
+ $wplc_enable_transcripts = $wplc_et_settings['wplc_enable_transcripts'];
6206
+ if ( isset( $wplc_enable_transcripts ) && $wplc_enable_transcripts == 1 ) {
6207
+
6208
+ if ( function_exists( "wplc_get_chat_data" ) ) {
6209
+ $cdata = wplc_get_chat_data( $cid );
6210
+ if ( $cdata ) {
6211
+ if ( $wplc_et_settings['wplc_send_transcripts_to'] === 'admin' ) {
6212
+ $user = wp_get_current_user();
6213
+ $email = $user->user_email;
6214
+ } else {
6215
+ $email = $cdata->email;
6216
+ }
6217
+ if ( ! $email ) {
6218
+ return array( "error" => "no email" );
6219
+ }
6220
+ } else {
6221
+ return array( "error" => "no chat data" );
6222
+ }
6223
+ } else {
6224
+ return array( "error" => "basic funtion missing" );
6225
+ }
6226
+
6227
+ $headers = array( 'Content-Type: text/html; charset=UTF-8' );
6228
+ $subject = sprintf( __( 'Your chat transcript from %1$s', 'wplivechat' ),
6229
+ get_bloginfo( 'url' )
6230
+ );
6231
+ wp_mail( $email, $subject, wplc_transcript_return_chat_messages( $cid ), $headers );
6232
+
6233
+ }
6234
+
6235
+ return array( "success" => 1 );
6236
+
6237
+ }
6238
+ add_action('wplc_send_transcript_hook', 'wplc_send_transcript', 10, 1);
6239
+
6240
+ function wplc_transcript_return_chat_messages( $cid ) {
6241
+ global $current_chat_id;
6242
+ $current_chat_id = $cid;
6243
+ $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6244
+ $body = html_entity_decode( stripslashes( $wplc_et_settings['wplc_et_email_body'] ) );
6245
+
6246
+ if ( ! $body ) {
6247
+ $body = do_shortcode( wplc_transcript_return_default_email_body() );
6248
+ } else {
6249
+ $body = do_shortcode( $body );
6250
+ }
6251
+
6252
+ return $body;
6253
+ }
6254
+
6255
+ function wplc_transcript_return_default_email_body() {
6256
+ $body = '
6257
+ <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">
6258
+ <html>
6259
+
6260
+ <body>
6261
+
6262
+
6263
+
6264
+ <table id="" border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color: #ec822c;">
6265
+ <tbody>
6266
+ <tr>
6267
+ <td width="100%" style="padding: 30px 20px 100px 20px;">
6268
+ <table align="center" cellpadding="0" cellspacing="0" class="" width="100%" style="border-collapse: separate; max-width:600px;">
6269
+ <tbody>
6270
+ <tr>
6271
+ <td style="text-align: center; padding-bottom: 20px;">
6272
+
6273
+ <p>[wplc_et_transcript_header_text]</p>
6274
+ </td>
6275
+ </tr>
6276
+ </tbody>
6277
+ </table>
6278
+
6279
+ <table id="" align="center" cellpadding="0" cellspacing="0" class="" width="100%" style="border-collapse: separate; max-width: 600px; font-family: Georgia, serif; font-size: 12px; color: rgb(51, 62, 72); border: 0px solid rgb(255, 255, 255); border-radius: 10px; background-color: rgb(255, 255, 255);">
6280
+ <tbody>
6281
+ <tr>
6282
+ <td class="sortable-list ui-sortable" style="padding:20px;">
6283
+ [wplc_et_transcript]
6284
+ </td>
6285
+ </tr>
6286
+ </tbody>
6287
+ </table>
6288
+
6289
+ <table align="center" cellpadding="0" cellspacing="0" class="" width="100%" style="border-collapse: separate; max-width:100%;">
6290
+ <tbody>
6291
+ <tr>
6292
+ <td style="padding:20px;">
6293
+ <table border="0" cellpadding="0" cellspacing="0" class="" width="100%">
6294
+ <tbody>
6295
+ <tr>
6296
+ <td id="" align="center">
6297
+ <p>[wplc_et_transcript_footer_text]</p>
6298
+ </td>
6299
+ </tr>
6300
+ </tbody>
6301
+ </table>
6302
+ </td>
6303
+ </tr>
6304
+ </tbody>
6305
+ </table>
6306
+ </td>
6307
+ </tr>
6308
+ </tbody>
6309
+ </table>
6310
+
6311
+
6312
+
6313
+ </div>
6314
+ </body>
6315
+ </html>
6316
+ ';
6317
+
6318
+ return $body;
6319
+ }
6320
+
6321
+ add_action( 'wplc_hook_admin_settings_save', 'wplc_transcript_save_settings' );
6322
+ function wplc_transcript_save_settings() {
6323
+ if ( isset( $_POST['wplc_save_settings'] ) ) {
6324
+ if ( isset( $_POST['wplc_enable_transcripts'] ) ) {
6325
+ $wplc_et_data['wplc_enable_transcripts'] = esc_attr( $_POST['wplc_enable_transcripts'] );
6326
+ } else {
6327
+ $wplc_et_data['wplc_enable_transcripts'] = 0;
6328
+ }
6329
+ if ( isset( $_POST['wplc_send_transcripts_to'] ) ) {
6330
+ $wplc_et_data['wplc_send_transcripts_to'] = esc_attr( $_POST['wplc_send_transcripts_to'] );
6331
+ } else {
6332
+ $wplc_et_data['wplc_send_transcripts_to'] = 'user';
6333
+ }
6334
+ if ( isset( $_POST['wplc_send_transcripts_when_chat_ends'] ) ) {
6335
+ $wplc_et_data['wplc_send_transcripts_when_chat_ends'] = esc_attr( $_POST['wplc_send_transcripts_when_chat_ends'] );
6336
+ } else {
6337
+ $wplc_et_data['wplc_send_transcripts_when_chat_ends'] = 0;
6338
+ }
6339
+ if ( isset( $_POST['wplc_et_email_header'] ) ) {
6340
+ $wplc_et_data['wplc_et_email_header'] = esc_attr( $_POST['wplc_et_email_header'] );
6341
+ }
6342
+ if ( isset( $_POST['wplc_et_email_footer'] ) ) {
6343
+ $wplc_et_data['wplc_et_email_footer'] = esc_attr( $_POST['wplc_et_email_footer'] );
6344
+ }
6345
+ if ( isset( $_POST['wplc_et_email_body'] ) ) {
6346
+ $wplc_et_data['wplc_et_email_body'] = esc_html( $_POST['wplc_et_email_body'] );
6347
+ }
6348
+ update_option( 'WPLC_ET_SETTINGS', $wplc_et_data );
6349
+
6350
+ }
6351
+ }
6352
+
6353
+ add_action( 'wplc_hook_admin_settings_main_settings_after', 'wplc_hook_admin_transcript_settings' );
6354
+ function wplc_hook_admin_transcript_settings() {
6355
+ $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6356
+ echo "<hr />";
6357
+ echo "<h3>" . __( "Chat Transcript Settings", 'wplivechat' ) . "</h3>";
6358
+ echo "<table class='form-table wp-list-table widefat fixed striped pages' width='700'>";
6359
+ echo " <tr>";
6360
+ echo " <td width='400' valign='top'>" . __( "Enable chat transcripts:", "wplivechat" ) . "</td>";
6361
+ echo " <td>";
6362
+ echo " <input type=\"checkbox\" value=\"1\" name=\"wplc_enable_transcripts\" ";
6363
+ if ( isset( $wplc_et_settings['wplc_enable_transcripts'] ) && $wplc_et_settings['wplc_enable_transcripts'] == 1 ) {
6364
+ echo "checked";
6365
+ }
6366
+ echo " />";
6367
+ echo " </td>";
6368
+ echo " </tr>";
6369
+
6370
+ echo " <tr>";
6371
+ echo " <td width='400' valign='top'>" . __( "Send transcripts to:", "wplivechat" ) . "</td>";
6372
+ echo " <td>";
6373
+ echo " <select name=\"wplc_send_transcripts_to\">";
6374
+ echo " <option value=\"user\" ";
6375
+ if ( isset( $wplc_et_settings['wplc_send_transcripts_to'] ) && $wplc_et_settings['wplc_send_transcripts_to'] == 'user' ) {
6376
+ echo "selected";
6377
+ }
6378
+ echo ">" . __( "User", "wplivechat" ) . "</option>";
6379
+ echo " <option value=\"admin\" ";
6380
+ if ( isset( $wplc_et_settings['wplc_send_transcripts_to'] ) && $wplc_et_settings['wplc_send_transcripts_to'] == 'admin' ) {
6381
+ echo "selected";
6382
+ }
6383
+ echo ">" . __( "Admin", "wplivechat" ) . "</option>";
6384
+ echo " </select>";
6385
+ echo " </td>";
6386
+ echo " </tr>";
6387
+
6388
+ echo " <tr>";
6389
+ echo " <td width='400' valign='top'>" . __( "Send transcripts when chat ends:", "wplivechat" ) . "</td>";
6390
+ echo " <td>";
6391
+ echo " <input type=\"checkbox\" value=\"1\" name=\"wplc_send_transcripts_when_chat_ends\" ";
6392
+ if ( isset( $wplc_et_settings['wplc_send_transcripts_when_chat_ends'] ) && $wplc_et_settings['wplc_send_transcripts_when_chat_ends'] == 1 ) {
6393
+ echo "checked";
6394
+ }
6395
+ echo " />";
6396
+ echo " </td>";
6397
+ echo " </tr>";
6398
+
6399
+ echo " <tr>";
6400
+ echo " <td width='400' valign='top'>" . __( "Email body", "wplivechat" ) . "</td>";
6401
+ echo " <td>";
6402
+ echo " <textarea cols='85' rows='15' name=\"wplc_et_email_body\">";
6403
+ if ( isset( $wplc_et_settings['wplc_et_email_body'] ) ) {
6404
+ echo html_entity_decode( stripslashes( $wplc_et_settings['wplc_et_email_body'] ) );
6405
+ }
6406
+ echo " </textarea>";
6407
+ echo " </td>";
6408
+ echo " </tr>";
6409
+
6410
+
6411
+ echo " <tr>";
6412
+ echo " <td width='400' valign='top'>" . __( "Email header", "wplivechat" ) . "</td>";
6413
+ echo " <td>";
6414
+ echo " <textarea cols='85' rows='5' name=\"wplc_et_email_header\">";
6415
+ if ( isset( $wplc_et_settings['wplc_et_email_header'] ) ) {
6416
+ echo stripslashes( $wplc_et_settings['wplc_et_email_header'] );
6417
+ }
6418
+ echo " </textarea>";
6419
+ echo " </td>";
6420
+ echo " </tr>";
6421
+
6422
+ echo " <tr>";
6423
+ echo " <td width='400' valign='top'>" . __( "Email footer", "wplivechat" ) . "</td>";
6424
+ echo " <td>";
6425
+ echo " <textarea cols='85' rows='5' name=\"wplc_et_email_footer\">";
6426
+ if ( isset( $wplc_et_settings['wplc_et_email_footer'] ) ) {
6427
+ echo stripslashes( $wplc_et_settings['wplc_et_email_footer'] );
6428
+ }
6429
+ echo " </textarea>";
6430
+ echo " </td>";
6431
+ echo " </tr>";
6432
+
6433
+
6434
+ echo "</table>";
6435
+ }
6436
+
6437
+ add_shortcode('wplc_et_transcript', 'wplc_transcript_get_transcript');
6438
+ function wplc_transcript_get_transcript() {
6439
+ global $current_chat_id;
6440
+ $cid = $current_chat_id;
6441
+
6442
+ if ( intval( $cid ) > 0 ) {
6443
+ return wplc_return_chat_messages( intval( $cid ), true );
6444
+ } else {
6445
+ return "0";
6446
+ }
6447
+ }
6448
+
6449
+ add_shortcode( 'wplc_et_transcript_footer_text', 'wplc_transcript_get_footer_text' );
6450
+ function wplc_transcript_get_footer_text() {
6451
+ $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6452
+ $wplc_et_footer = html_entity_decode( stripslashes( $wplc_et_settings['wplc_et_email_footer'] ) );
6453
+ if ( $wplc_et_footer ) {
6454
+ return $wplc_et_footer;
6455
+ } else {
6456
+ return "";
6457
+ }
6458
+ }
6459
+
6460
+ add_shortcode( 'wplc_et_transcript_header_text', 'wplc_transcript_get_header_text' );
6461
+ function wplc_transcript_get_header_text() {
6462
+ $wplc_et_settings = get_option( "WPLC_ET_SETTINGS" );
6463
+
6464
+ global $current_chat_id;
6465
+ $cid = $current_chat_id;
6466
+
6467
+ $from_email = "Unknown@unknown.com";
6468
+ $from_name = "User";
6469
+ if ( intval( $cid ) > 0 ) {
6470
+ $chat_data = wplc_get_chat_data( $cid );
6471
+ if ( isset( $chat_data->email ) ) {
6472
+ $from_email = $chat_data->email;
6473
+ }
6474
+ if ( isset( $chat_data->name ) ) {
6475
+ $from_name = $chat_data->name;
6476
+ }
6477
+ }
6478
+
6479
+ $wplc_et_header = "<h3>".$from_name." (".$from_email.")"."</h3>".html_entity_decode( stripslashes( $wplc_et_settings['wplc_et_email_header'] ) );
6480
+ if ( $wplc_et_header ) {
6481
+ return $wplc_et_header;
6482
+ } else {
6483
+ return "";
6484
+ }
6485
  }