PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 6.6.9
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v6.6.9
8.7.8 8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 8.5.5 8.5.4 8.5.3 All 534 releases
chatbot / includes / simple_text_response.php

simple_text_response.php in WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services 6.6.9, at includes/simple_text_response.php

601 lines 17.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 }
5 global $wpdb;
6 ?>
7 <style>
8 .wpbot_dashboard_header {
9 margin-right: unset !important;
10 margin-left: unset !important;
11 background: #32373c;
12 color: #fff;
13 text-align: center;
14 border-radius: 5px 5px 0px 0px;
15 }
16 .wpbot_addons_section {
17 margin-right: unset !important;
18 margin-left: unset !important;
19 margin-bottom: 10px;
20 background: #32373c;
21 padding-bottom: 20px;
22 border-radius: 0px 0px 5px 5px;
23 }
24 .wpbot_single_addon_wrapper2 {
25 background: #32373c !important;
26 color: #fff !important;
27 padding: 20px;
28 }
29 .wpbot_single_addon_wrapper2 .form-table th,.wpbot_single_addon_wrapper2 .form-wrap label{
30 color: #fff !important;
31 }
32 .wp-chatbot-admin-header, .wp-chatbot-admin-footer {
33 padding: 25px;
34 }
35 .wpbot_dashboard_header h1 {
36 font-size: 30px;
37 line-height: 100px;
38 margin: 0px;
39 color: #fff;
40 }
41 .container {
42 width: 1170px;
43 padding-right: 15px;
44 padding-left: 15px;
45 }
46 .wrapTexttop {
47 background: #1a1a1a;
48 padding: 8px 20px;
49 border-radius: 8px;
50 }
51 .form-table-str{
52 border: 0 !important;
53 }
54 .form-table{
55 border: 0 !important;
56 }
57 .form-table-str.form-table tr:nth-child(odd){
58 background: #32373c !important;
59 }
60 .form-table tr:nth-child(odd) {
61 background: #32373c !important;
62 }
63
64
65
66
67 /* 10-16-2024 - CSS Updated*/
68
69 .TextResponsesouter .wrap.TextResponses{
70 position: relative;
71 max-width: 1170px;
72 }
73 .TextResponsesouter .wrap.TextResponses:before {
74 content: '';
75 position: absolute;
76 background: url("<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/hud-left-dark.png' );?>") top left;
77 left: -6px;
78 width: 40px;
79 height: 100%;
80 z-index: 999;
81 top: 0;
82 background-repeat: repeat !important;
83 }
84 .TextResponsesouter .wrap.TextResponses:after {
85 content: '';
86 position: absolute;
87 background: url("<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/hud-righ-dark.png' );?>") top right;
88
89 width: 41px;
90 height: 100%;
91 right: -22px;
92 width: 28px;
93 z-index: 999;
94 top: 0;
95 background-repeat: repeat !important;
96 }
97 .TextResponsesouter {
98 position: relative;
99 max-width: 1190px;
100 }
101 .TextResponsesouter:before {
102 content: '';
103 position: absolute;
104 background: url(<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/hud-top-dark_new.png' );?>) top center;
105 left: 2px;
106 width: 100%;
107 height: 34px;
108 z-index: 9999999;
109 top: -7px;
110 background-repeat: no-repeat;
111 background-size: cover;
112 }
113 .card-header .wpbot_dashboard_header {
114 background: #222222;
115 }
116 .card-header .wpbot_addons_section {
117 background: #222222;
118 }
119
120 path{stroke-dasharray:300;stroke-dashoffset:300;stroke:#c3a477;stroke-width:2px;-webkit-animation:draw ease-out infinite;animation:draw ease-out infinite}
121 #l1{-webkit-animation-duration:3s;animation-duration:3s}
122 #l2{-webkit-animation-duration:5.5s;animation-duration:5.5s}
123 #l3{-webkit-animation-duration:2s;animation-duration:2s}
124 #l4{-webkit-animation-duration:5.5s;animation-duration:5.5s}@-webkit-keyframes draw{50%{stroke-dashoffset:0}100%{stroke-dashoffset:-300}}@keyframes draw{50%{stroke-dashoffset:0}100%{stroke-dashoffset:-300}}
125 .lineanimation{position:absolute;top:-64px;z-index:99999999;left:-10px;right:0;margin:0 auto;width:257px;max-width:257px;height:90px;overflow:hidden;bottom:0}
126 .lineanimation svg{width:250px;height:95px}.lineanimation svg{width:250px;height:150px;overflow:hidden}.lineanimation path{stroke:#5e5e5e}
127
128
129 .TextResponsesouter .TextResponses {
130 background: #222222;
131 }
132
133 .TextResponsesouter {
134 max-width: 1230px;
135 }
136 .TextResponsesouter .form-table-str.form-table tr:nth-child(odd) {
137 background: #222222 !important;
138 }
139
140 .wrapTexttop {
141 margin: 20px 0 0 0;
142 }
143 .form-table-str.form-table tr:nth-child(odd) {
144 background: #32373c !important;
145 }
146
147 .wp-chatbot-wrap .form-table td {
148 color: #fff;
149 }
150
151
152
153
154
155
156
157
158
159 /* 10-23-2024 - CSS Updated*/
160
161 .qcwrap.TextResponses{
162 position: relative;
163 max-width: 1170px;
164 }
165 .qcwrap.TextResponses:before {
166 content: '';
167 position: absolute;
168 background: url("<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/hud-left-dark.png' );?>") top left;
169 left: -6px;
170 width: 40px;
171 height: 100%;
172 z-index: 999;
173 top: 0;
174 background-repeat: repeat !important;
175 }
176 .qcwrap.TextResponses:after {
177 content: '';
178 position: absolute;
179 background: url("<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/hud-righ-dark.png' );?>") top right;
180
181 width: 41px;
182 height: 100%;
183 right: -22px;
184 width: 28px;
185 z-index: 999;
186 top: 0;
187 background-repeat: repeat !important;
188 }
189 .TextResponsesoutside {
190 position: relative;
191 max-width: 1190px;
192 }
193 .TextResponsesoutside:before {
194 content: '';
195 position: absolute;
196 background: url(<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/hud-top-dark_new.png' );?>) top center;
197 left: 2px;
198 width: 100%;
199 height: 34px;
200 z-index: 9999999;
201 top: -7px;
202 background-repeat: no-repeat;
203 background-size: cover;
204 }
205 .card-header .wpbot_dashboard_header {
206 background: #222222;
207 }
208 .card-header .wpbot_addons_section {
209 background: #222222;
210 }
211
212 path{stroke-dasharray:300;stroke-dashoffset:300;stroke:#c3a477;stroke-width:2px;-webkit-animation:draw ease-out infinite;animation:draw ease-out infinite}
213 #l1{-webkit-animation-duration:3s;animation-duration:3s}
214 #l2{-webkit-animation-duration:5.5s;animation-duration:5.5s}
215 #l3{-webkit-animation-duration:2s;animation-duration:2s}
216 #l4{-webkit-animation-duration:5.5s;animation-duration:5.5s}@-webkit-keyframes draw{50%{stroke-dashoffset:0}100%{stroke-dashoffset:-300}}@keyframes draw{50%{stroke-dashoffset:0}100%{stroke-dashoffset:-300}}
217 .lineanimation{position:absolute;top:-64px;z-index:99999999;left:-10px;right:0;margin:0 auto;width:257px;max-width:257px;height:90px;overflow:hidden;bottom:0}
218 .lineanimation svg{width:250px;height:95px}.lineanimation svg{width:250px;height:150px;overflow:hidden}.lineanimation path{stroke:#5e5e5e}
219
220
221
222 .TextResponsesoutside .wpbot_dashboard_header {
223 background: #222222;
224 }
225 .TextResponsesoutside .wpbot_addons_section {
226 background: #222222;
227 }
228 .TextResponsesoutside .wpbot_single_addon_wrapper2 {
229 background: #222222 !important;
230 }
231 .TextResponsesoutside .form-table-str.form-table tr:nth-child(odd) {
232 background: #222222 !important;
233 }
234
235 .TextResponsesoutside .TextResponses {
236 background: #222222;
237 }
238 </style>
239
240
241 <?php
242 if(isset($_GET['opt']) && $_GET['opt']=='add'):
243
244 do_action('qcld_str_add_category');
245
246 elseif(isset($_GET['opt']) && $_GET['opt']=='edit'):
247
248 do_action('qcld_str_edit_category');
249
250 elseif(isset($_GET['page']) && $_GET['page']=='simple-text-response' && isset($_GET['action']) && $_GET['action']=='import'):
251
252 do_action('qcld_str_import');
253
254 elseif(isset($_GET['action']) && $_GET['action']=='manage-categories'):
255
256 include_once(QCLD_wpCHATBOT_PLUGIN_DIR_PATH.'/includes/templates/manage-categories.php');
257
258 elseif(isset($_GET['action']) && $_GET['action']=='edit'):
259
260 if(class_exists('Qcld_str_pro')):
261 do_action('qcld_str_pro_stredit');
262 else:
263
264 $hasEdit = false;
265 if(isset($_GET['query']) && $_GET['query']!=''){
266 $hasEdit = true;
267 $id = sanitize_text_field($_GET['query']);
268 $table = $wpdb->prefix.'wpbot_response';
269 $data = $wpdb->get_row($wpdb->prepare("select * from $table where id = %d", $id)); //DB Call OK, No Caching OK
270
271 }
272
273
274 ?>
275
276
277
278 <div class="TextResponsesoutside">
279
280 <div class="lineanimation">
281 <svg width="350" height="350" viewBox="0 0 308 309" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
282 <defs>
283 <circle id="a" cx="150" cy="150" r="150"></circle>
284 <linearGradient x1="50%" y1="0%" x2="50%" y2="62.304%" id="c">
285 <stop stop-color="#09DFF3" offset="0%"></stop>
286 <stop stop-color="#44BEFF" offset="100%"></stop>
287 </linearGradient>
288 </defs>
289 <g>
290 <path id="l1" d="M0 130 L300 130"></path>
291 <path id="l2" d="M0 150 L300 150"></path>
292 <path id="l3" d="M0 170 L300 170"></path>
293 <path id="l4" d="M0 190 L300 190"></path>
294 </g>
295 </svg></div>
296
297
298 <div class="qcwrap TextResponses">
299
300 <div class="wp-chatbot-wrap">
301 <div class="wpbot_dashboard_header container"><h1><?php echo ($hasEdit?'Edit':'Add') ?> Response</h1></div>
302 <form method="post" action="">
303 <div class="wpbot_addons_section container">
304 <div class="wpbot_single_addon_wrapper2">
305 <p><b><?php esc_html_e('Please note the following ', 'wpbot'); ?></b></p>
306 <ul>
307 <li> <?php esc_html_e('1. The Query, Response and Keywords fields will be searched. Add Keywords for best matches', 'wpbot'); ?></li>
308 <li> <?php esc_html_e('2. Please clear browser Cache and Cookies both before testing new responses', 'wpbot'); ?></li>
309 </ul>
310 <table class="form-table-str form-table">
311 <tbody>
312 <tr valign="top">
313 <th scope="row"><?php esc_html_e('Query', 'wpbot'); ?></th>
314 <td>
315 <input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" />
316 <input type="text" name="qc_bot_str_query" value="<?php echo esc_attr($hasEdit?$data->query:''); ?>" style="width: 400px;" required />
317 <br><i><?php esc_html_e('*Required. Add the query here. ', 'wpbot'); ?></i>
318 </td>
319 </tr>
320
321 <tr valign="top">
322 <th scope="row"> <?php esc_html_e('Response', 'wpbot'); ?></th>
323 <td>
324 <?php
325
326 $content = ($hasEdit?$data->response:'');
327 $editor_id = 'qc_bot_str_response';
328 $settings = array( );
329
330 wp_editor( $content, $editor_id, $settings );
331
332 ?>
333 <br><i><?php esc_html_e('*Required. Add the response here. ', 'wpbot'); ?></i>
334 </td>
335 </tr>
336 <tr valign="top">
337 <th scope="row">Keyword</th>
338 <td>
339 <input type="text" name="qc_bot_str_keyword" value="<?php echo esc_attr($hasEdit?$data->keyword:''); ?>" style="width: 400px;" />
340 <br><i> <?php esc_html_e('Optional. Add multiple keyword or phrases as comma(,) seperated value. It will help to find the best match result.', 'wpbot'); ?></i>
341 </td>
342 </tr>
343
344
345 <?php if($hasEdit): ?>
346
347 <input type="hidden" name="qc_bot_str_id" value="<?php echo esc_attr($data->id); ?>" />
348
349 <?php endif; ?>
350
351
352 </tbody>
353 </table>
354 </div>
355
356 <footer class="wp-chatbot-admin-footer">
357 <div class="row">
358 <div class="text-left col-sm-3 col-sm-offset-3">
359
360 </div>
361 <div class="text-right col-sm-6">
362 <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings">
363 </div>
364 </div>
365 <!-- row-->
366 </footer>
367
368
369 </div></form>
370 </div>
371 </div>
372 </div>
373 <?php endif; ?>
374 <?php else: ?>
375 <h1 class="wp-heading-inline"><?php esc_html_e('Simple Text Responses', 'wpbot'); ?></h1>
376 <a href="<?php echo esc_url( add_query_arg( 'action', 'edit', admin_url('admin.php?page=simple-text-response') ) ); ?>" class="button page-title-action"><?php esc_html_e('Add New', 'wpbot'); ?></a>
377
378 <?php if(class_exists('Qcld_str_pro')): ?>
379
380 <a href="<?php echo esc_url( add_query_arg( 'action', 'manage-categories', admin_url('admin.php?page=simple-text-response') ) ); ?>" class="button page-title-action"><?php esc_html_e('Manage Categories', 'wpbot'); ?></a>
381 <a href="<?php echo esc_url( admin_url( 'admin-post.php?action=qc_str_export' ) ); ?>" class="button page-title-action"><?php esc_html_e('Export', 'wpbot'); ?></a>
382 <a href="<?php echo esc_url( add_query_arg( 'action', 'import', admin_url('admin.php?page=simple-text-response') ) ); ?>" class="button page-title-action"><?php esc_html_e('Import', 'wpbot'); ?></a>
383
384 <?php endif; ?>
385
386 <div class="TextResponsesouter">
387
388
389 <div class="lineanimation">
390 <svg width="350" height="350" viewBox="0 0 308 309" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
391 <defs>
392 <circle id="a" cx="150" cy="150" r="150"></circle>
393 <linearGradient x1="50%" y1="0%" x2="50%" y2="62.304%" id="c">
394 <stop stop-color="#09DFF3" offset="0%"></stop>
395 <stop stop-color="#44BEFF" offset="100%"></stop>
396 </linearGradient>
397 </defs>
398 <g>
399 <path id="l1" d="M0 130 L300 130"></path>
400 <path id="l2" d="M0 150 L300 150"></path>
401 <path id="l3" d="M0 170 L300 170"></path>
402 <path id="l4" d="M0 190 L300 190"></path>
403 </g>
404 </svg></div>
405
406
407 <div class="wrap TextResponses">
408
409
410
411 <div class="wrapTexttop">
412
413 <p><?php esc_html_e('Create simple text responses and the ChatBot will use advanced search algorithm to answer user questions. This is a simpler alternative to OpenAI or DialogFlow.', 'wpbot'); ?><br>
414 <b><?php esc_html_e('NB: Simple Text Responses require mySQL Client version 5.6+', 'wpbot'); ?></b></p>
415 </div>
416 <form method="post" action="">
417 <table class="form-table-str form-table">
418 <tbody>
419 <tr valign="top">
420 <th scope="row"><?php esc_html_e('Phrase matching accuracy', 'wpbot'); ?></th>
421 <td>
422 <input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" />
423 <input type="text" name="qc_bot_str_weight" value="<?php esc_attr_e((get_option('qc_bot_str_weight')!=''?get_option('qc_bot_str_weight'):'0.4')); ?>" style="width: 400px;" required />
424 <br><i><?php esc_html_e('Please enter a value between 0 to 1. Higher value means more exact matching of phrases.', 'wpbot'); ?></i>
425 </td>
426 </tr>
427 <tr valign="top">
428 <th scope="row"><?php esc_html_e('Search Fields', 'wpbot'); ?></th>
429 <td>
430 <?php
431 $fields = get_option('qc_bot_str_fields');
432 ?>
433
434 <label for="qc_bot_str_field_title"><?php esc_html_e('Title', 'wpbot'); ?></label>
435 <input id="qc_bot_str_field_title" type="checkbox" name="qc_bot_str_fields[]" value="query" <?php echo (!$fields?'checked="checked"':''); ?> <?php echo ($fields && in_array('query', $fields)?'checked="checked"':''); ?> />
436
437 <label for="qc_bot_str_field_keyword"><?php esc_html_e('Keyword', 'wpbot'); ?></label>
438 <input id="qc_bot_str_field_keyword" type="checkbox" name="qc_bot_str_fields[]" value="keyword" <?php echo (!$fields?'checked="checked"':''); ?> <?php echo ($fields && in_array('keyword', $fields)?'checked="checked"':''); ?> />
439
440 <label for="qc_bot_str_field_response"><?php esc_html_e('Response', 'wpbot'); ?></label>
441 <input id="qc_bot_str_field_response" type="checkbox" name="qc_bot_str_fields[]" value="response" <?php echo (!$fields?'checked="checked"':''); ?> <?php echo ($fields && in_array('response', $fields)?'checked="checked"':''); ?> />
442 <br><i><?php esc_html_e('Please check/uncheck to allow/disallow searching in that fields', 'wpbot'); ?></i>
443 </td>
444 </tr>
445
446 <tr valign="top">
447 <th scope="row"></th>
448 <td>
449 <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings">
450 </td>
451 </tr>
452 </tbody>
453 </table>
454 </form>
455
456 <form method="post" action="">
457 <table class="form-table-str form-table">
458 <tbody>
459 <tr valign="top">
460 <th scope="row"><?php esc_html_e('Re-Index STR Simple Text Responses', 'wpbot'); ?></th>
461 <td>
462 <input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" />
463 <input type="submit" class="button button-primary" name="qc-re-index" id="re-index" value="Re Index">
464 <br/>
465 <i><?php esc_html_e('Re-Indexing may required after migration.', 'wpbot'); ?></i>
466 </td>
467 </tr>
468 </tbody>
469 </table>
470 </form>
471 <div id="poststuff">
472 <div id="post-body" class="metabox-holder">
473 <div id="post-body-content-edit" class="str-form">
474 <div class="meta-box-sortables ui-sortable">
475 <form method="post">
476
477 <a href="<?php echo esc_url( add_query_arg( 'action', 'edit', admin_url('admin.php?page=simple-text-response') ) ); ?>" class="button page-title-action str-addnew"><?php esc_html_e('Add New', 'wpbot'); ?></a>
478 <?php
479 $this->response_list->prepare_items();
480 $this->response_list->display(); ?>
481 </form>
482 </div>
483 </div>
484 </div>
485
486 </div>
487 </div>
488 </div>
489 <?php endif; ?>
490 <script type="text/javascript">
491 // var stopcheckBox = document.getElementById("qc_bot_str_remove_stopwords");
492 // stopcheckBox.addEventListener('change', function () {
493 // if (stopcheckBox.checked == true){
494 // stopcheckBox.value = "1";
495
496 // } else {
497 // stopcheckBox.value = "0";
498 // }
499 // });
500
501 // var small_talk = document.getElementById('small_talk');
502 // small_talk.addEventListener( 'click', () => { small_talk_import(); } );
503 // function small_talk_import(){
504 // var req = new XMLHttpRequest();
505 // req.open('POST', ajaxurl, true);
506 // req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
507 // var s = 'action=small_talk_import';
508 // req.send(s);
509 // if(req.DONE == 4){
510 // alert('Smalltalk is imported');
511 // setTimeout(function(){
512 // window.location.reload();
513 // }, 3000);
514 // }
515 // }
516
517 </script>
518
519
520 <style>
521
522
523 .TextResponses{
524 background: #32373c;
525 padding: 20px 20px;
526 border-radius: 6px;
527 width: 100%;
528 max-width: 1220px;
529 }
530 .TextResponses p{
531 color:#fff;
532 }
533 .TextResponses i{
534 color:#fff;
535 }
536 .TextResponses h1{
537 color:#fff;
538 }
539 .TextResponses .form-table th, .TextResponses .form-wrap label {
540 color:#fff;
541 }
542 .qcwrap {
543 margin: 20px 0 0 0;
544 }
545 .TextResponses label {
546 color: #fff;
547 }
548 .tablenav-pages .current-page {
549 display: inline-block;
550 vertical-align: baseline;
551 min-width: 30px;
552 min-height: 31px;
553 margin: 0 0 0 0;
554 padding: 0 4px;
555 font-size: 13px;
556 line-height: 1.5;
557 text-align: center;
558 }
559 .tablenav-pages .current-page {
560 border: 1px solid
561 }
562 div#poststuff {
563 color: #fff;
564 }
565 .str-form{
566 position: relative;
567 }
568 .str-addnew{
569 position: absolute !important;
570 left: 50%;
571 }
572 .qcbot-str-top-notic {
573 max-width: 1240px;
574 padding: 0 !important;
575 margin: 20px 0 0 0;
576 }
577 body .qcbot-str-top-notic {
578 max-width: initial !important;
579 padding: 0 !important;
580 margin: 20px 20px 20px 0 !important;
581 padding: 15px 15px 15px 0 !important;
582 border: none !important;
583 border-radius: 6px !important;
584 box-shadow: 0px 4px 6px 1px #ebebeb !important;
585 }
586 div#promotion-wpchatbot {
587 max-width: inherit;
588 margin-left: 0;
589 border: none;
590 margin: 12px 20px 20px 0;
591 }
592 div#promotion-wpchatbot a{
593 display: block;
594 }
595
596 .str-addnew {
597 position: absolute !important;
598 left: 15% !important;
599 top: 5px !important;
600 }
601 </style>