| 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>Please note the following</b></p> |
| 86 |
<ul> |
| 87 |
<li>1. The Query, Response and Keywords fields will be searched. Add Keywords for best matches</li> |
| 88 |
<li>2. Please clear browser Cache and Cookies both before testing new responses</li> |
| 89 |
</ul> |
| 90 |
<table class="form-table"> |
| 91 |
<tbody> |
| 92 |
<tr valign="top"> |
| 93 |
<th scope="row">Query</th> |
| 94 |
<td> |
| 95 |
<input type="text" name="qc_bot_str_query" value="<?php echo ($hasEdit?$data->query:''); ?>" style="width: 400px;" required /> |
| 96 |
<br><i>*Required. Add the query here.</i> |
| 97 |
</td> |
| 98 |
</tr> |
| 99 |
|
| 100 |
<tr valign="top"> |
| 101 |
<th scope="row">Response</th> |
| 102 |
<td> |
| 103 |
<textarea id="qlcd_wp_chatbot_stop_words" cols="130" rows="10" name="qc_bot_str_response" required><?php echo ($hasEdit?$data->response:''); ?></textarea> |
| 104 |
<br><i>*Required. Add the response here.</i> |
| 105 |
</td> |
| 106 |
</tr> |
| 107 |
<tr valign="top"> |
| 108 |
<th scope="row">Keyword</th> |
| 109 |
<td> |
| 110 |
<input type="text" name="qc_bot_str_keyword" value="<?php echo ($hasEdit?$data->keyword:''); ?>" style="width: 400px;" /> |
| 111 |
<br><i>Optional. Add multiple keyword or phrases as comma(,) seperated value. It will help to find the best match result.</i> |
| 112 |
</td> |
| 113 |
</tr> |
| 114 |
|
| 115 |
<tr valign="top"> |
| 116 |
<th scope="row">Intent</th> |
| 117 |
<td> |
| 118 |
<input type="text" name="qc_bot_str_intent" value="<?php echo ($hasEdit?$data->intent:''); ?>" style="width: 400px;" /> |
| 119 |
<br><i>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.</i> |
| 120 |
<?php if($hasEdit): ?> |
| 121 |
|
| 122 |
<input type="hidden" name="qc_bot_str_id" value="<?php echo ($data->id); ?>" /> |
| 123 |
|
| 124 |
<?php endif; ?> |
| 125 |
</td> |
| 126 |
</tr> |
| 127 |
|
| 128 |
|
| 129 |
</tbody> |
| 130 |
</table> |
| 131 |
</div> |
| 132 |
|
| 133 |
<footer class="wp-chatbot-admin-footer"> |
| 134 |
<div class="row"> |
| 135 |
<div class="text-left col-sm-3 col-sm-offset-3"> |
| 136 |
|
| 137 |
</div> |
| 138 |
<div class="text-right col-sm-6"> |
| 139 |
<input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings"> |
| 140 |
</div> |
| 141 |
</div> |
| 142 |
<!-- row--> |
| 143 |
</footer> |
| 144 |
|
| 145 |
|
| 146 |
</div></form> |
| 147 |
</div> |
| 148 |
</div> |
| 149 |
<?php endif; ?> |
| 150 |
<?php else: |
| 151 |
$small_talk = get_option('qcld_small_talk_imported'); |
| 152 |
?> |
| 153 |
<div class="wrap"> |
| 154 |
<h1 class="wp-heading-inline"> |
| 155 |
Simple Text Responses</h1> |
| 156 |
<a href="<?php echo add_query_arg( 'action', 'edit', admin_url('admin.php?page=simple-text-response') ); ?>" class="page-title-action">Add New</a> |
| 157 |
<?php if($small_talk != 'yes'){ ?> |
| 158 |
<a id="small_talk" class="page-title-action">Import Small Talk</a> |
| 159 |
<?php } ?> |
| 160 |
<?php if(class_exists('Qcld_str_pro')): ?> |
| 161 |
|
| 162 |
<a href="<?php echo add_query_arg( 'action', 'manage-categories', admin_url('admin.php?page=simple-text-response') ); ?>" class="page-title-action">Manage Categories</a> |
| 163 |
<a href="<?php echo admin_url( 'admin-post.php?action=qc_str_export' ); ?>" class="page-title-action">Export</a> |
| 164 |
<a href="<?php echo add_query_arg( 'action', 'import', admin_url('admin.php?page=simple-text-response') ); ?>" class="page-title-action">Import</a> |
| 165 |
|
| 166 |
<?php endif; ?> |
| 167 |
|
| 168 |
<hr class="wp-header-end"> |
| 169 |
|
| 170 |
<p>Create simple text responses and the ChatBot will use advanced search algorithm for natural language phrase matching with user input.</p> |
| 171 |
<p><b>This is a new feature. If you have any feedback to improve this feature or found a bug please report us <a href="https://www.quantumcloud.com/resources/free-support/" target="_blank">here</a>.</b></p> |
| 172 |
<p><b>NB: Simple Text Responses require mySQL Client version 5.6+</b></p> |
| 173 |
|
| 174 |
<form method="post" action=""> |
| 175 |
<table class="form-table"> |
| 176 |
<tbody> |
| 177 |
<tr valign="top"> |
| 178 |
<th scope="row">Phrase matching accuracy</th> |
| 179 |
<td> |
| 180 |
|
| 181 |
<input type="text" name="qc_bot_str_weight" value="<?php echo (get_option('qc_bot_str_weight')!=''?get_option('qc_bot_str_weight'):'0.4'); ?>" style="width: 400px;" required /> |
| 182 |
<br><i>Please enter a value between 0 to 1. Higher value means more exact matching of phrases.</i> |
| 183 |
</td> |
| 184 |
</tr> |
| 185 |
<?php// if(class_exists('Qcld_str_pro')): ?> |
| 186 |
<tr valign="top"> |
| 187 |
<th scope="row">Search Fields</th> |
| 188 |
<td> |
| 189 |
<?php |
| 190 |
$fields = get_option('qc_bot_str_fields'); |
| 191 |
?> |
| 192 |
|
| 193 |
<label for="qc_bot_str_field_title">Title</label> |
| 194 |
<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"':''); ?> /> |
| 195 |
|
| 196 |
<label for="qc_bot_str_field_keyword">Keyword</label> |
| 197 |
<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"':''); ?> /> |
| 198 |
|
| 199 |
<label for="qc_bot_str_field_response">Response</label> |
| 200 |
<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"':''); ?> /> |
| 201 |
<br><i>Please check/uncheck to allow/disallow searching in that fields</i> |
| 202 |
</td> |
| 203 |
</tr> |
| 204 |
<!-- <tr valign="top"> |
| 205 |
<th scope="row">Remove Stopwords</th> |
| 206 |
<td> |
| 207 |
<input id="qc_bot_str_remove_stopwords" type="checkbox" name="qc_bot_str_remove_stopwords" value="<?php //echo get_option('qc_bot_str_remove_stopwords') ?>" <?php //echo ((get_option('qc_bot_str_remove_stopwords') ==1) ? 'checked="checked"':''); ?> /> |
| 208 |
<label for="qc_bot_str_remove_stopwords">Remove Stopwords</label> |
| 209 |
<br><i>Please enable to remove stopwords from users query for better searching.</i> |
| 210 |
</td> |
| 211 |
</tr> --> |
| 212 |
<?php //endif; ?> |
| 213 |
<tr valign="top"> |
| 214 |
<th scope="row"></th> |
| 215 |
<td> |
| 216 |
<input type="submit" class="button button-primary" name="submit" id="submit" value="Save Settings"> |
| 217 |
</td> |
| 218 |
</tr> |
| 219 |
</tbody> |
| 220 |
</table> |
| 221 |
</form> |
| 222 |
|
| 223 |
<form method="post" action=""> |
| 224 |
<table class="form-table"> |
| 225 |
<tbody> |
| 226 |
<tr valign="top"> |
| 227 |
<th scope="row">Re-Index STR Simple Text Responses</th> |
| 228 |
<td> |
| 229 |
<input type="submit" class="button button-primary" name="qc-re-index" id="re-index" value="Re Index"> |
| 230 |
<br/> |
| 231 |
<i>Re-Indexing may required after migration.</i> |
| 232 |
</td> |
| 233 |
</tr> |
| 234 |
</tbody> |
| 235 |
</table> |
| 236 |
</form> |
| 237 |
|
| 238 |
<div id="poststuff"> |
| 239 |
<div id="post-body" class="metabox-holder"> |
| 240 |
<div id="post-body-content"> |
| 241 |
<div class="meta-box-sortables ui-sortable"> |
| 242 |
<form method="post"> |
| 243 |
<?php |
| 244 |
$this->response_list->prepare_items(); |
| 245 |
$this->response_list->display(); ?> |
| 246 |
</form> |
| 247 |
</div> |
| 248 |
</div> |
| 249 |
</div> |
| 250 |
<br class="clear"> |
| 251 |
</div> |
| 252 |
</div> |
| 253 |
|
| 254 |
<?php endif; ?> |
| 255 |
<script type="text/javascript"> |
| 256 |
var stopcheckBox = document.getElementById("qc_bot_str_remove_stopwords"); |
| 257 |
stopcheckBox.addEventListener('change', function () { |
| 258 |
if (stopcheckBox.checked == true){ |
| 259 |
stopcheckBox.value = "1"; |
| 260 |
|
| 261 |
} else { |
| 262 |
stopcheckBox.value = "0"; |
| 263 |
} |
| 264 |
}); |
| 265 |
|
| 266 |
var small_talk = document.getElementById('small_talk'); |
| 267 |
small_talk.addEventListener( 'click', () => { small_talk_import(); } ); |
| 268 |
function small_talk_import(){ |
| 269 |
var req = new XMLHttpRequest(); |
| 270 |
req.open('POST', ajaxurl, true); |
| 271 |
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); |
| 272 |
var s = 'action=small_talk_import'; |
| 273 |
req.send(s); |
| 274 |
if(req.DONE == 4){ |
| 275 |
alert('Smalltalk is imported'); |
| 276 |
setTimeout(function(){ |
| 277 |
window.location.reload(); |
| 278 |
}, 3000); |
| 279 |
} |
| 280 |
} |
| 281 |
|
| 282 |
</script> |
| 283 |
|