PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, AI Services / 5.0.2
WPBot – AI ChatBot for Live Support, Lead Generation, AI Services v5.0.2
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 8.5.0 8.4.9 All 531 releases
chatbot / includes / simple_text_response.php

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

315 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 <?php
109
110 $content = ($hasEdit?$data->response:'');
111 $editor_id = 'qc_bot_str_response';
112 $settings = array( );
113
114 wp_editor( $content, $editor_id, $settings );
115
116 ?>
117 <br><i><?php esc_html_e('*Required. Add the response here. ', 'wpbot'); ?></i>
118 </td>
119 </tr>
120 <tr valign="top">
121 <th scope="row">Keyword</th>
122 <td>
123 <input type="text" name="qc_bot_str_keyword" value="<?php echo esc_attr($hasEdit?$data->keyword:''); ?>" style="width: 400px;" />
124 <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>
125 </td>
126 </tr>
127
128 <tr valign="top">
129 <th scope="row"><?php esc_html_e('Intent', 'wpbot'); ?></th>
130 <td>
131 <input type="text" name="qc_bot_str_intent" value="<?php echo esc_attr($hasEdit?$data->intent:''); ?>" style="width: 400px;" />
132 <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>
133 <?php if($hasEdit): ?>
134
135 <input type="hidden" name="qc_bot_str_id" value="<?php echo esc_attr($data->id); ?>" />
136
137 <?php endif; ?>
138 </td>
139 </tr>
140
141
142 </tbody>
143 </table>
144 </div>
145
146 <footer class="wp-chatbot-admin-footer">
147 <div class="row">
148 <div class="text-left col-sm-3 col-sm-offset-3">
149
150 </div>
151 <div class="text-right col-sm-6">
152 <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings">
153 </div>
154 </div>
155 <!-- row-->
156 </footer>
157
158
159 </div></form>
160 </div>
161 </div>
162 <?php endif; ?>
163 <?php else: ?>
164 <h1 class="wp-heading-inline"><?php esc_html_e('Simple Text Responses', 'wpbot'); ?></h1>
165 <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>
166
167 <?php if(class_exists('Qcld_str_pro')): ?>
168
169 <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>
170 <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>
171 <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>
172
173 <?php endif; ?>
174
175
176 <div class="wrap TextResponses">
177
178 <div class="wrapTexttop">
179
180 <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>
181 <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>
182 <p><b><?php esc_html_e('NB: Simple Text Responses require mySQL Client version 5.6+', 'wpbot'); ?></b></p>
183 </div>
184 <form method="post" action="">
185 <table class="form-table">
186 <tbody>
187 <tr valign="top">
188 <th scope="row"><?php esc_html_e('Phrase matching accuracy', 'wpbot'); ?></th>
189 <td>
190 <input name="str_nonce" type="hidden" value="<?=wp_create_nonce('str-nonce')?>" />
191 <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 />
192 <br><i><?php esc_html_e('Please enter a value between 0 to 1. Higher value means more exact matching of phrases.', 'wpbot'); ?></i>
193 </td>
194 </tr>
195 <tr valign="top">
196 <th scope="row"><?php esc_html_e('Search Fields', 'wpbot'); ?></th>
197 <td>
198 <?php
199 $fields = get_option('qc_bot_str_fields');
200 ?>
201
202 <label for="qc_bot_str_field_title"><?php esc_html_e('Title', 'wpbot'); ?></label>
203 <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"':''); ?> />
204
205 <label for="qc_bot_str_field_keyword"><?php esc_html_e('Keyword', 'wpbot'); ?></label>
206 <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"':''); ?> />
207
208 <label for="qc_bot_str_field_response"><?php esc_html_e('Response', 'wpbot'); ?></label>
209 <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"':''); ?> />
210 <br><i><?php esc_html_e('Please check/uncheck to allow/disallow searching in that fields', 'wpbot'); ?></i>
211 </td>
212 </tr>
213
214 <tr valign="top">
215 <th scope="row"></th>
216 <td>
217 <input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings">
218 </td>
219 </tr>
220 </tbody>
221 </table>
222 </form>
223
224 <form method="post" action="">
225 <table class="form-table">
226 <tbody>
227 <tr valign="top">
228 <th scope="row"><?php esc_html_e('Re-Index STR Simple Text Responses', 'wpbot'); ?></th>
229 <td>
230 <input name="str_nonce" type="hidden" value="<?=wp_create_nonce('str-nonce')?>" />
231 <input type="submit" class="button button-primary" name="qc-re-index" id="re-index" value="Re Index">
232 <br/>
233 <i><?php esc_html_e('Re-Indexing may required after migration.', 'wpbot'); ?></i>
234 </td>
235 </tr>
236 </tbody>
237 </table>
238 </form>
239
240 <div id="poststuff">
241 <div id="post-body" class="metabox-holder">
242 <div id="post-body-content-edit">
243 <div class="meta-box-sortables ui-sortable">
244 <form method="post">
245 <?php
246 $this->response_list->prepare_items();
247 $this->response_list->display(); ?>
248 </form>
249 </div>
250 </div>
251 </div>
252
253 </div>
254 </div>
255
256 <?php endif; ?>
257 <script type="text/javascript">
258 // var stopcheckBox = document.getElementById("qc_bot_str_remove_stopwords");
259 // stopcheckBox.addEventListener('change', function () {
260 // if (stopcheckBox.checked == true){
261 // stopcheckBox.value = "1";
262
263 // } else {
264 // stopcheckBox.value = "0";
265 // }
266 // });
267
268 // var small_talk = document.getElementById('small_talk');
269 // small_talk.addEventListener( 'click', () => { small_talk_import(); } );
270 // function small_talk_import(){
271 // var req = new XMLHttpRequest();
272 // req.open('POST', ajaxurl, true);
273 // req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
274 // var s = 'action=small_talk_import';
275 // req.send(s);
276 // if(req.DONE == 4){
277 // alert('Smalltalk is imported');
278 // setTimeout(function(){
279 // window.location.reload();
280 // }, 3000);
281 // }
282 // }
283
284 </script>
285
286
287 <style>
288
289
290 .TextResponses{
291 background: #32373c;
292 padding: 20px 20px;
293 border-radius: 6px;
294 width: 100%;
295 max-width: 1220px;
296 }
297 .TextResponses p{
298 color:#fff;
299 }
300 .TextResponses i{
301 color:#fff;
302 }
303 .TextResponses h1{
304 color:#fff;
305 }
306 .TextResponses .form-table th, .TextResponses .form-wrap label {
307 color:#fff;
308 }
309 .qcwrap {
310 margin: 20px 0 0 0;
311 }
312 .TextResponses label {
313 color: #fff;
314 }
315 </style>