PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
← All changes | application/views/wdk_settings/index.php +181 -40 1.2.8 → 1.5.9 View file →
@@ -8,13 +8,15 @@
8 8
9 9 if ( ! defined( 'ABSPATH' ) ) {
10 10 exit; // Exit if accessed directly.
11 11 }
12 +
13 +
12 14 ?>
13 15 <!-- This file should primarily consist of HTML with a little bit of PHP. -->
14 16
15 17 <div class="wrap wdk-wrap">
16 - <h1 class="wp-heading-inline"><?php echo __('Settings', 'wpdirectorykit'); ?></h1>
18 + <h1 class="wp-heading-inline"><?php echo esc_html__('Settings', 'wpdirectorykit'); ?></h1>
17 19 <br />
18 20 <div class="wdk-body">
19 21 <form method="post" action="" novalidate="novalidate">
20 22 <?php wp_nonce_field( 'wdk-settings-edit', '_wpnonce'); ?>
@@ -21,79 +23,99 @@
21 23 <?php
22 24 $form->messages('class="alert alert-danger"', __('Successfully saved', 'wpdirectorykit'));
23 25 ?>
24 26 <?php if(!get_option('wdk_results_page')):?>
25 - <p class="alert alert-info"><?php echo __('Missing results page', 'wpdirectorykit'); ?></p>
27 + <p class="alert alert-info"><?php echo esc_html__('Missing results page', 'wpdirectorykit'); ?></p>
26 28 <?php endif;?>
27 29
28 30 <div class="wdk-tabs-navs">
29 - <label for="wdk_tab_general" class="active"><?php echo esc_html__('General','wpdirectorykit');?></label>
30 - <label for="wdk_tab_apis"><?php echo esc_html__('Api-s','wpdirectorykit');?></label>
31 - <label for="wdk_tab_templates"><?php echo esc_html__('Templates','wpdirectorykit');?></label>
32 - <label for="wdk_tab_fields"><?php echo esc_html__('Fields','wpdirectorykit' );?></label>
33 - <label for="wdk_tab_tools"><?php echo esc_html__('Tools','wpdirectorykit' );?></label>
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);?>
34 43 </div>
35 44 <div class="postbox" style="display: block;">
36 45 <div class="inside">
37 46 <div class="wdk-tabs-panel">
38 - <input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_general" checked value="1">
47 + <input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_general" checked value="wdk_tab_general">
39 48 <div class="wdk-tab">
40 - <?php echo wdk_generate_fields($fields_list_tabs['general'], $db_data); ?>
49 + <?php wdk_generate_fields($fields_list_tabs['general'], $db_data); ?>
41 50 </div>
42 51
43 - <input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_apis" value="1">
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;?>>
44 53 <div class="wdk-tab">
45 - <?php echo wdk_generate_fields($fields_list_tabs['apis'], $db_data); ?>
54 + <?php wdk_generate_fields($fields_list_tabs['apis'], $db_data); ?>
46 55 </div>
47 56
48 - <input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_templates" value="1">
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;?>>
49 58 <div class="wdk-tab">
50 - <?php echo wdk_generate_fields($fields_list_tabs['templates'], $db_data); ?>
59 + <?php wdk_generate_fields($fields_list_tabs['templates'], $db_data); ?>
51 60 </div>
52 61
53 - <input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_fields" value="1">
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;?>>
54 63 <div class="wdk-tab">
55 - <?php echo wdk_generate_fields($fields_list_tabs['fields'], $db_data); ?>
64 + <?php wdk_generate_fields($fields_list_tabs['fields'], $db_data); ?>
56 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;?>
57 73
58 - <input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_tools" value="1">
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;?>>
59 75 <div class="wdk-tab">
60 - <div class="wdk-field-edit">
61 - <a href="<?php echo get_admin_url() . "admin.php?page=wdk_settings&function=remove&_wpnonce=".wp_create_nonce( 'remove-data'); ?>"
62 - class="button button-primary event-ajax-indicator confirm" id="reset_data_field_button"><?php echo __('Remove plugin data (Listings, fields, location, categories)','wpdirectorykit'); ?></a>
63 - <span class="wdk-ajax-indicator wdk-infinity-load color-primary dashicons dashicons-update-alt hidden" style="margin-top: 4px;margin-left: 4px;"></span>
64 - </div>
65 - <div class="wdk-field-edit">
66 - <a href="<?php echo get_admin_url() . "admin.php?page=wdk_settings&function=import_demo"; ?>" class="button button-primary" id="import_demo_field_button"><?php echo __('Import Demo Data','wpdirectorykit'); ?></a>
67 - </div>
68 - <div class="wdk-field-edit">
69 - <a href="#" class="button button-primary" id="generate_listings_images_path"><?php echo __('Generate Listings Images Path','wpdirectorykit'); ?></a>
70 - </div>
71 - <div class="wdk-field-edit">
72 - <a href="#" class="button button-primary" id="optimization_listingfields_table"><?php echo __('Optimization Listing Fields Table','wpdirectorykit'); ?></a>
73 - </div>
74 - <div class="wdk-field-edit">
75 - <a href="#" class="button button-primary ajax_query" data-function="generated_strings"><?php echo __('Generate translation strings','wpdirectorykit'); ?></a>
76 - </div>
76 + <?php $this->view('wdk_settings/tabs/tab_tools', $data); ?>
77 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);?>
78 90 </div>
79 91 </div>
80 92 </div>
81 - <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo __('Save Changes', 'wpdirectorykit'); ?>">
93 + <input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo esc_html__('Save Changes', 'wpdirectorykit'); ?>">
82 94 </form>
83 95 </div>
84 96 <br/>
85 - <div class="alert alert-info" role="alert"><a href="//wpdirectorykit.com/documentation/#change_currency" target="_blank"><?php echo __('How to change currency?','wpdirectorykit'); ?></a></div>
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>
86 98 </div>
87 99
100 +<?php wp_enqueue_style('jquery-confirm'); ?>
101 +<?php wp_enqueue_script('jquery-confirm'); ?>
102 +
88 103 <script>
89 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 +
90 112 $('#reset_data_field_button').on('click', function(e){
91 113 var self = $(this);
92 114
93 - var res = prompt("<?php echo __('Are you sure? All Listings, fields, categories, locations will be completely removed, check url and type remove if you are sure', 'wpdirectorykit')?>", "");
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')?>", "");
94 116
95 - if(res == "<?php echo __('remove', 'wpdirectorykit')?>") {
117 + if(res == "<?php echo esc_html__('remove', 'wpdirectorykit')?>") {
96 118 return true;
97 119 } else {
98 120 e.preventDefault();
99 121 e.stopPropagation();
@@ -100,8 +122,9 @@
100 122 $(this).parent().find('.wdk-ajax-indicator').addClass('hidden');
101 123 return false;
102 124 }
103 125 })
126 +
104 127 $('#generate_listings_images_path').on('click', function(e){
105 128 e.preventDefault();
106 129 e.stopPropagation();
107 130 var self = $(this);
@@ -118,9 +141,9 @@
118 141 "function": 'generated_listings_images_path',
119 142 "action": 'wdk_public_action',
120 143 "_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-generated_listings_images_path'));?>',
121 144 };
122 - $.post("<?php echo admin_url( 'admin-ajax.php' );?>", ajax_param,
145 + $.post("<?php echo esc_url(admin_url( 'admin-ajax.php' ));?>", ajax_param,
123 146 function(data){
124 147
125 148 if(data.popup_text_success)
126 149 wdk_log_notify(data.popup_text_success);
@@ -158,9 +181,9 @@
158 181 "function": 'optimization_listingfields_table',
159 182 "action": 'wdk_public_action',
160 183 "_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-optimization_listingfields_table'));?>',
161 184 };
162 - $.post("<?php echo admin_url( 'admin-ajax.php' );?>", ajax_param,
185 + $.post("<?php echo esc_url(admin_url( 'admin-ajax.php' ));?>", ajax_param,
163 186 function(data){
164 187
165 188 if(data.popup_text_success)
166 189 wdk_log_notify(data.popup_text_success);
@@ -197,10 +220,11 @@
197 220 "page": 'wdk_backendajax',
198 221 "function": self.data('function'),
199 222 "action": 'wdk_public_action',
200 223 "_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-backendajax'));?>',
224 + "arg": self.data('arg') ?? '',
201 225 };
202 - $.post("<?php echo admin_url( 'admin-ajax.php' );?>", ajax_param,
226 + $.post("<?php echo esc_url(admin_url( 'admin-ajax.php' ));?>", ajax_param,
203 227 function(data){
204 228
205 229 if(data.popup_text_success)
206 230 wdk_log_notify(data.popup_text_success);
@@ -219,8 +243,125 @@
219 243
220 244 });
221 245 return false;
222 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();
223 364 })
224 365 </script>
225 366
226 367 <?php $this->view('general/footer', $data); ?>