PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 7.4.1
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v7.4.1
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.4.1, 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 ', '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
189 <tr valign="top">
190 <th scope="row"></th>
191 <td>
192 <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings">
193 </td>
194 </tr>
195 </tbody>
196 </table>
197 </form>
198 <form method="post" action="">
199 <table class="form-table-str form-table">
200 <tbody>
201 <tr valign="top">
202 <th scope="row"><?php esc_html_e('Re-Index STR', 'chatbot'); ?></th>
203 <td>
204 <input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" />
205 <input type="submit" class="button button-primary" name="qc-re-index" id="re-index" value="Re Index">
206
207 <i><?php esc_html_e('Re-Index if results are not as expected.', 'chatbot'); ?></i>
208 </td>
209 </tr>
210 </tbody>
211 </table>
212 </form>
213
214
215
216 </div>
217 <div class="qcld-show-more-show-more"><i class="fa fa-plus-circle" aria-hidden="true"></i></div>
218 </div>
219
220 <div id="poststuff">
221 <div id="post-body" class="metabox-holder">
222 <div id="post-body-content-edit" class="str-form">
223 <div class="meta-box-sortables ui-sortable">
224 <form method="post">
225
226 <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>
227 <?php
228 $this->response_list->prepare_items();
229 $this->response_list->display(); ?>
230 </form>
231 </div>
232 </div>
233 </div>
234
235 </div>
236 </div>
237 </div>
238 <?php endif; ?>
239
240
241 <style>
242 body {
243 background-color: #F5F7FD;
244 font-family: "DM Sans", sans-serif !important;
245 font-optical-sizing: auto;
246 font-size: 16px;
247 font-weight: normal;
248 }
249 .qcld-wp-chatbot-wrap-header {
250 display: flex;
251 column-gap: 15px;
252 row-gap: 10px;
253 background: #fff;
254 padding: 15px 15px;
255 margin: 20px 20px 20px 0;
256 border-radius: 16px;
257 align-items: center;
258 justify-content: space-between;
259 width: 97%;
260 }
261
262 .qcld-wp-chatbot-wrap-header img{
263 max-width: 50px;
264 }
265
266 .qcld-wp-chatbot-wrap-header ul, .qcld-wp-chatbot-wrap-header p, .qcld-wp-chatbot-wrap-header li{
267 margin: 0;
268 }
269 .qcld-wp-chatbot-wrap-header a.wpchatbot-Upgrade {
270 padding: 12px 25px;
271 background: #ffffff;
272 color: #5B4E96;
273 border: 2px solid #5B4E96;
274 border-radius: 6px;
275 font-weight: bold;
276 }
277
278 .qcld-wp-chatbot-wrap-header a.wpchatbot-Upgrade:hover {
279 padding: 12px 25px;
280 background: #5B4E96;
281 color: #fff;
282 border: 2px solid #5B4E96;
283 border-radius: 6px;
284 font-weight: bold;
285 text-decoration: none;
286 }
287 a.qcld-wp-chatbot-wrap-site__logo {
288 font-size: 22px;
289 color: #000;
290 font-weight: bold;
291 display: flex;
292 align-items: center;
293 gap: 12px;
294 text-decoration: none;
295 margin: 0;
296 padding: 0;
297 }
298
299 a{
300 text-decoration: none;
301 }
302 .qcld-wp-chatbot-wrap-header_inn {
303 background: #fff;
304 border-radius: 16px;
305 margin: 0 20px 0 0;
306 padding: 20px;
307 }
308 .TextResponsesoutside {
309 background: #fff;
310 border-radius: 16px;
311 margin: 0 20px 0 0;
312 padding: 20px;
313 }
314
315
316 .qcld-wp-chatbot-wrap-header_inn h1.wp-heading-inline {
317 border-bottom: 1px solid #eee;
318 padding: 0 0 15px 0;
319 margin: 20px 0 12px 0;
320 font-weight: bold;
321 font-size: 22px !important;
322 }
323
324 .TextResponsesoutside h1 {
325 border-bottom: 1px solid #eee;
326 padding: 0 0 8px 0;
327 margin: 20px 0 12px 0;
328 font-weight: bold;
329 font-size: 22px !important;
330 }
331 .TextResponsesoutside ul li {
332 font-size: 14px;
333 }
334 .wpbot_single_addon_wrapper2 p {
335 font-size: 16px;
336 }
337 .TextResponsesouter i {
338 font-weight: normal;
339 font-size: 12px;
340 color: red;
341 }
342 .TextResponsesoutside i {
343 font-weight: normal;
344 font-size: 12px;
345 color: red;
346 }
347
348 table.form-table-str.form-table tr {
349 background: #fff;
350 padding: 2px 10px !important;
351 border-radius: 6px;
352 margin: 0 0 8px 0;
353 border: 5px solid #fff;
354 vertical-align: middle;
355 border: 1px solid #eee;
356 }
357 table.form-table-str.form-table {
358 border: 1px solid #eee;
359 }
360 table.form-table-str.form-table tr {
361 border: none;
362 }
363 table.form-table-str.form-table th {
364 vertical-align: top;
365 text-align: center;
366 padding: 20px 10px 20px 0;
367 width: 200px;
368 line-height: 1.3;
369 font-weight: 600;
370 vertical-align: middle;
371 }
372
373 .TextResponsesoutside footer.wp-chatbot-admin-footer input#submit {
374 padding: 12px 20px;
375 width: 100%;
376 font-size: 16px;
377 font-weight: 500;
378 color: #988FBD;
379 border-radius: 8px;
380 position: relative;
381 display: flex;
382 align-items: center;
383 gap: 15px;
384 background: #5B4E96;
385 color: #ffffff;
386 text-decoration: none;
387 border: none;
388 max-width: 220px;
389 margin: 12px 0 0 0;
390 line-height: 24px;
391 }
392 .qcld-wp-chatbot-wrap-header_inn a.button.page-title-action {
393 padding: 3px 25px;
394 background: #ffffff;
395 color: #5B4E96;
396 border: 2px solid #5B4E96;
397 border-radius: 6px;
398 font-weight: bold;
399 }
400
401 .qcld-wp-chatbot-wrap-header_inn a.button.page-title-action:hover {
402 padding: 0px 15px;
403 background: #5B4E96;
404 color: #fff;
405 border: 2px solid #5B4E96;
406 border-radius: 6px;
407 font-weight: bold;
408 position: absolute;
409 top: 36px;
410 left: 280px;
411 }
412 .qcld-wp-chatbot-wrap-header_inn a.button.page-title-action {
413 padding: 0px 15px;
414 background: #ffffff;
415 color: #5B4E96;
416 border: 2px solid #5B4E96;
417 border-radius: 6px;
418 font-weight: bold;
419 position: absolute;
420 top: 36px;
421 left: 280px;
422 }
423
424 .qcld-wp-chatbot-wrap-header_inn {
425 position: relative;
426 }
427 .notice.is-dismissible.qcbot-str-top-notic {
428 width: 96%;
429 }
430
431 .TextResponsesouter i {
432 position: relative;
433 top: 6px;
434 }
435
436 table.form-table-str.form-table th {
437 text-align: left !important;
438 padding: 20px 10px 20px 20px !important;
439 }
440
441 .qc-review-text img {
442 width: 100%;
443 }
444
445 .TextResponsesouter input#submit {
446 padding: 0px 15px;
447 background: #ffffff;
448 color: #5B4E96;
449 border: 2px solid #5B4E96;
450 border-radius: 6px;
451 font-weight: bold;
452 }
453 .TextResponsesouter input#re-index {
454 padding: 0px 15px;
455 background: #ffffff;
456 color: #5B4E96;
457 border: 2px solid #5B4E96;
458 border-radius: 6px;
459 font-weight: bold;
460 }
461
462
463 #qcld-show-more-wrapper-box {
464 margin-top: 0;
465 position:relative;
466 }
467 #qcld-show-more-wrapper-box .qcld-show-more-text {
468 /* width: 660px; */
469 margin-bottom: 5px;
470 padding: 0 0;
471 position:relative;
472 display: block;
473 }
474 #qcld-show-more-wrapper-box .qcld-show-more-show-more {
475 color: #ffffff;
476 position: relative;
477 padding: 40px 0 0 0;
478 height: 40px;
479 text-align: center;
480 background: #f1f1f1;
481 cursor: pointer;
482 background: linear-gradient(to bottom, rgb(255 255 255 / 53%) 0%, rgb(188 174 255) 100%);
483 margin: -18px 0 0 0;
484 border-radius: 0 0 15px 15px;
485 z-index: 99999;
486 font-weight: bold;
487
488 }
489
490 #qcld-show-more-wrapper-box .qcld-show-more-show-more-height {
491 height: 112px;
492 overflow:hidden;
493 }
494
495 #qcld-show-more-wrapper-box .qcld-show-more-show-more i {
496 display: block;
497 padding: 0 0 0 0;
498 background: #5b4e96;
499 width: 30px;
500 height: 30px;
501 line-height: 30px;
502 border-radius: 50%;
503 margin: -15px auto 0 auto;
504 font-size: 18px !important;
505 color: #fff;
506 }
507 .TextResponsesouter input#submit:hover {
508 background: #5B4E96;
509 color: #fff;
510 border: 2px solid #5B4E96;
511 }
512
513 .TextResponsesouter input#re-index:hover {
514 background: #5B4E96;
515 color: #fff;
516 border: 2px solid #5B4E96;
517 }
518
519 </style>
520
521 <script type="text/javascript">
522 jQuery(".qcld-show-more-show-more").click(function () {
523 if(jQuery(".qcld-show-more-text").hasClass("qcld-show-more-show-more-height")) {
524 jQuery(this).html('<i class="fa fa-minus-circle" aria-hidden="true"></i>');
525 } else {
526 jQuery(this).html('<i class="fa fa-plus-circle" aria-hidden="true"></i>');
527 }
528
529 jQuery(".qcld-show-more-text").toggleClass("qcld-show-more-show-more-height");
530 });
531
532
533 </script>