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

463 lines 13.7 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 }
282
283 .qcld-wp-chatbot-wrap-header img{
284 max-width: 50px;
285 }
286
287 .qcld-wp-chatbot-wrap-header ul, .qcld-wp-chatbot-wrap-header p, .qcld-wp-chatbot-wrap-header li{
288 margin: 0;
289 }
290 .qcld-wp-chatbot-wrap-header a.wpchatbot-Upgrade {
291 padding: 12px 25px;
292 background: #ffffff;
293 color: #5B4E96;
294 border: 2px solid #5B4E96;
295 border-radius: 6px;
296 font-weight: bold;
297 }
298
299 .qcld-wp-chatbot-wrap-header a.wpchatbot-Upgrade:hover {
300 padding: 12px 25px;
301 background: #5B4E96;
302 color: #fff;
303 border: 2px solid #5B4E96;
304 border-radius: 6px;
305 font-weight: bold;
306 text-decoration: none;
307 }
308 a.qcld-wp-chatbot-wrap-site__logo {
309 font-size: 22px;
310 color: #000;
311 font-weight: bold;
312 display: flex;
313 align-items: center;
314 gap: 12px;
315 text-decoration: none;
316 margin: 0;
317 padding: 0;
318 }
319
320 a{
321 text-decoration: none;
322 }
323 .qcld-wp-chatbot-wrap-header_inn {
324 background: #fff;
325 border-radius: 16px;
326 margin: 0 20px 0 0;
327 padding: 20px;
328 }
329 .TextResponsesoutside {
330 background: #fff;
331 border-radius: 16px;
332 margin: 0 20px 0 0;
333 padding: 20px;
334 }
335
336
337 .qcld-wp-chatbot-wrap-header_inn h1.wp-heading-inline {
338 border-bottom: 1px solid #eee;
339 padding: 0 0 15px 0;
340 margin: 20px 0 12px 0;
341 font-weight: bold;
342 font-size: 22px !important;
343 }
344
345 .TextResponsesoutside h1 {
346 border-bottom: 1px solid #eee;
347 padding: 0 0 8px 0;
348 margin: 20px 0 12px 0;
349 font-weight: bold;
350 font-size: 22px !important;
351 }
352 .TextResponsesoutside ul li {
353 font-size: 14px;
354 }
355 .wpbot_single_addon_wrapper2 p {
356 font-size: 16px;
357 }
358 .TextResponsesouter i {
359 font-weight: normal;
360 font-size: 12px;
361 color: red;
362 }
363 .TextResponsesoutside i {
364 font-weight: normal;
365 font-size: 12px;
366 color: red;
367 }
368
369 table.form-table-str.form-table tr {
370 background: #fff;
371 padding: 2px 10px !important;
372 border-radius: 6px;
373 margin: 0 0 8px 0;
374 border: 5px solid #fff;
375 vertical-align: middle;
376 border: 1px solid #eee;
377 }
378 table.form-table-str.form-table {
379 border: 1px solid #eee;
380 }
381 table.form-table-str.form-table tr {
382 border: none;
383 }
384 table.form-table-str.form-table th {
385 vertical-align: top;
386 text-align: center;
387 padding: 20px 10px 20px 0;
388 width: 200px;
389 line-height: 1.3;
390 font-weight: 600;
391 vertical-align: middle;
392 }
393
394 .TextResponsesoutside footer.wp-chatbot-admin-footer input#submit {
395 padding: 12px 20px;
396 width: 100%;
397 font-size: 16px;
398 font-weight: 500;
399 color: #988FBD;
400 border-radius: 8px;
401 position: relative;
402 display: flex;
403 align-items: center;
404 gap: 15px;
405 background: #5B4E96;
406 color: #ffffff;
407 text-decoration: none;
408 border: none;
409 max-width: 220px;
410 margin: 12px 0 0 0;
411 line-height: 24px;
412 }
413 .qcld-wp-chatbot-wrap-header_inn a.button.page-title-action {
414 padding: 3px 25px;
415 background: #ffffff;
416 color: #5B4E96;
417 border: 2px solid #5B4E96;
418 border-radius: 6px;
419 font-weight: bold;
420 }
421
422 .qcld-wp-chatbot-wrap-header_inn a.button.page-title-action:hover {
423 padding: 0px 15px;
424 background: #5B4E96;
425 color: #fff;
426 border: 2px solid #5B4E96;
427 border-radius: 6px;
428 font-weight: bold;
429 position: absolute;
430 top: 36px;
431 left: 280px;
432 }
433 .qcld-wp-chatbot-wrap-header_inn a.button.page-title-action {
434 padding: 0px 15px;
435 background: #ffffff;
436 color: #5B4E96;
437 border: 2px solid #5B4E96;
438 border-radius: 6px;
439 font-weight: bold;
440 position: absolute;
441 top: 36px;
442 left: 280px;
443 }
444
445 .qcld-wp-chatbot-wrap-header_inn {
446 position: relative;
447 }
448 .notice.is-dismissible.qcbot-str-top-notic {
449 width: 96%;
450 }
451
452 .TextResponsesouter i {
453 position: relative;
454 top: 6px;
455 }
456
457 table.form-table-str.form-table th {
458 text-align: left !important;
459 padding: 20px 10px 20px 20px !important;
460 }
461
462
463 </style>