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

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