| 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 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
/* 10-16-2024 - CSS Updated*/ |
| 67 |
|
| 68 |
.TextResponsesouter .wrap.TextResponses{ |
| 69 |
position: relative; |
| 70 |
max-width: 1170px; |
| 71 |
} |
| 72 |
.TextResponsesouter .wrap.TextResponses:before { |
| 73 |
content: ''; |
| 74 |
position: absolute; |
| 75 |
background: url("<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/hud-left-dark.png' );?>") top left; |
| 76 |
left: -6px; |
| 77 |
width: 40px; |
| 78 |
height: 100%; |
| 79 |
z-index: 999; |
| 80 |
top: 0; |
| 81 |
background-repeat: repeat !important; |
| 82 |
} |
| 83 |
.TextResponsesouter .wrap.TextResponses:after { |
| 84 |
content: ''; |
| 85 |
position: absolute; |
| 86 |
background: url("<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/hud-righ-dark.png' );?>") top right; |
| 87 |
|
| 88 |
width: 41px; |
| 89 |
height: 100%; |
| 90 |
right: -22px; |
| 91 |
width: 28px; |
| 92 |
z-index: 999; |
| 93 |
top: 0; |
| 94 |
background-repeat: repeat !important; |
| 95 |
} |
| 96 |
.TextResponsesouter { |
| 97 |
position: relative; |
| 98 |
max-width: 1190px; |
| 99 |
} |
| 100 |
.TextResponsesouter:before { |
| 101 |
content: ''; |
| 102 |
position: absolute; |
| 103 |
background: url(<?php echo esc_url( QCLD_wpCHATBOT_IMG_URL . '/hud-top-dark_new.png' );?>) top center; |
| 104 |
left: 2px; |
| 105 |
width: 100%; |
| 106 |
height: 34px; |
| 107 |
z-index: 9999999; |
| 108 |
top: -7px; |
| 109 |
background-repeat: no-repeat; |
| 110 |
background-size: cover; |
| 111 |
} |
| 112 |
.card-header .wpbot_dashboard_header { |
| 113 |
background: #222222; |
| 114 |
} |
| 115 |
.card-header .wpbot_addons_section { |
| 116 |
background: #222222; |
| 117 |
} |
| 118 |
|
| 119 |
path{stroke-dasharray:300;stroke-dashoffset:300;stroke:#c3a477;stroke-width:2px;-webkit-animation:draw ease-out infinite;animation:draw ease-out infinite} |
| 120 |
#l1{-webkit-animation-duration:3s;animation-duration:3s} |
| 121 |
#l2{-webkit-animation-duration:5.5s;animation-duration:5.5s} |
| 122 |
#l3{-webkit-animation-duration:2s;animation-duration:2s} |
| 123 |
#l4{-webkit-animation-duration:5.5s;animation-duration:5.5s}@-webkit-keyframes draw{50%{stroke-dashoffset:0}100%{stroke-dashoffset:-300}}@keyframes draw{50%{stroke-dashoffset:0}100%{stroke-dashoffset:-300}} |
| 124 |
.lineanimation{position:absolute;top:-64px;z-index:99999999;left:-10px;right:0;margin:0 auto;width:257px;max-width:257px;height:90px;overflow:hidden;bottom:0} |
| 125 |
.lineanimation svg{width:250px;height:95px}.lineanimation svg{width:250px;height:150px;overflow:hidden}.lineanimation path{stroke:#5e5e5e} |
| 126 |
|
| 127 |
|
| 128 |
.TextResponsesouter .TextResponses { |
| 129 |
background: #222222; |
| 130 |
} |
| 131 |
|
| 132 |
.TextResponsesouter { |
| 133 |
max-width: 1230px; |
| 134 |
} |
| 135 |
.TextResponsesouter .form-table-str.form-table tr:nth-child(odd) { |
| 136 |
background: #222222 !important; |
| 137 |
} |
| 138 |
|
| 139 |
.wrapTexttop { |
| 140 |
margin: 20px 0 0 0; |
| 141 |
} |
| 142 |
.form-table-str.form-table tr:nth-child(odd) { |
| 143 |
background: #32373c !important; |
| 144 |
} |
| 145 |
</style> |
| 146 |
|
| 147 |
|
| 148 |
<?php |
| 149 |
if(isset($_GET['opt']) && $_GET['opt']=='add'): |
| 150 |
|
| 151 |
do_action('qcld_str_add_category'); |
| 152 |
|
| 153 |
elseif(isset($_GET['opt']) && $_GET['opt']=='edit'): |
| 154 |
|
| 155 |
do_action('qcld_str_edit_category'); |
| 156 |
|
| 157 |
elseif(isset($_GET['page']) && $_GET['page']=='simple-text-response' && isset($_GET['action']) && $_GET['action']=='import'): |
| 158 |
|
| 159 |
do_action('qcld_str_import'); |
| 160 |
|
| 161 |
elseif(isset($_GET['action']) && $_GET['action']=='manage-categories'): |
| 162 |
|
| 163 |
include_once(QCLD_wpCHATBOT_PLUGIN_DIR_PATH.'/includes/templates/manage-categories.php'); |
| 164 |
|
| 165 |
elseif(isset($_GET['action']) && $_GET['action']=='edit'): |
| 166 |
|
| 167 |
if(class_exists('Qcld_str_pro')): |
| 168 |
do_action('qcld_str_pro_stredit'); |
| 169 |
else: |
| 170 |
|
| 171 |
$hasEdit = false; |
| 172 |
if(isset($_GET['query']) && $_GET['query']!=''){ |
| 173 |
$hasEdit = true; |
| 174 |
$id = sanitize_text_field($_GET['query']); |
| 175 |
$table = $wpdb->prefix.'wpbot_response'; |
| 176 |
$data = $wpdb->get_row($wpdb->prepare("select * from $table where id = %d", $id)); //DB Call OK, No Caching OK |
| 177 |
|
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
?> |
| 182 |
<div class="qcwrap"> |
| 183 |
<div class="wp-chatbot-wrap"> |
| 184 |
<div class="wpbot_dashboard_header container"><h1><?php echo ($hasEdit?'Edit':'Add') ?> Response</h1></div> |
| 185 |
<form method="post" action=""> |
| 186 |
<div class="wpbot_addons_section container"> |
| 187 |
<div class="wpbot_single_addon_wrapper2"> |
| 188 |
<p><b><?php esc_html_e('Please note the following ', 'wpbot'); ?></b></p> |
| 189 |
<ul> |
| 190 |
<li> <?php esc_html_e('1. The Query, Response and Keywords fields will be searched. Add Keywords for best matches', 'wpbot'); ?></li> |
| 191 |
<li> <?php esc_html_e('2. Please clear browser Cache and Cookies both before testing new responses', 'wpbot'); ?></li> |
| 192 |
</ul> |
| 193 |
<table class="form-table-str form-table"> |
| 194 |
<tbody> |
| 195 |
<tr valign="top"> |
| 196 |
<th scope="row"><?php esc_html_e('Query', 'wpbot'); ?></th> |
| 197 |
<td> |
| 198 |
<input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" /> |
| 199 |
<input type="text" name="qc_bot_str_query" value="<?php echo esc_attr($hasEdit?$data->query:''); ?>" style="width: 400px;" required /> |
| 200 |
<br><i><?php esc_html_e('*Required. Add the query here. ', 'wpbot'); ?></i> |
| 201 |
</td> |
| 202 |
</tr> |
| 203 |
|
| 204 |
<tr valign="top"> |
| 205 |
<th scope="row"> <?php esc_html_e('Response', 'wpbot'); ?></th> |
| 206 |
<td> |
| 207 |
<?php |
| 208 |
|
| 209 |
$content = ($hasEdit?$data->response:''); |
| 210 |
$editor_id = 'qc_bot_str_response'; |
| 211 |
$settings = array( ); |
| 212 |
|
| 213 |
wp_editor( $content, $editor_id, $settings ); |
| 214 |
|
| 215 |
?> |
| 216 |
<br><i><?php esc_html_e('*Required. Add the response here. ', 'wpbot'); ?></i> |
| 217 |
</td> |
| 218 |
</tr> |
| 219 |
<tr valign="top"> |
| 220 |
<th scope="row">Keyword</th> |
| 221 |
<td> |
| 222 |
<input type="text" name="qc_bot_str_keyword" value="<?php echo esc_attr($hasEdit?$data->keyword:''); ?>" style="width: 400px;" /> |
| 223 |
<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> |
| 224 |
</td> |
| 225 |
</tr> |
| 226 |
|
| 227 |
|
| 228 |
<?php if($hasEdit): ?> |
| 229 |
|
| 230 |
<input type="hidden" name="qc_bot_str_id" value="<?php echo esc_attr($data->id); ?>" /> |
| 231 |
|
| 232 |
<?php endif; ?> |
| 233 |
|
| 234 |
|
| 235 |
</tbody> |
| 236 |
</table> |
| 237 |
</div> |
| 238 |
|
| 239 |
<footer class="wp-chatbot-admin-footer"> |
| 240 |
<div class="row"> |
| 241 |
<div class="text-left col-sm-3 col-sm-offset-3"> |
| 242 |
|
| 243 |
</div> |
| 244 |
<div class="text-right col-sm-6"> |
| 245 |
<input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings"> |
| 246 |
</div> |
| 247 |
</div> |
| 248 |
<!-- row--> |
| 249 |
</footer> |
| 250 |
|
| 251 |
|
| 252 |
</div></form> |
| 253 |
</div> |
| 254 |
</div> |
| 255 |
<?php endif; ?> |
| 256 |
<?php else: ?> |
| 257 |
<h1 class="wp-heading-inline"><?php esc_html_e('Simple Text Responses', 'wpbot'); ?></h1> |
| 258 |
<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> |
| 259 |
|
| 260 |
<?php if(class_exists('Qcld_str_pro')): ?> |
| 261 |
|
| 262 |
<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> |
| 263 |
<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> |
| 264 |
<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> |
| 265 |
|
| 266 |
<?php endif; ?> |
| 267 |
|
| 268 |
<div class="TextResponsesouter"> |
| 269 |
|
| 270 |
|
| 271 |
<div class="lineanimation"> |
| 272 |
<svg width="350" height="350" viewBox="0 0 308 309" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 273 |
<defs> |
| 274 |
<circle id="a" cx="150" cy="150" r="150"></circle> |
| 275 |
<linearGradient x1="50%" y1="0%" x2="50%" y2="62.304%" id="c"> |
| 276 |
<stop stop-color="#09DFF3" offset="0%"></stop> |
| 277 |
<stop stop-color="#44BEFF" offset="100%"></stop> |
| 278 |
</linearGradient> |
| 279 |
</defs> |
| 280 |
<g> |
| 281 |
<path id="l1" d="M0 130 L300 130"></path> |
| 282 |
<path id="l2" d="M0 150 L300 150"></path> |
| 283 |
<path id="l3" d="M0 170 L300 170"></path> |
| 284 |
<path id="l4" d="M0 190 L300 190"></path> |
| 285 |
</g> |
| 286 |
</svg></div> |
| 287 |
|
| 288 |
|
| 289 |
<div class="wrap TextResponses"> |
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
<div class="wrapTexttop"> |
| 294 |
|
| 295 |
<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> |
| 296 |
<p><b><?php esc_html_e('NB: Simple Text Responses require mySQL Client version 5.6+', 'wpbot'); ?></b></p> |
| 297 |
</div> |
| 298 |
<form method="post" action=""> |
| 299 |
<table class="form-table-str form-table"> |
| 300 |
<tbody> |
| 301 |
<tr valign="top"> |
| 302 |
<th scope="row"><?php esc_html_e('Phrase matching accuracy', 'wpbot'); ?></th> |
| 303 |
<td> |
| 304 |
<input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" /> |
| 305 |
<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 /> |
| 306 |
<br><i><?php esc_html_e('Please enter a value between 0 to 1. Higher value means more exact matching of phrases.', 'wpbot'); ?></i> |
| 307 |
</td> |
| 308 |
</tr> |
| 309 |
<tr valign="top"> |
| 310 |
<th scope="row"><?php esc_html_e('Search Fields', 'wpbot'); ?></th> |
| 311 |
<td> |
| 312 |
<?php |
| 313 |
$fields = get_option('qc_bot_str_fields'); |
| 314 |
?> |
| 315 |
|
| 316 |
<label for="qc_bot_str_field_title"><?php esc_html_e('Title', 'wpbot'); ?></label> |
| 317 |
<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"':''); ?> /> |
| 318 |
|
| 319 |
<label for="qc_bot_str_field_keyword"><?php esc_html_e('Keyword', 'wpbot'); ?></label> |
| 320 |
<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"':''); ?> /> |
| 321 |
|
| 322 |
<label for="qc_bot_str_field_response"><?php esc_html_e('Response', 'wpbot'); ?></label> |
| 323 |
<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"':''); ?> /> |
| 324 |
<br><i><?php esc_html_e('Please check/uncheck to allow/disallow searching in that fields', 'wpbot'); ?></i> |
| 325 |
</td> |
| 326 |
</tr> |
| 327 |
|
| 328 |
<tr valign="top"> |
| 329 |
<th scope="row"></th> |
| 330 |
<td> |
| 331 |
<input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings"> |
| 332 |
</td> |
| 333 |
</tr> |
| 334 |
</tbody> |
| 335 |
</table> |
| 336 |
</form> |
| 337 |
|
| 338 |
<form method="post" action=""> |
| 339 |
<table class="form-table-str form-table"> |
| 340 |
<tbody> |
| 341 |
<tr valign="top"> |
| 342 |
<th scope="row"><?php esc_html_e('Re-Index STR Simple Text Responses', 'wpbot'); ?></th> |
| 343 |
<td> |
| 344 |
<input name="str_nonce" type="hidden" value="<?php echo sanitize_key( wp_create_nonce('str-nonce') ); ?>" /> |
| 345 |
<input type="submit" class="button button-primary" name="qc-re-index" id="re-index" value="Re Index"> |
| 346 |
<br/> |
| 347 |
<i><?php esc_html_e('Re-Indexing may required after migration.', 'wpbot'); ?></i> |
| 348 |
</td> |
| 349 |
</tr> |
| 350 |
</tbody> |
| 351 |
</table> |
| 352 |
</form> |
| 353 |
<div id="poststuff"> |
| 354 |
<div id="post-body" class="metabox-holder"> |
| 355 |
<div id="post-body-content-edit" class="str-form"> |
| 356 |
<div class="meta-box-sortables ui-sortable"> |
| 357 |
<form method="post"> |
| 358 |
|
| 359 |
<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> |
| 360 |
<?php |
| 361 |
$this->response_list->prepare_items(); |
| 362 |
$this->response_list->display(); ?> |
| 363 |
</form> |
| 364 |
</div> |
| 365 |
</div> |
| 366 |
</div> |
| 367 |
|
| 368 |
</div> |
| 369 |
</div> |
| 370 |
</div> |
| 371 |
<?php endif; ?> |
| 372 |
<script type="text/javascript"> |
| 373 |
// var stopcheckBox = document.getElementById("qc_bot_str_remove_stopwords"); |
| 374 |
// stopcheckBox.addEventListener('change', function () { |
| 375 |
// if (stopcheckBox.checked == true){ |
| 376 |
// stopcheckBox.value = "1"; |
| 377 |
|
| 378 |
// } else { |
| 379 |
// stopcheckBox.value = "0"; |
| 380 |
// } |
| 381 |
// }); |
| 382 |
|
| 383 |
// var small_talk = document.getElementById('small_talk'); |
| 384 |
// small_talk.addEventListener( 'click', () => { small_talk_import(); } ); |
| 385 |
// function small_talk_import(){ |
| 386 |
// var req = new XMLHttpRequest(); |
| 387 |
// req.open('POST', ajaxurl, true); |
| 388 |
// req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); |
| 389 |
// var s = 'action=small_talk_import'; |
| 390 |
// req.send(s); |
| 391 |
// if(req.DONE == 4){ |
| 392 |
// alert('Smalltalk is imported'); |
| 393 |
// setTimeout(function(){ |
| 394 |
// window.location.reload(); |
| 395 |
// }, 3000); |
| 396 |
// } |
| 397 |
// } |
| 398 |
|
| 399 |
</script> |
| 400 |
|
| 401 |
|
| 402 |
<style> |
| 403 |
|
| 404 |
|
| 405 |
.TextResponses{ |
| 406 |
background: #32373c; |
| 407 |
padding: 20px 20px; |
| 408 |
border-radius: 6px; |
| 409 |
width: 100%; |
| 410 |
max-width: 1220px; |
| 411 |
} |
| 412 |
.TextResponses p{ |
| 413 |
color:#fff; |
| 414 |
} |
| 415 |
.TextResponses i{ |
| 416 |
color:#fff; |
| 417 |
} |
| 418 |
.TextResponses h1{ |
| 419 |
color:#fff; |
| 420 |
} |
| 421 |
.TextResponses .form-table th, .TextResponses .form-wrap label { |
| 422 |
color:#fff; |
| 423 |
} |
| 424 |
.qcwrap { |
| 425 |
margin: 20px 0 0 0; |
| 426 |
} |
| 427 |
.TextResponses label { |
| 428 |
color: #fff; |
| 429 |
} |
| 430 |
.tablenav-pages .current-page { |
| 431 |
display: inline-block; |
| 432 |
vertical-align: baseline; |
| 433 |
min-width: 30px; |
| 434 |
min-height: 31px; |
| 435 |
margin: 0 0 0 0; |
| 436 |
padding: 0 4px; |
| 437 |
font-size: 13px; |
| 438 |
line-height: 1.5; |
| 439 |
text-align: center; |
| 440 |
} |
| 441 |
.tablenav-pages .current-page { |
| 442 |
border: 1px solid |
| 443 |
} |
| 444 |
div#poststuff { |
| 445 |
color: #fff; |
| 446 |
} |
| 447 |
.str-form{ |
| 448 |
position: relative; |
| 449 |
} |
| 450 |
.str-addnew{ |
| 451 |
position: absolute !important; |
| 452 |
left: 50%; |
| 453 |
} |
| 454 |
.qcbot-str-top-notic { |
| 455 |
max-width: 1240px; |
| 456 |
padding: 0 !important; |
| 457 |
margin: 20px 0 0 0; |
| 458 |
} |
| 459 |
|
| 460 |
</style> |