| 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($wpdb->prepare("select * from $table where id = %d", $id)); //DB Call OK, No Caching OK |
| 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="<?php echo sanitize_key( 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 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> |
| 166 |
|
| 167 |
<?php if(class_exists('Qcld_str_pro')): ?> |
| 168 |
|
| 169 |
<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> |
| 170 |
<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> |
| 171 |
<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> |
| 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="<?php echo sanitize_key( 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="<?php echo sanitize_key( 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 |
<div id="poststuff"> |
| 240 |
<div id="post-body" class="metabox-holder"> |
| 241 |
<div id="post-body-content-edit" class="str-form"> |
| 242 |
<div class="meta-box-sortables ui-sortable"> |
| 243 |
<form method="post"> |
| 244 |
|
| 245 |
<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> |
| 246 |
<?php |
| 247 |
$this->response_list->prepare_items(); |
| 248 |
$this->response_list->display(); ?> |
| 249 |
</form> |
| 250 |
</div> |
| 251 |
</div> |
| 252 |
</div> |
| 253 |
|
| 254 |
</div> |
| 255 |
</div> |
| 256 |
|
| 257 |
<?php endif; ?> |
| 258 |
<script type="text/javascript"> |
| 259 |
// var stopcheckBox = document.getElementById("qc_bot_str_remove_stopwords"); |
| 260 |
// stopcheckBox.addEventListener('change', function () { |
| 261 |
// if (stopcheckBox.checked == true){ |
| 262 |
// stopcheckBox.value = "1"; |
| 263 |
|
| 264 |
// } else { |
| 265 |
// stopcheckBox.value = "0"; |
| 266 |
// } |
| 267 |
// }); |
| 268 |
|
| 269 |
// var small_talk = document.getElementById('small_talk'); |
| 270 |
// small_talk.addEventListener( 'click', () => { small_talk_import(); } ); |
| 271 |
// function small_talk_import(){ |
| 272 |
// var req = new XMLHttpRequest(); |
| 273 |
// req.open('POST', ajaxurl, true); |
| 274 |
// req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); |
| 275 |
// var s = 'action=small_talk_import'; |
| 276 |
// req.send(s); |
| 277 |
// if(req.DONE == 4){ |
| 278 |
// alert('Smalltalk is imported'); |
| 279 |
// setTimeout(function(){ |
| 280 |
// window.location.reload(); |
| 281 |
// }, 3000); |
| 282 |
// } |
| 283 |
// } |
| 284 |
|
| 285 |
</script> |
| 286 |
|
| 287 |
|
| 288 |
<style> |
| 289 |
|
| 290 |
|
| 291 |
.TextResponses{ |
| 292 |
background: #32373c; |
| 293 |
padding: 20px 20px; |
| 294 |
border-radius: 6px; |
| 295 |
width: 100%; |
| 296 |
max-width: 1220px; |
| 297 |
} |
| 298 |
.TextResponses p{ |
| 299 |
color:#fff; |
| 300 |
} |
| 301 |
.TextResponses i{ |
| 302 |
color:#fff; |
| 303 |
} |
| 304 |
.TextResponses h1{ |
| 305 |
color:#fff; |
| 306 |
} |
| 307 |
.TextResponses .form-table th, .TextResponses .form-wrap label { |
| 308 |
color:#fff; |
| 309 |
} |
| 310 |
.qcwrap { |
| 311 |
margin: 20px 0 0 0; |
| 312 |
} |
| 313 |
.TextResponses label { |
| 314 |
color: #fff; |
| 315 |
} |
| 316 |
.tablenav-pages .current-page { |
| 317 |
display: inline-block; |
| 318 |
vertical-align: baseline; |
| 319 |
min-width: 30px; |
| 320 |
min-height: 31px; |
| 321 |
margin: 0 0 0 0; |
| 322 |
padding: 0 4px; |
| 323 |
font-size: 13px; |
| 324 |
line-height: 1.5; |
| 325 |
text-align: center; |
| 326 |
} |
| 327 |
.tablenav-pages .current-page { |
| 328 |
border: 1px solid |
| 329 |
} |
| 330 |
div#poststuff { |
| 331 |
color: #fff; |
| 332 |
} |
| 333 |
.str-form{ |
| 334 |
position: relative; |
| 335 |
} |
| 336 |
.str-addnew{ |
| 337 |
position: absolute !important; |
| 338 |
left: 50%; |
| 339 |
} |
| 340 |
</style> |