PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 7.8.9
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v7.8.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 7.8.9, at includes/simple_text_response.php

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