PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 4.8.9
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v4.8.9
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 8.5.2 All 533 releases
chatbot / includes / simple_text_response.php

simple_text_response.php in WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services 4.8.9, at includes/simple_text_response.php

307 lines 11.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 <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 </style>
47
48
49 <?php
50 if(isset($_GET['opt']) && $_GET['opt']=='add'):
51
52 do_action('qcld_str_add_category');
53
54 elseif(isset($_GET['opt']) && $_GET['opt']=='edit'):
55
56 do_action('qcld_str_edit_category');
57
58 elseif(isset($_GET['page']) && $_GET['page']=='simple-text-response' && isset($_GET['action']) && $_GET['action']=='import'):
59
60 do_action('qcld_str_import');
61
62 elseif(isset($_GET['action']) && $_GET['action']=='manage-categories'):
63
64 include_once(QCLD_wpCHATBOT_PLUGIN_DIR_PATH.'/includes/templates/manage-categories.php');
65
66 elseif(isset($_GET['action']) && $_GET['action']=='edit'):
67
68 if(class_exists('Qcld_str_pro')):
69 do_action('qcld_str_pro_stredit');
70 else:
71
72 $hasEdit = false;
73 if(isset($_GET['query']) && $_GET['query']!=''){
74 $hasEdit = true;
75 $id = sanitize_text_field($_GET['query']);
76 $table = $wpdb->prefix.'wpbot_response';
77 $data = $wpdb->get_row("select * from $table where 1 and id = '".$id."'");
78
79 }
80
81
82 ?>
83 <div class="qcwrap">
84 <div class="wp-chatbot-wrap">
85 <div class="wpbot_dashboard_header container"><h1><?php echo ($hasEdit?'Edit':'Add') ?> Response</h1></div>
86 <form method="post" action="">
87 <div class="wpbot_addons_section container">
88 <div class="wpbot_single_addon_wrapper2">
89 <p><b><?php esc_html_e('Please note the following ', 'wpbot'); ?></b></p>
90 <ul>
91 <li> <?php esc_html_e('1. The Query, Response and Keywords fields will be searched. Add Keywords for best matches', 'wpbot'); ?></li>
92 <li> <?php esc_html_e('2. Please clear browser Cache and Cookies both before testing new responses', 'wpbot'); ?></li>
93 </ul>
94 <table class="form-table">
95 <tbody>
96 <tr valign="top">
97 <th scope="row"><?php esc_html_e('Query', 'wpbot'); ?></th>
98 <td>
99 <input name="str_nonce" type="hidden" value="<?=wp_create_nonce('str-nonce')?>" />
100 <input type="text" name="qc_bot_str_query" value="<?php echo esc_attr($hasEdit?$data->query:''); ?>" style="width: 400px;" required />
101 <br><i><?php esc_html_e('*Required. Add the query here. ', 'wpbot'); ?></i>
102 </td>
103 </tr>
104
105 <tr valign="top">
106 <th scope="row"> <?php esc_html_e('Response', 'wpbot'); ?></th>
107 <td>
108 <textarea id="qlcd_wp_chatbot_stop_words" cols="130" rows="10" name="qc_bot_str_response" required><?php echo ($hasEdit?$data->response:''); ?></textarea>
109 <br><i><?php esc_html_e('*Required. Add the response here. ', 'wpbot'); ?></i>
110 </td>
111 </tr>
112 <tr valign="top">
113 <th scope="row">Keyword</th>
114 <td>
115 <input type="text" name="qc_bot_str_keyword" value="<?php echo esc_attr($hasEdit?$data->keyword:''); ?>" style="width: 400px;" />
116 <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>
117 </td>
118 </tr>
119
120 <tr valign="top">
121 <th scope="row"><?php esc_html_e('Intent', 'wpbot'); ?></th>
122 <td>
123 <input type="text" name="qc_bot_str_intent" value="<?php echo esc_attr($hasEdit?$data->intent:''); ?>" style="width: 400px;" />
124 <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>
125 <?php if($hasEdit): ?>
126
127 <input type="hidden" name="qc_bot_str_id" value="<?php echo esc_attr($data->id); ?>" />
128
129 <?php endif; ?>
130 </td>
131 </tr>
132
133
134 </tbody>
135 </table>
136 </div>
137
138 <footer class="wp-chatbot-admin-footer">
139 <div class="row">
140 <div class="text-left col-sm-3 col-sm-offset-3">
141
142 </div>
143 <div class="text-right col-sm-6">
144 <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings">
145 </div>
146 </div>
147 <!-- row-->
148 </footer>
149
150
151 </div></form>
152 </div>
153 </div>
154 <?php endif; ?>
155 <?php else: ?>
156 <h1 class="wp-heading-inline"><?php esc_html_e('Simple Text Responses', 'wpbot'); ?></h1>
157 <a href="<?php echo 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>
158
159 <?php if(class_exists('Qcld_str_pro')): ?>
160
161 <a href="<?php echo 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>
162 <a href="<?php echo admin_url( 'admin-post.php?action=qc_str_export' ); ?>" class="button page-title-action"><?php esc_html_e('Export', 'wpbot'); ?></a>
163 <a href="<?php echo 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>
164
165 <?php endif; ?>
166
167
168 <div class="wrap TextResponses">
169
170 <div class="wrapTexttop">
171
172 <p><?php esc_html_e('Create simple text responses and the ChatBot will use advanced search algorithm for natural language phrase matching with user input.', 'wpbot'); ?></p>
173 <p><b><?php esc_html_e('This is a new feature. If you have any feedback to improve this feature or found a bug please report us ', 'wpbot'); ?> <a href="https://www.wpbot.pro/free-support/" target="_blank"><?php esc_html_e('here', 'wpbot'); ?></a>.</b></p>
174 <p><b><?php esc_html_e('NB: Simple Text Responses require mySQL Client version 5.6+', 'wpbot'); ?></b></p>
175 </div>
176 <form method="post" action="">
177 <table class="form-table">
178 <tbody>
179 <tr valign="top">
180 <th scope="row"><?php esc_html_e('Phrase matching accuracy', 'wpbot'); ?></th>
181 <td>
182 <input name="str_nonce" type="hidden" value="<?=wp_create_nonce('str-nonce')?>" />
183 <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 />
184 <br><i><?php esc_html_e('Please enter a value between 0 to 1. Higher value means more exact matching of phrases.', 'wpbot'); ?></i>
185 </td>
186 </tr>
187 <tr valign="top">
188 <th scope="row"><?php esc_html_e('Search Fields', 'wpbot'); ?></th>
189 <td>
190 <?php
191 $fields = get_option('qc_bot_str_fields');
192 ?>
193
194 <label for="qc_bot_str_field_title"><?php esc_html_e('Title', 'wpbot'); ?></label>
195 <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"':''); ?> />
196
197 <label for="qc_bot_str_field_keyword"><?php esc_html_e('Keyword', 'wpbot'); ?></label>
198 <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"':''); ?> />
199
200 <label for="qc_bot_str_field_response"><?php esc_html_e('Response', 'wpbot'); ?></label>
201 <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"':''); ?> />
202 <br><i><?php esc_html_e('Please check/uncheck to allow/disallow searching in that fields', 'wpbot'); ?></i>
203 </td>
204 </tr>
205
206 <tr valign="top">
207 <th scope="row"></th>
208 <td>
209 <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings">
210 </td>
211 </tr>
212 </tbody>
213 </table>
214 </form>
215
216 <form method="post" action="">
217 <table class="form-table">
218 <tbody>
219 <tr valign="top">
220 <th scope="row"><?php esc_html_e('Re-Index STR Simple Text Responses', 'wpbot'); ?></th>
221 <td>
222 <input name="str_nonce" type="hidden" value="<?=wp_create_nonce('str-nonce')?>" />
223 <input type="submit" class="button button-primary" name="qc-re-index" id="re-index" value="Re Index">
224 <br/>
225 <i><?php esc_html_e('Re-Indexing may required after migration.', 'wpbot'); ?></i>
226 </td>
227 </tr>
228 </tbody>
229 </table>
230 </form>
231
232 <div id="poststuff">
233 <div id="post-body" class="metabox-holder">
234 <div id="post-body-content-edit">
235 <div class="meta-box-sortables ui-sortable">
236 <form method="post">
237 <?php
238 $this->response_list->prepare_items();
239 $this->response_list->display(); ?>
240 </form>
241 </div>
242 </div>
243 </div>
244
245 </div>
246 </div>
247
248 <?php endif; ?>
249 <script type="text/javascript">
250 // var stopcheckBox = document.getElementById("qc_bot_str_remove_stopwords");
251 // stopcheckBox.addEventListener('change', function () {
252 // if (stopcheckBox.checked == true){
253 // stopcheckBox.value = "1";
254
255 // } else {
256 // stopcheckBox.value = "0";
257 // }
258 // });
259
260 // var small_talk = document.getElementById('small_talk');
261 // small_talk.addEventListener( 'click', () => { small_talk_import(); } );
262 // function small_talk_import(){
263 // var req = new XMLHttpRequest();
264 // req.open('POST', ajaxurl, true);
265 // req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
266 // var s = 'action=small_talk_import';
267 // req.send(s);
268 // if(req.DONE == 4){
269 // alert('Smalltalk is imported');
270 // setTimeout(function(){
271 // window.location.reload();
272 // }, 3000);
273 // }
274 // }
275
276 </script>
277
278
279 <style>
280
281
282 .TextResponses{
283 background: #32373c;
284 padding: 20px 20px;
285 border-radius: 6px;
286 width: 100%;
287 max-width: 1220px;
288 }
289 .TextResponses p{
290 color:#fff;
291 }
292 .TextResponses i{
293 color:#fff;
294 }
295 .TextResponses h1{
296 color:#fff;
297 }
298 .TextResponses .form-table th, .TextResponses .form-wrap label {
299 color:#fff;
300 }
301 .qcwrap {
302 margin: 20px 0 0 0;
303 }
304 .TextResponses label {
305 color: #fff;
306 }
307 </style>