PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 6.6.0
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v6.6.0
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 8.5.2 8.5.0 All 532 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.0, at includes/simple_text_response.php

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