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

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