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

530 lines 16.5 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 }
297
298 a{
299 text-decoration: none;
300 }
301 .qcld-wp-chatbot-wrap-header_inn {
302 background: #fff;
303 border-radius: 16px;
304 margin: 0 20px 0 0;
305 padding: 20px;
306 }
307 .TextResponsesoutside {
308 background: #fff;
309 border-radius: 16px;
310 margin: 0 20px 0 0;
311 padding: 20px;
312 }
313
314
315 .qcld-wp-chatbot-wrap-header_inn h1.wp-heading-inline {
316 border-bottom: 1px solid #eee;
317 padding: 0 0 15px 0;
318 margin: 20px 0 12px 0;
319 font-weight: bold;
320 font-size: 22px !important;
321 }
322
323 .TextResponsesoutside h1 {
324 border-bottom: 1px solid #eee;
325 padding: 0 0 8px 0;
326 margin: 20px 0 12px 0;
327 font-weight: bold;
328 font-size: 22px !important;
329 }
330 .TextResponsesoutside ul li {
331 font-size: 14px;
332 }
333 .wpbot_single_addon_wrapper2 p {
334 font-size: 16px;
335 }
336 .TextResponsesouter i {
337 font-weight: normal;
338 font-size: 12px;
339 color: red;
340 }
341 .TextResponsesoutside i {
342 font-weight: normal;
343 font-size: 12px;
344 color: red;
345 }
346
347 table.form-table-str.form-table tr {
348 background: #fff;
349 padding: 2px 10px !important;
350 border-radius: 6px;
351 margin: 0 0 8px 0;
352 border: 5px solid #fff;
353 vertical-align: middle;
354 border: 1px solid #eee;
355 }
356 table.form-table-str.form-table {
357 border: 1px solid #eee;
358 }
359 table.form-table-str.form-table tr {
360 border: none;
361 }
362 table.form-table-str.form-table th {
363 vertical-align: top;
364 text-align: center;
365 padding: 20px 10px 20px 0;
366 width: 200px;
367 line-height: 1.3;
368 font-weight: 600;
369 vertical-align: middle;
370 }
371
372 .TextResponsesoutside footer.wp-chatbot-admin-footer input#submit {
373 padding: 12px 20px;
374 width: 100%;
375 font-size: 16px;
376 font-weight: 500;
377 color: #988FBD;
378 border-radius: 8px;
379 position: relative;
380 display: flex;
381 align-items: center;
382 gap: 15px;
383 background: #5B4E96;
384 color: #ffffff;
385 text-decoration: none;
386 border: none;
387 max-width: 220px;
388 margin: 12px 0 0 0;
389 line-height: 24px;
390 }
391 .qcld-wp-chatbot-wrap-header_inn a.button.page-title-action {
392 padding: 3px 25px;
393 background: #ffffff;
394 color: #5B4E96;
395 border: 2px solid #5B4E96;
396 border-radius: 6px;
397 font-weight: bold;
398 }
399
400 .qcld-wp-chatbot-wrap-header_inn a.button.page-title-action:hover {
401 padding: 0px 15px;
402 background: #5B4E96;
403 color: #fff;
404 border: 2px solid #5B4E96;
405 border-radius: 6px;
406 font-weight: bold;
407 position: absolute;
408 top: 36px;
409 left: 280px;
410 }
411 .qcld-wp-chatbot-wrap-header_inn a.button.page-title-action {
412 padding: 0px 15px;
413 background: #ffffff;
414 color: #5B4E96;
415 border: 2px solid #5B4E96;
416 border-radius: 6px;
417 font-weight: bold;
418 position: absolute;
419 top: 36px;
420 left: 280px;
421 }
422
423 .qcld-wp-chatbot-wrap-header_inn {
424 position: relative;
425 }
426 .notice.is-dismissible.qcbot-str-top-notic {
427 width: 96%;
428 }
429
430 .TextResponsesouter i {
431 position: relative;
432 top: 6px;
433 }
434
435 table.form-table-str.form-table th {
436 text-align: left !important;
437 padding: 20px 10px 20px 20px !important;
438 }
439
440 .qc-review-text img {
441 width: 100%;
442 }
443
444 .TextResponsesouter input#submit {
445 padding: 0px 15px;
446 background: #ffffff;
447 color: #5B4E96;
448 border: 2px solid #5B4E96;
449 border-radius: 6px;
450 font-weight: bold;
451 }
452 .TextResponsesouter input#re-index {
453 padding: 0px 15px;
454 background: #ffffff;
455 color: #5B4E96;
456 border: 2px solid #5B4E96;
457 border-radius: 6px;
458 font-weight: bold;
459 }
460
461
462 #qcld-show-more-wrapper-box {
463 margin-top: 0;
464 position:relative;
465 }
466 #qcld-show-more-wrapper-box .qcld-show-more-text {
467 /* width: 660px; */
468 margin-bottom: 5px;
469 padding: 0 0;
470 position:relative;
471 display: block;
472 }
473 #qcld-show-more-wrapper-box .qcld-show-more-show-more {
474 color: #ffffff;
475 position: relative;
476 padding: 40px 0 0 0;
477 height: 40px;
478 text-align: center;
479 background: #f1f1f1;
480 cursor: pointer;
481 background: linear-gradient(to bottom, rgb(255 255 255 / 53%) 0%, rgb(188 174 255) 100%);
482 margin: -18px 0 0 0;
483 border-radius: 0 0 15px 15px;
484 z-index: 99999;
485 font-weight: bold;
486
487 }
488
489 #qcld-show-more-wrapper-box .qcld-show-more-show-more-height {
490 height: 112px;
491 overflow:hidden;
492 }
493
494 #qcld-show-more-wrapper-box .qcld-show-more-show-more i {
495 display: block;
496 padding: 0 0 0 0;
497 background: #5b4e96;
498 width: 30px;
499 height: 30px;
500 line-height: 30px;
501 border-radius: 50%;
502 margin: -15px auto 0 auto;
503 font-size: 18px !important;
504 color: #fff;
505 }
506 .TextResponsesouter input#submit:hover {
507 background: #5B4E96;
508 color: #fff;
509 border: 2px solid #5B4E96;
510 }
511
512 .TextResponsesouter input#re-index:hover {
513 background: #5B4E96;
514 color: #fff;
515 border: 2px solid #5B4E96;
516 }
517
518 </style>
519
520 <script type="text/javascript">
521 jQuery(".qcld-show-more-show-more").click(function () {
522 if(jQuery(".qcld-show-more-text").hasClass("qcld-show-more-show-more-height")) {
523 jQuery(this).html('<i class="fa fa-minus-circle" aria-hidden="true"></i>');
524 } else {
525 jQuery(this).html('<i class="fa fa-plus-circle" aria-hidden="true"></i>');
526 }
527
528 jQuery(".qcld-show-more-text").toggleClass("qcld-show-more-show-more-height");
529 });
530 </script>