| 1 |
<?php |
| 2 |
/** |
| 3 |
* The template for Settings. |
| 4 |
* |
| 5 |
* This is the template that edit form settings |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; // Exit if accessed directly. |
| 11 |
} |
| 12 |
|
| 13 |
|
| 14 |
?> |
| 15 |
<!-- This file should primarily consist of HTML with a little bit of PHP. --> |
| 16 |
|
| 17 |
<div class="wrap wdk-wrap"> |
| 18 |
<h1 class="wp-heading-inline"><?php echo esc_html__('Settings', 'wpdirectorykit'); ?></h1> |
| 19 |
<br /> |
| 20 |
<div class="wdk-body"> |
| 21 |
<form method="post" action="" novalidate="novalidate"> |
| 22 |
<?php wp_nonce_field( 'wdk-settings-edit', '_wpnonce'); ?> |
| 23 |
<?php |
| 24 |
$form->messages('class="alert alert-danger"', __('Successfully saved', 'wpdirectorykit')); |
| 25 |
?> |
| 26 |
<?php if(!get_option('wdk_results_page')):?> |
| 27 |
<p class="alert alert-info"><?php echo esc_html__('Missing results page', 'wpdirectorykit'); ?></p> |
| 28 |
<?php endif;?> |
| 29 |
|
| 30 |
<div class="wdk-tabs-navs"> |
| 31 |
<label for="wdk_tab_general"<?php if(!wmvc_show_data('wdk_tabs',$_REQUEST, false) || wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_general'):?> class="active" <?php endif;?>><?php echo esc_html__('General','wpdirectorykit');?></label> |
| 32 |
<label for="wdk_tab_apis" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_apis'):?> class="active" <?php endif;?>><?php echo esc_html__('APIs','wpdirectorykit');?></label> |
| 33 |
<label for="wdk_tab_templates" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_templates'):?> class="active" <?php endif;?>><?php echo esc_html__('Layout','wpdirectorykit');?></label> |
| 34 |
<label for="wdk_tab_fields" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_fields'):?> class="active" <?php endif;?>><?php echo esc_html__('Fields','wpdirectorykit' );?></label> |
| 35 |
<label for="wdk_tab_tools" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_tools'):?> class="active" <?php endif;?>><?php echo esc_html__('Tools','wpdirectorykit' );?></label> |
| 36 |
<label for="wdk_tab_autosuggestion" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_autosuggestion'):?> class="active" <?php endif;?>><?php echo esc_html__('Autosuggestion','wpdirectorykit' );?></label> |
| 37 |
<?php if(get_option('wdk_experimental_features')):?> |
| 38 |
<label for="wdk_tab_experimental" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_experimental'):?> class="active" <?php endif;?>><?php echo esc_html__('Experimental','wpdirectorykit' );?></label> |
| 39 |
<?php endif;?> |
| 40 |
<label for="wdk_tab_mails" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_mails'):?> class="active" <?php endif;?>><?php echo esc_html__('Emails','wpdirectorykit' );?></label> |
| 41 |
|
| 42 |
<?php do_action('wpdirectorykit/admin/settings/page/tabs', $db_data);?> |
| 43 |
</div> |
| 44 |
<div class="postbox" style="display: block;"> |
| 45 |
<div class="inside"> |
| 46 |
<div class="wdk-tabs-panel"> |
| 47 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_general" checked value="wdk_tab_general"> |
| 48 |
<div class="wdk-tab"> |
| 49 |
<?php wdk_generate_fields($fields_list_tabs['general'], $db_data); ?> |
| 50 |
</div> |
| 51 |
|
| 52 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_apis" value="wdk_tab_apis" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_apis'):?> checked="checked" <?php endif;?>> |
| 53 |
<div class="wdk-tab"> |
| 54 |
<?php wdk_generate_fields($fields_list_tabs['apis'], $db_data); ?> |
| 55 |
</div> |
| 56 |
|
| 57 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_templates" value="wdk_tab_templates" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_templates'):?> checked="checked" <?php endif;?>> |
| 58 |
<div class="wdk-tab"> |
| 59 |
<?php wdk_generate_fields($fields_list_tabs['templates'], $db_data); ?> |
| 60 |
</div> |
| 61 |
|
| 62 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_fields" value="wdk_tab_fields" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_fields'):?> checked="checked" <?php endif;?>> |
| 63 |
<div class="wdk-tab"> |
| 64 |
<?php wdk_generate_fields($fields_list_tabs['fields'], $db_data); ?> |
| 65 |
</div> |
| 66 |
|
| 67 |
<?php if(get_option('wdk_experimental_features')):?> |
| 68 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_experimental" value="wdk_tab_experimental" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_experimental'):?> checked="checked" <?php endif;?>> |
| 69 |
<div class="wdk-tab"> |
| 70 |
<?php wdk_generate_fields($fields_list_tabs['experimental'], $db_data); ?> |
| 71 |
</div> |
| 72 |
<?php endif;?> |
| 73 |
|
| 74 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_tools" value="wdk_tab_tools" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_tools'):?> checked="checked" <?php endif;?>> |
| 75 |
<div class="wdk-tab"> |
| 76 |
<?php $this->view('wdk_settings/tabs/tab_tools', $data); ?> |
| 77 |
</div> |
| 78 |
|
| 79 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_autosuggestion" value="wdk_tab_autosuggestion" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_autosuggestion'):?> checked="checked" <?php endif;?>> |
| 80 |
<div class="wdk-tab"> |
| 81 |
<?php wdk_generate_fields($fields_list_tabs['autosuggestion'], $db_data); ?> |
| 82 |
</div> |
| 83 |
|
| 84 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_mails" value="wdk_tab_mails" <?php if(wmvc_show_data('wdk_tabs',$_REQUEST) == 'wdk_tab_mails'):?> checked="checked" <?php endif;?>> |
| 85 |
<div class="wdk-tab"> |
| 86 |
<?php $this->view('wdk_settings/tabs/tab_emails', $data); ?> |
| 87 |
</div> |
| 88 |
|
| 89 |
<?php do_action('wpdirectorykit/admin/settings/page/tabs-list', $db_data);?> |
| 90 |
</div> |
| 91 |
</div> |
| 92 |
</div> |
| 93 |
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo esc_html__('Save Changes', 'wpdirectorykit'); ?>"> |
| 94 |
</form> |
| 95 |
</div> |
| 96 |
<br/> |
| 97 |
<div class="alert alert-info" role="alert"><a href="//wpdirectorykit.com/documentation/#change_currency" target="_blank"><?php echo esc_html__('How to change currency?','wpdirectorykit'); ?></a></div> |
| 98 |
</div> |
| 99 |
|
| 100 |
<?php wp_enqueue_style('jquery-confirm'); ?> |
| 101 |
<?php wp_enqueue_script('jquery-confirm'); ?> |
| 102 |
|
| 103 |
<script> |
| 104 |
jQuery(document).ready(function($) { |
| 105 |
/* reset page feature, create new demo page and atache */ |
| 106 |
|
| 107 |
$('#wdk_results_page, #wdk_listing_page').each(function(){ |
| 108 |
$(this).closest('.wdk-field-edit').find('.suffix').append(`<a data-function="reinstall_page" data-arg="`+$(this).attr('id')+`" class="button button ajax_query_pages" href="#" style="margin-top: -5px;"> <?php echo esc_html__('Reset','wpdirectorykit');?>`); |
| 109 |
}); |
| 110 |
|
| 111 |
|
| 112 |
$('#reset_data_field_button').on('click', function(e){ |
| 113 |
var self = $(this); |
| 114 |
|
| 115 |
var res = prompt("<?php echo esc_html__('Are you sure? All Listings, fields, categories, locations will be completely removed, check url and type remove if you are sure', 'wpdirectorykit')?>", ""); |
| 116 |
|
| 117 |
if(res == "<?php echo esc_html__('remove', 'wpdirectorykit')?>") { |
| 118 |
return true; |
| 119 |
} else { |
| 120 |
e.preventDefault(); |
| 121 |
e.stopPropagation(); |
| 122 |
$(this).parent().find('.wdk-ajax-indicator').addClass('hidden'); |
| 123 |
return false; |
| 124 |
} |
| 125 |
}) |
| 126 |
|
| 127 |
$('#generate_listings_images_path').on('click', function(e){ |
| 128 |
e.preventDefault(); |
| 129 |
e.stopPropagation(); |
| 130 |
var self = $(this); |
| 131 |
|
| 132 |
if(self.attr('disabled')) { |
| 133 |
return false; |
| 134 |
} |
| 135 |
|
| 136 |
self.addClass('wdk_btn_load_indicator out'); |
| 137 |
|
| 138 |
self.attr('disabled','disabled'); |
| 139 |
var ajax_param = { |
| 140 |
"page": 'wdk_backendajax', |
| 141 |
"function": 'generated_listings_images_path', |
| 142 |
"action": 'wdk_public_action', |
| 143 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-generated_listings_images_path'));?>', |
| 144 |
}; |
| 145 |
$.post("<?php echo esc_url(admin_url( 'admin-ajax.php' ));?>", ajax_param, |
| 146 |
function(data){ |
| 147 |
|
| 148 |
if(data.popup_text_success) |
| 149 |
wdk_log_notify(data.popup_text_success); |
| 150 |
|
| 151 |
if(data.popup_text_error) |
| 152 |
wdk_log_notify(data.popup_text_error, 'error'); |
| 153 |
|
| 154 |
if(data.success) { |
| 155 |
self.removeClass('wdk_btn_load_indicator out'); |
| 156 |
self.addClass('wdk_btn_load_success out'); |
| 157 |
} else { |
| 158 |
self.removeClass('wdk_btn_load_indicator out'); |
| 159 |
self.addClass('wdk_btn_load_error out'); |
| 160 |
} |
| 161 |
}).always(function(data) { |
| 162 |
|
| 163 |
}); |
| 164 |
return false; |
| 165 |
}) |
| 166 |
|
| 167 |
$('#optimization_listingfields_table').on('click', function(e){ |
| 168 |
e.preventDefault(); |
| 169 |
e.stopPropagation(); |
| 170 |
var self = $(this); |
| 171 |
|
| 172 |
if(self.attr('disabled')) { |
| 173 |
return false; |
| 174 |
} |
| 175 |
|
| 176 |
self.addClass('wdk_btn_load_indicator out'); |
| 177 |
|
| 178 |
self.attr('disabled','disabled'); |
| 179 |
var ajax_param = { |
| 180 |
"page": 'wdk_backendajax', |
| 181 |
"function": 'optimization_listingfields_table', |
| 182 |
"action": 'wdk_public_action', |
| 183 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-optimization_listingfields_table'));?>', |
| 184 |
}; |
| 185 |
$.post("<?php echo esc_url(admin_url( 'admin-ajax.php' ));?>", ajax_param, |
| 186 |
function(data){ |
| 187 |
|
| 188 |
if(data.popup_text_success) |
| 189 |
wdk_log_notify(data.popup_text_success); |
| 190 |
|
| 191 |
if(data.popup_text_error) |
| 192 |
wdk_log_notify(data.popup_text_error, 'error'); |
| 193 |
|
| 194 |
if(data.success) { |
| 195 |
self.removeClass('wdk_btn_load_indicator out'); |
| 196 |
self.addClass('wdk_btn_load_success out'); |
| 197 |
} else { |
| 198 |
self.removeClass('wdk_btn_load_indicator out'); |
| 199 |
self.addClass('wdk_btn_load_error out'); |
| 200 |
} |
| 201 |
}).always(function(data) { |
| 202 |
|
| 203 |
}); |
| 204 |
return false; |
| 205 |
}) |
| 206 |
|
| 207 |
$('.ajax_query').on('click', function(e){ |
| 208 |
e.preventDefault(); |
| 209 |
e.stopPropagation(); |
| 210 |
var self = $(this); |
| 211 |
|
| 212 |
if(self.attr('disabled')) { |
| 213 |
return false; |
| 214 |
} |
| 215 |
|
| 216 |
self.addClass('wdk_btn_load_indicator out'); |
| 217 |
|
| 218 |
self.attr('disabled','disabled'); |
| 219 |
var ajax_param = { |
| 220 |
"page": 'wdk_backendajax', |
| 221 |
"function": self.data('function'), |
| 222 |
"action": 'wdk_public_action', |
| 223 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-backendajax'));?>', |
| 224 |
"arg": self.data('arg') ?? '', |
| 225 |
}; |
| 226 |
$.post("<?php echo esc_url(admin_url( 'admin-ajax.php' ));?>", ajax_param, |
| 227 |
function(data){ |
| 228 |
|
| 229 |
if(data.popup_text_success) |
| 230 |
wdk_log_notify(data.popup_text_success); |
| 231 |
|
| 232 |
if(data.popup_text_error) |
| 233 |
wdk_log_notify(data.popup_text_error, 'error'); |
| 234 |
|
| 235 |
if(data.success) { |
| 236 |
self.removeClass('wdk_btn_load_indicator out'); |
| 237 |
self.addClass('wdk_btn_load_success out'); |
| 238 |
} else { |
| 239 |
self.removeClass('wdk_btn_load_indicator out'); |
| 240 |
self.addClass('wdk_btn_load_error out'); |
| 241 |
} |
| 242 |
}).always(function(data) { |
| 243 |
|
| 244 |
}); |
| 245 |
return false; |
| 246 |
}) |
| 247 |
|
| 248 |
$('.ajax_query_pages').on('click', function(e){ |
| 249 |
e.preventDefault(); |
| 250 |
e.stopPropagation(); |
| 251 |
var self = $(this); |
| 252 |
|
| 253 |
if(self.attr('disabled')) { |
| 254 |
return false; |
| 255 |
} |
| 256 |
|
| 257 |
|
| 258 |
$.confirm({ |
| 259 |
boxWidth: '400px', |
| 260 |
useBootstrap: false, |
| 261 |
title: '', |
| 262 |
content: '<?php echo esc_js(esc_html__('Are you sure? current layout will be replaced with default plugin version','wpdirectorykit'));?>', |
| 263 |
buttons: { |
| 264 |
cancel: function () { |
| 265 |
return true; |
| 266 |
}, |
| 267 |
confirm: { |
| 268 |
text: '<?php echo esc_js(esc_html__('Confirm','wpdirectorykit'));?>', |
| 269 |
btnClass: 'btn-blue', |
| 270 |
keys: ['enter', 'shift'], |
| 271 |
action: function(){ |
| 272 |
var ajax_param = { |
| 273 |
"page": 'wdk_backendajax', |
| 274 |
"function": self.data('function'), |
| 275 |
"action": 'wdk_public_action', |
| 276 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-backendajax'));?>', |
| 277 |
"arg": self.data('arg') ?? '', |
| 278 |
}; |
| 279 |
|
| 280 |
self.addClass('wdk_btn_load_indicator out'); |
| 281 |
self.attr('disabled','disabled'); |
| 282 |
$.post("<?php echo esc_url(admin_url( 'admin-ajax.php' ));?>", ajax_param, |
| 283 |
function(data){ |
| 284 |
|
| 285 |
if(data.popup_text_success) |
| 286 |
wdk_log_notify(data.popup_text_success); |
| 287 |
|
| 288 |
if(data.popup_text_error) |
| 289 |
wdk_log_notify(data.popup_text_error, 'error'); |
| 290 |
|
| 291 |
if(data.success) { |
| 292 |
self.removeClass('wdk_btn_load_indicator out'); |
| 293 |
self.addClass('wdk_btn_load_success out'); |
| 294 |
|
| 295 |
if(data.page_id && data.page_title) { |
| 296 |
self.closest('.wdk-field-container').find('select option').removeAttr('selected').parent().append('<option selected="selected" value="'+data.page_id+'">'+data.page_title+' #'+data.page_id+'</option>'); |
| 297 |
} |
| 298 |
} else { |
| 299 |
self.removeClass('wdk_btn_load_indicator out'); |
| 300 |
self.addClass('wdk_btn_load_error out'); |
| 301 |
} |
| 302 |
}).always(function(data) { |
| 303 |
|
| 304 |
}); |
| 305 |
|
| 306 |
return true; |
| 307 |
} |
| 308 |
}, |
| 309 |
} |
| 310 |
}) |
| 311 |
}) |
| 312 |
|
| 313 |
/* number format live */ |
| 314 |
|
| 315 |
// Live update for number format fields example |
| 316 |
function updateWdkExamplePriceFormat() { |
| 317 |
var decimal_point = $('#wdk_number_format_decimal_point').val(); |
| 318 |
var thousands_sep = $('#wdk_number_format_thousands_sep').val(); |
| 319 |
var decimals = $('#wdk_number_format_decimals').val(); |
| 320 |
|
| 321 |
// Fallbacks for empty values |
| 322 |
if (decimal_point === '') decimal_point = '.'; |
| 323 |
if (thousands_sep === '') thousands_sep = ','; |
| 324 |
if (decimals === '' || isNaN(decimals)) decimals = 0; |
| 325 |
decimals = parseInt(decimals); |
| 326 |
|
| 327 |
// Example number to format |
| 328 |
var exampleNumber = 1234567.89; |
| 329 |
|
| 330 |
// Format number |
| 331 |
function number_format(number, decimals, dec_point, thousands_sep) { |
| 332 |
number = (number + '').replace(/[^0-9+\-Ee.]/g, ''); |
| 333 |
var n = !isFinite(+number) ? 0 : +number, |
| 334 |
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), |
| 335 |
sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, |
| 336 |
dec = (typeof dec_point === 'undefined') ? '.' : dec_point, |
| 337 |
s = '', |
| 338 |
toFixedFix = function (n, prec) { |
| 339 |
var k = Math.pow(10, prec); |
| 340 |
return '' + Math.round(n * k) / k; |
| 341 |
}; |
| 342 |
s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); |
| 343 |
var re = /(-?\d+)(\d{3})/; |
| 344 |
while (re.test(s[0])) { |
| 345 |
s[0] = s[0].replace(re, "$1" + sep + "$2"); |
| 346 |
} |
| 347 |
if ((s[1] || '').length < prec) { |
| 348 |
s[1] = s[1] || ''; |
| 349 |
s[1] += new Array(prec - s[1].length + 1).join('0'); |
| 350 |
} |
| 351 |
return s.join(dec); |
| 352 |
} |
| 353 |
|
| 354 |
var formatted = number_format(exampleNumber, decimals, decimal_point, thousands_sep); |
| 355 |
$('#wdk_example_price_format').text(formatted); |
| 356 |
} |
| 357 |
|
| 358 |
$('#wdk_number_format_decimal_point, #wdk_number_format_thousands_sep, #wdk_number_format_decimals').on('input change', function() { |
| 359 |
updateWdkExamplePriceFormat(); |
| 360 |
}); |
| 361 |
|
| 362 |
// Initial update on page load |
| 363 |
updateWdkExamplePriceFormat(); |
| 364 |
}) |
| 365 |
</script> |
| 366 |
|
| 367 |
<?php $this->view('general/footer', $data); ?> |