PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, AI Services / 8.2.5
WPBot – AI ChatBot for Live Support, Lead Generation, AI Services v8.2.5
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 8.4.9 All 531 releases
chatbot / includes / simple_text_response.php

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

562 lines 17.3 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
8 <?php
9 if(isset($_GET['opt']) && $_GET['opt']=='add'):
10
11 do_action('qcld_str_add_category');
12
13 elseif(isset($_GET['opt']) && $_GET['opt']=='edit'):
14
15 do_action('qcld_str_edit_category');
16
17 elseif(isset($_GET['page']) && $_GET['page']=='simple-text-response' && isset($_GET['action']) && $_GET['action']=='import'):
18
19 do_action('qcld_str_import');
20
21 elseif(isset($_GET['action']) && wp_unslash($_GET['action'])=='manage-categories'):
22
23 include_once(QCLD_wpCHATBOT_PLUGIN_DIR_PATH.'/includes/templates/manage-categories.php');
24
25 elseif(isset($_GET['action']) && wp_unslash($_GET['action'])=='edit'):
26
27 if(class_exists('Qcld_str_pro')):
28 do_action('qcld_str_pro_stredit');
29 else:
30
31 $hasEdit = false;
32 if(isset($_GET['query']) && wp_unslash($_GET['query'])!=''){
33 $hasEdit = true;
34 $id = sanitize_text_field(wp_unslash($_GET['query']));
35 $table = $wpdb->prefix.'wpbot_response';
36 $data = $wpdb->get_row($wpdb->prepare("select * from $table where id = %d", $id)); //DB Call OK, No Caching OK
37 }
38 ?>
39 <div class="qcld-wp-chatbot-wrap-header">
40
41 <div class="qcld-wp-chatbot-wrap-header-logo"><a href="#" class="qcld-wp-chatbot-wrap-site__logo"><img style="width:100%" src="<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/chatbot.png' ); ?>" alt="Dialogflow CX"> WPBot Control Panel </a>
42 <p><strong>Core Version:</strong> v<?php echo QCLD_wpCHATBOT_VERSION; ?></p>
43 </div>
44 <ul class="qcld-wp-chatbot-wrap-version-wrapper">
45 <li>
46 <a class="wpchatbot-Upgrade" href="https://www.wpbot.pro/" target="_blank">Upgrade To Pro</a>
47
48 </li>
49 </ul>
50 </div>
51 <div class="TextResponsesoutside">
52 <div class="qcwrap TextResponses">
53 <div class="wp-chatbot-wrap">
54 <div class="wpbot_dashboard_header "><h1><?php echo ($hasEdit?'Edit':'Add') ?> Response</h1></div>
55 <form method="post" action="">
56 <div class="wpbot_addons_section ">
57 <div class="wpbot_single_addon_wrapper2">
58 <p><b><?php esc_html_e('Please note the following ', 'chatbot'); ?></b></p>
59 <ul>
60 <li> <?php esc_html_e('1. The Query, Response and Keywords fields will be searched. Add Keywords for best matches', 'chatbot'); ?></li>
61 <li> <?php esc_html_e('2. Please clear browser Cache and Cookies both before testing new responses', 'chatbot'); ?></li>
62 </ul>
63 <table class="form-table-str form-table">
64 <tbody>
65 <tr valign="top">
66 <th scope="row"><?php esc_html_e('Query', 'chatbot'); ?></th>
67 <td>
68 <input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" />
69 <input type="text" name="qc_bot_str_query" value="<?php echo esc_attr($hasEdit?$data->query:''); ?>" style="width: 100%;" required />
70 <br><i><?php esc_html_e('*Required. Add the query here. ', 'chatbot'); ?></i>
71 </td>
72 </tr>
73
74 <tr valign="top">
75 <th scope="row"> <?php esc_html_e('Response', 'chatbot'); ?></th>
76 <td>
77 <?php
78
79 $content = ($hasEdit?$data->response:'');
80 $editor_id = 'qc_bot_str_response';
81 $settings = array( );
82
83 wp_editor( $content, $editor_id, $settings );
84
85 ?>
86 <br><i><?php esc_html_e('*Required. Add the response here. ', 'chatbot'); ?></i>
87 </td>
88 </tr>
89 <tr valign="top">
90 <th scope="row">Keyword</th>
91 <td>
92 <input type="text" name="qc_bot_str_keyword" value="<?php echo esc_attr($hasEdit?$data->keyword:''); ?>" style="width: 100%;" />
93 <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.', 'chatbot'); ?></i>
94 </td>
95 </tr>
96
97
98 <?php if($hasEdit): ?>
99
100 <input type="hidden" name="qc_bot_str_id" value="<?php echo esc_attr($data->id); ?>" />
101
102 <?php endif; ?>
103 </tbody>
104 </table>
105 </div>
106 <footer class="wp-chatbot-admin-footer">
107 <div class="row">
108 <div class="text-left col-sm-3 col-sm-offset-3">
109
110 </div>
111 <div class="text-right col-sm-6">
112 <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings">
113 </div>
114 </div>
115 <!-- row-->
116 </footer>
117 </div></form>
118 </div>
119 </div>
120 </div>
121 <?php endif; ?>
122
123
124 <?php else: ?>
125
126 <div class="qcld-wp-chatbot-wrap-header">
127
128 <a href="#" class="qcld-wp-chatbot-wrap-site__logo"><img style="width:100%" src="<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/chatbot.png' ); ?>" alt="Dialogflow CX"> WPBot Control Panel </a>
129 <p><strong>Core Version:</strong> v<?php echo QCLD_wpCHATBOT_VERSION; ?></p>
130 <ul class="qcld-wp-chatbot-wrap-version-wrapper">
131 <li>
132 <a class="wpchatbot-Upgrade" href="https://www.wpbot.pro/" target="_blank">Upgrade To Pro</a>
133
134 </li>
135 </ul>
136 </div>
137
138 <div class="qcld-wp-chatbot-wrap-header_inn">
139 <div class="qcld-wp-chatbot-wrap-header_inn_heading">
140 <h1 class="wp-heading-inline"><?php esc_html_e('Simple Text Responses', 'chatbot'); ?></h1>
141 <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', 'chatbot'); ?></a>
142 </div>
143 <?php if(class_exists('Qcld_str_pro')): ?>
144
145 <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', 'chatbot'); ?></a>
146 <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', 'chatbot'); ?></a>
147 <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', 'chatbot'); ?></a>
148 </div>
149 <?php endif; ?>
150 <div class="TextResponsesouter">
151 <div class="wrap TextResponses">
152
153 <div id="qcld-show-more-wrapper-box">
154 <div class="qcld-show-more-text qcld-show-more-show-more-height">
155
156 <div class="wrapTexttop">
157 <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.', 'chatbot'); ?><br>
158 <b><?php esc_html_e('NB: Simple Text Responses require mySQL Client version 5.6+', 'chatbot'); ?></b></p>
159 </div>
160 <form method="post" action="">
161 <table class="form-table-str form-table">
162 <tbody>
163 <tr valign="top">
164 <th scope="row"><?php esc_html_e('Phrase matching accuracy', 'chatbot'); ?></th>
165 <td>
166 <input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" />
167 <input type="text" name="qc_bot_str_weight" value="<?php echo esc_attr( !empty(get_option('qc_bot_str_weight')) ? get_option('qc_bot_str_weight') : '0.4' ); ?>" style="width: 100%;" required />
168 <br><i><?php esc_html_e('Please enter a value between 0 to 1. Higher value means more exact matching of phrases.', 'chatbot'); ?></i>
169 </td>
170 </tr>
171 <tr valign="top">
172 <th scope="row"><?php esc_html_e('Search Fields', 'chatbot'); ?></th>
173 <td>
174 <?php
175 $fields = get_option('qc_bot_str_fields');
176 ?>
177
178 <label for="qc_bot_str_field_title"><?php esc_html_e('Title', 'chatbot'); ?></label>
179 <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"':''); ?> />
180
181 <label for="qc_bot_str_field_keyword"><?php esc_html_e('Keyword', 'chatbot'); ?></label>
182 <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"':''); ?> />
183
184 <label for="qc_bot_str_field_response"><?php esc_html_e('Response', 'chatbot'); ?></label>
185 <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"':''); ?> />
186 <br><i><?php esc_html_e('Please check/uncheck to allow/disallow searching in that fields', 'chatbot'); ?></i>
187 </td>
188 </tr>
189 <?php
190 $current_user = wp_get_current_user();
191 if ( in_array( 'administrator', $current_user->roles )) {
192 ?>
193 <tr valign="top">
194 <th scope="row"><?php echo esc_html( 'Allow Author & Editor to edit STR' ); ?></th>
195 <td>
196 <input id="qc_bot_str_allow_author_editor" type="checkbox" name="qc_bot_str_allow_author_editor" value="1" <?php echo ( get_option( 'qc_bot_str_allow_author_editor' ) && get_option( 'qc_bot_str_allow_author_editor' ) == 1 ? 'checked="checked"' : '' ); ?> />
197 <label for="qc_bot_str_allow_author_editor"><?php echo esc_html( 'Allow Author & Editor to edit STR' ); ?></label>
198 <br><i><?php echo esc_html( 'Please enable to allow Author & Editor to edit STR.' ); ?></i>
199 </td>
200 </tr>
201 <?php } ?>
202 <tr valign="top">
203 <th scope="row"></th>
204 <td>
205 <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings">
206 </td>
207 </tr>
208 </tbody>
209 </table>
210 </form>
211 <form method="post" action="">
212 <table class="form-table-str form-table">
213 <tbody>
214 <tr valign="top">
215 <th scope="row"><?php esc_html_e('Re-Index STR', 'chatbot'); ?></th>
216 <td>
217 <input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" />
218 <input type="submit" class="button button-primary" name="qc-re-index" id="re-index" value="Re Index">
219
220 <i><?php esc_html_e('Re-Index if results are not as expected.', 'chatbot'); ?></i>
221 </td>
222 </tr>
223 </tbody>
224 </table>
225 </form>
226
227
228
229 </div>
230 <div class="qcld-show-more-show-more"><i class="dashicons dashicons-plus-alt" aria-hidden="true"></i></div>
231 </div>
232
233 <div id="poststuff">
234 <div id="post-body" class="metabox-holder">
235 <div id="post-body-content-edit" class="str-form">
236 <div class="meta-box-sortables ui-sortable">
237 <form method="post">
238
239 <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', 'chatbot'); ?></a>
240 <?php
241 $this->response_list->prepare_items();
242 $this->response_list->display(); ?>
243 </form>
244 </div>
245 </div>
246 </div>
247
248 </div>
249 </div>
250 </div>
251 <?php endif; ?>
252
253
254
255 <style>
256 body {
257 background-color: #F5F7FD;
258 font-family: "DM Sans", sans-serif !important;
259 font-optical-sizing: auto;
260 font-size: 16px;
261 font-weight: normal;
262 }
263 .qcld-wp-chatbot-wrap-header {
264 display: flex;
265 column-gap: 15px;
266 row-gap: 10px;
267 background: #fff;
268 padding: 15px 15px;
269 margin: 20px 20px 20px 0;
270 border-radius: 16px;
271 align-items: center;
272 justify-content: space-between;
273 width: 97%;
274 }
275
276 .qcld-wp-chatbot-wrap-header img{
277 max-width: 50px;
278 }
279
280 .qcld-wp-chatbot-wrap-header ul, .qcld-wp-chatbot-wrap-header p, .qcld-wp-chatbot-wrap-header li{
281 margin: 0;
282 }
283 .qcld-wp-chatbot-wrap-header a.wpchatbot-Upgrade {
284 padding: 12px 25px;
285 background: #ffffff;
286 color: #5B4E96;
287 border: 2px solid #5B4E96;
288 border-radius: 6px;
289 font-weight: bold;
290 }
291
292 .qcld-wp-chatbot-wrap-header a.wpchatbot-Upgrade:hover {
293 padding: 12px 25px;
294 background: #5B4E96;
295 color: #fff;
296 border: 2px solid #5B4E96;
297 border-radius: 6px;
298 font-weight: bold;
299 text-decoration: none;
300 }
301 a.qcld-wp-chatbot-wrap-site__logo {
302 font-size: 22px;
303 color: #000;
304 font-weight: bold;
305 display: flex;
306 align-items: center;
307 gap: 12px;
308 text-decoration: none;
309 margin: 0;
310 padding: 0;
311 }
312
313 a{
314 text-decoration: none;
315 }
316 .qcld-wp-chatbot-wrap-header_inn {
317 background: #fff;
318 border-radius: 16px;
319 margin: 0 20px 0 0;
320 padding: 20px;
321 }
322 .TextResponsesoutside {
323 background: #fff;
324 border-radius: 16px;
325 margin: 0 20px 0 0;
326 padding: 20px;
327 }
328
329
330 .qcld-wp-chatbot-wrap-header_inn h1.wp-heading-inline {
331 border-bottom: 1px solid #eee;
332 padding: 0 0 15px 0;
333 margin: 20px 0 12px 0;
334 font-weight: bold;
335 font-size: 22px !important;
336 }
337
338 .TextResponsesoutside h1 {
339 border-bottom: 1px solid #eee;
340 padding: 0 0 8px 0;
341 margin: 20px 0 12px 0;
342 font-weight: bold;
343 font-size: 22px !important;
344 }
345 .TextResponsesoutside ul li {
346 font-size: 14px;
347 }
348 .wpbot_single_addon_wrapper2 p {
349 font-size: 16px;
350 }
351 .TextResponsesouter i {
352 font-weight: normal;
353 font-size: 12px;
354 color: red;
355 }
356 .TextResponsesoutside i {
357 font-weight: normal;
358 font-size: 12px;
359 color: red;
360 }
361
362 table.form-table-str.form-table tr {
363 background: #fff;
364 padding: 2px 10px !important;
365 border-radius: 6px;
366 margin: 0 0 8px 0;
367 border: 5px solid #fff;
368 vertical-align: middle;
369 border: 1px solid #eee;
370 }
371 table.form-table-str.form-table {
372 border: 1px solid #eee;
373 }
374 table.form-table-str.form-table tr {
375 border: none;
376 }
377 table.form-table-str.form-table th {
378 vertical-align: top;
379 text-align: center;
380 padding: 20px 10px 20px 0;
381 width: 200px;
382 line-height: 1.3;
383 font-weight: 600;
384 vertical-align: middle;
385 }
386
387 .TextResponsesoutside footer.wp-chatbot-admin-footer input#submit {
388 padding: 12px 20px;
389 width: 100%;
390 font-size: 16px;
391 font-weight: 500;
392 color: #988FBD;
393 border-radius: 8px;
394 position: relative;
395 display: flex;
396 align-items: center;
397 gap: 15px;
398 background: #5B4E96;
399 color: #ffffff;
400 text-decoration: none;
401 border: none;
402 max-width: 220px;
403 margin: 12px 0 0 0;
404 line-height: 24px;
405 }
406 .qcld-wp-chatbot-wrap-header_inn a.button.page-title-action {
407 padding: 3px 25px;
408 background: #ffffff;
409 color: #5B4E96;
410 border: 2px solid #5B4E96;
411 border-radius: 6px;
412 font-weight: bold;
413 }
414
415 .qcld-wp-chatbot-wrap-header_inn a.button.page-title-action:hover {
416 padding: 0px 15px;
417 background: #5B4E96;
418 color: #fff;
419 border: 2px solid #5B4E96;
420 border-radius: 6px;
421 font-weight: bold;
422 position: absolute;
423 top: 36px;
424 left: 280px;
425 }
426 .qcld-wp-chatbot-wrap-header_inn a.button.page-title-action {
427 padding: 0px 15px;
428 background: #ffffff;
429 color: #5B4E96;
430 border: 2px solid #5B4E96;
431 border-radius: 6px;
432 font-weight: bold;
433 position: absolute;
434 top: 36px;
435 left: 280px;
436 }
437
438 .qcld-wp-chatbot-wrap-header_inn {
439 position: relative;
440 }
441 .notice.is-dismissible.qcbot-str-top-notic {
442 width: 96%;
443 }
444
445 .TextResponsesouter i {
446 position: relative;
447 top: 6px;
448 }
449
450 table.form-table-str.form-table th {
451 text-align: left !important;
452 padding: 20px 10px 20px 20px !important;
453 }
454
455 .qc-review-text img {
456 width: 100%;
457 }
458
459 .TextResponsesouter input#submit {
460 padding: 0px 15px;
461 background: #ffffff;
462 color: #5B4E96;
463 border: 2px solid #5B4E96;
464 border-radius: 6px;
465 font-weight: bold;
466 }
467 .TextResponsesouter input#re-index {
468 padding: 0px 15px;
469 background: #ffffff;
470 color: #5B4E96;
471 border: 2px solid #5B4E96;
472 border-radius: 6px;
473 font-weight: bold;
474 }
475
476
477 #qcld-show-more-wrapper-box {
478 margin-top: 0;
479 position:relative;
480 }
481 #qcld-show-more-wrapper-box .qcld-show-more-text {
482 /* width: 660px; */
483 margin-bottom: 5px;
484 padding: 0 0;
485 position:relative;
486 display: block;
487 }
488 #qcld-show-more-wrapper-box .qcld-show-more-show-more {
489 color: #ffffff;
490 position: relative;
491 padding: 40px 0 0 0;
492 height: 40px;
493 text-align: center;
494 background: #f1f1f1;
495 cursor: pointer;
496 background: linear-gradient(to bottom, rgb(255 255 255 / 53%) 0%, rgb(188 174 255) 100%);
497 margin: -18px 0 0 0;
498 border-radius: 0 0 15px 15px;
499 z-index: 99999;
500 font-weight: bold;
501
502 }
503
504 #qcld-show-more-wrapper-box .qcld-show-more-show-more-height {
505 height: 112px;
506 overflow:hidden;
507 }
508
509 #qcld-show-more-wrapper-box .qcld-show-more-show-more i {
510 display: block;
511 padding: 0 0 0 0;
512 background: #5b4e96;
513 width: 30px;
514 height: 30px;
515 line-height: 30px;
516 border-radius: 50%;
517 margin: -15px auto 0 auto;
518 font-size: 18px !important;
519 color: #fff;
520 }
521 .TextResponsesouter input#submit:hover {
522 background: #5B4E96;
523 color: #fff;
524 border: 2px solid #5B4E96;
525 }
526
527 .TextResponsesouter input#re-index:hover {
528 background: #5B4E96;
529 color: #fff;
530 border: 2px solid #5B4E96;
531 }
532 .TextResponsesouter table.widefat {
533 border: 1px solid #ebebeb;
534 }
535 .TextResponsesouter .tablenav {
536 padding: 8px;
537 background: #5B4E96;
538 }
539 .TextResponsesouter span.displaying-num {
540 color: #fff;
541 }
542
543 .qcld-wp-chatbot-wrap-header-logo {
544 display: flex;
545 align-items: center;
546 gap: 10px;
547 }
548 </style>
549
550 <script type="text/javascript">
551 jQuery(".qcld-show-more-show-more").click(function () {
552 if(jQuery(".qcld-show-more-text").hasClass("qcld-show-more-show-more-height")) {
553 jQuery(this).html('<i class="dashicons dashicons-remove" aria-hidden="true"></i>');
554 } else {
555 jQuery(this).html('<i class="dashicons dashicons-plus-alt" aria-hidden="true"></i>');
556 }
557
558 jQuery(".qcld-show-more-text").toggleClass("qcld-show-more-show-more-height");
559 });
560
561
562 </script>