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

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