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

351 lines 11.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 <style>
8 .wpbot_dashboard_header {
9 margin-right: unset !important;
10 margin-left: unset !important;
11 background: #32373c;
12 color: #fff;
13 text-align: center;
14 border-radius: 5px 5px 0px 0px;
15 }
16 .wpbot_addons_section {
17 margin-right: unset !important;
18 margin-left: unset !important;
19 margin-bottom: 10px;
20 background: #32373c;
21 padding-bottom: 20px;
22 border-radius: 0px 0px 5px 5px;
23 }
24 .wpbot_single_addon_wrapper2 {
25 background: #fff;
26 padding: 20px;
27 }
28 .wp-chatbot-admin-header, .wp-chatbot-admin-footer {
29 padding: 25px;
30 }
31 .wpbot_dashboard_header h1 {
32 font-size: 30px;
33 line-height: 100px;
34 margin: 0px;
35 color: #fff;
36 }
37 .container {
38 width: 1170px;
39 padding-right: 15px;
40 padding-left: 15px;
41 }
42 .wrapTexttop {
43 background: #464b50;
44 padding: 8px 20px;
45 }
46 .form-table-str{
47 border: 0 !important;
48 }
49 .form-table{
50 border: 0 !important;
51 }
52 .form-table-str.form-table tr:nth-child(odd){
53 background: #32373c !important;
54 }
55 .form-table tr:nth-child(odd) {
56 background: #32373c !important;
57 }
58 </style>
59
60
61 <?php
62 if(isset($_GET['opt']) && $_GET['opt']=='add'):
63
64 do_action('qcld_str_add_category');
65
66 elseif(isset($_GET['opt']) && $_GET['opt']=='edit'):
67
68 do_action('qcld_str_edit_category');
69
70 elseif(isset($_GET['page']) && $_GET['page']=='simple-text-response' && isset($_GET['action']) && $_GET['action']=='import'):
71
72 do_action('qcld_str_import');
73
74 elseif(isset($_GET['action']) && $_GET['action']=='manage-categories'):
75
76 include_once(QCLD_wpCHATBOT_PLUGIN_DIR_PATH.'/includes/templates/manage-categories.php');
77
78 elseif(isset($_GET['action']) && $_GET['action']=='edit'):
79
80 if(class_exists('Qcld_str_pro')):
81 do_action('qcld_str_pro_stredit');
82 else:
83
84 $hasEdit = false;
85 if(isset($_GET['query']) && $_GET['query']!=''){
86 $hasEdit = true;
87 $id = sanitize_text_field($_GET['query']);
88 $table = $wpdb->prefix.'wpbot_response';
89 $data = $wpdb->get_row($wpdb->prepare("select * from $table where id = %d", $id)); //DB Call OK, No Caching OK
90
91 }
92
93
94 ?>
95 <div class="qcwrap">
96 <div class="wp-chatbot-wrap">
97 <div class="wpbot_dashboard_header container"><h1><?php echo ($hasEdit?'Edit':'Add') ?> Response</h1></div>
98 <form method="post" action="">
99 <div class="wpbot_addons_section container">
100 <div class="wpbot_single_addon_wrapper2">
101 <p><b><?php esc_html_e('Please note the following ', 'wpbot'); ?></b></p>
102 <ul>
103 <li> <?php esc_html_e('1. The Query, Response and Keywords fields will be searched. Add Keywords for best matches', 'wpbot'); ?></li>
104 <li> <?php esc_html_e('2. Please clear browser Cache and Cookies both before testing new responses', 'wpbot'); ?></li>
105 </ul>
106 <table class="form-table-str form-table">
107 <tbody>
108 <tr valign="top">
109 <th scope="row"><?php esc_html_e('Query', 'wpbot'); ?></th>
110 <td>
111 <input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" />
112 <input type="text" name="qc_bot_str_query" value="<?php echo esc_attr($hasEdit?$data->query:''); ?>" style="width: 400px;" required />
113 <br><i><?php esc_html_e('*Required. Add the query here. ', 'wpbot'); ?></i>
114 </td>
115 </tr>
116
117 <tr valign="top">
118 <th scope="row"> <?php esc_html_e('Response', 'wpbot'); ?></th>
119 <td>
120 <?php
121
122 $content = ($hasEdit?$data->response:'');
123 $editor_id = 'qc_bot_str_response';
124 $settings = array( );
125
126 wp_editor( $content, $editor_id, $settings );
127
128 ?>
129 <br><i><?php esc_html_e('*Required. Add the response here. ', 'wpbot'); ?></i>
130 </td>
131 </tr>
132 <tr valign="top">
133 <th scope="row">Keyword</th>
134 <td>
135 <input type="text" name="qc_bot_str_keyword" value="<?php echo esc_attr($hasEdit?$data->keyword:''); ?>" style="width: 400px;" />
136 <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>
137 </td>
138 </tr>
139
140 <tr valign="top">
141 <th scope="row"><?php esc_html_e('Intent', 'wpbot'); ?></th>
142 <td>
143 <input type="text" name="qc_bot_str_intent" value="<?php echo esc_attr($hasEdit?$data->intent:''); ?>" style="width: 400px;" />
144 <br><i> <?php esc_html_e('Optional. Single keyword or Phrase. Leave it empty if you do not need to use this response as a intent. This will add as a custom intent in every intent selection field in wpbot settings. Also the intent can be used as system command to trigger the response.', 'wpbot'); ?></i>
145 <?php if($hasEdit): ?>
146
147 <input type="hidden" name="qc_bot_str_id" value="<?php echo esc_attr($data->id); ?>" />
148
149 <?php endif; ?>
150 </td>
151 </tr>
152
153
154 </tbody>
155 </table>
156 </div>
157
158 <footer class="wp-chatbot-admin-footer">
159 <div class="row">
160 <div class="text-left col-sm-3 col-sm-offset-3">
161
162 </div>
163 <div class="text-right col-sm-6">
164 <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings">
165 </div>
166 </div>
167 <!-- row-->
168 </footer>
169
170
171 </div></form>
172 </div>
173 </div>
174 <?php endif; ?>
175 <?php else: ?>
176 <h1 class="wp-heading-inline"><?php esc_html_e('Simple Text Responses', 'wpbot'); ?></h1>
177 <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>
178
179 <?php if(class_exists('Qcld_str_pro')): ?>
180
181 <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>
182 <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>
183 <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>
184
185 <?php endif; ?>
186
187
188 <div class="wrap TextResponses">
189
190 <div class="wrapTexttop">
191
192 <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'); ?></p>
193 <p><b><?php esc_html_e('NB: Simple Text Responses require mySQL Client version 5.6+', 'wpbot'); ?></b></p>
194 </div>
195 <form method="post" action="">
196 <table class="form-table-str form-table">
197 <tbody>
198 <tr valign="top">
199 <th scope="row"><?php esc_html_e('Phrase matching accuracy', 'wpbot'); ?></th>
200 <td>
201 <input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" />
202 <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: 400px;" required />
203 <br><i><?php esc_html_e('Please enter a value between 0 to 1. Higher value means more exact matching of phrases.', 'wpbot'); ?></i>
204 </td>
205 </tr>
206 <tr valign="top">
207 <th scope="row"><?php esc_html_e('Search Fields', 'wpbot'); ?></th>
208 <td>
209 <?php
210 $fields = get_option('qc_bot_str_fields');
211 ?>
212
213 <label for="qc_bot_str_field_title"><?php esc_html_e('Title', 'wpbot'); ?></label>
214 <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"':''); ?> />
215
216 <label for="qc_bot_str_field_keyword"><?php esc_html_e('Keyword', 'wpbot'); ?></label>
217 <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"':''); ?> />
218
219 <label for="qc_bot_str_field_response"><?php esc_html_e('Response', 'wpbot'); ?></label>
220 <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"':''); ?> />
221 <br><i><?php esc_html_e('Please check/uncheck to allow/disallow searching in that fields', 'wpbot'); ?></i>
222 </td>
223 </tr>
224
225 <tr valign="top">
226 <th scope="row"></th>
227 <td>
228 <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings">
229 </td>
230 </tr>
231 </tbody>
232 </table>
233 </form>
234
235 <form method="post" action="">
236 <table class="form-table-str form-table">
237 <tbody>
238 <tr valign="top">
239 <th scope="row"><?php esc_html_e('Re-Index STR Simple Text Responses', 'wpbot'); ?></th>
240 <td>
241 <input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" />
242 <input type="submit" class="button button-primary" name="qc-re-index" id="re-index" value="Re Index">
243 <br/>
244 <i><?php esc_html_e('Re-Indexing may required after migration.', 'wpbot'); ?></i>
245 </td>
246 </tr>
247 </tbody>
248 </table>
249 </form>
250 <div id="poststuff">
251 <div id="post-body" class="metabox-holder">
252 <div id="post-body-content-edit" class="str-form">
253 <div class="meta-box-sortables ui-sortable">
254 <form method="post">
255
256 <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>
257 <?php
258 $this->response_list->prepare_items();
259 $this->response_list->display(); ?>
260 </form>
261 </div>
262 </div>
263 </div>
264
265 </div>
266 </div>
267
268 <?php endif; ?>
269 <script type="text/javascript">
270 // var stopcheckBox = document.getElementById("qc_bot_str_remove_stopwords");
271 // stopcheckBox.addEventListener('change', function () {
272 // if (stopcheckBox.checked == true){
273 // stopcheckBox.value = "1";
274
275 // } else {
276 // stopcheckBox.value = "0";
277 // }
278 // });
279
280 // var small_talk = document.getElementById('small_talk');
281 // small_talk.addEventListener( 'click', () => { small_talk_import(); } );
282 // function small_talk_import(){
283 // var req = new XMLHttpRequest();
284 // req.open('POST', ajaxurl, true);
285 // req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
286 // var s = 'action=small_talk_import';
287 // req.send(s);
288 // if(req.DONE == 4){
289 // alert('Smalltalk is imported');
290 // setTimeout(function(){
291 // window.location.reload();
292 // }, 3000);
293 // }
294 // }
295
296 </script>
297
298
299 <style>
300
301
302 .TextResponses{
303 background: #32373c;
304 padding: 20px 20px;
305 border-radius: 6px;
306 width: 100%;
307 max-width: 1220px;
308 }
309 .TextResponses p{
310 color:#fff;
311 }
312 .TextResponses i{
313 color:#fff;
314 }
315 .TextResponses h1{
316 color:#fff;
317 }
318 .TextResponses .form-table th, .TextResponses .form-wrap label {
319 color:#fff;
320 }
321 .qcwrap {
322 margin: 20px 0 0 0;
323 }
324 .TextResponses label {
325 color: #fff;
326 }
327 .tablenav-pages .current-page {
328 display: inline-block;
329 vertical-align: baseline;
330 min-width: 30px;
331 min-height: 31px;
332 margin: 0 0 0 0;
333 padding: 0 4px;
334 font-size: 13px;
335 line-height: 1.5;
336 text-align: center;
337 }
338 .tablenav-pages .current-page {
339 border: 1px solid
340 }
341 div#poststuff {
342 color: #fff;
343 }
344 .str-form{
345 position: relative;
346 }
347 .str-addnew{
348 position: absolute !important;
349 left: 50%;
350 }
351 </style>