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

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