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

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