| 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 |
<!-- This file should primarily consist of HTML with a little bit of PHP. --> |
| 14 |
|
| 15 |
<div class="wrap wdk-wrap"> |
| 16 |
<h1 class="wp-heading-inline"><?php echo __('Settings', 'wpdirectorykit'); ?></h1> |
| 17 |
<br /> |
| 18 |
<div class="wdk-body"> |
| 19 |
<form method="post" action="" novalidate="novalidate"> |
| 20 |
<?php wp_nonce_field( 'wdk-settings-edit', '_wpnonce'); ?> |
| 21 |
<?php |
| 22 |
$form->messages('class="alert alert-danger"', __('Successfully saved', 'wpdirectorykit')); |
| 23 |
?> |
| 24 |
<?php if(!get_option('wdk_results_page')):?> |
| 25 |
<p class="alert alert-info"><?php echo __('Missing results page', 'wpdirectorykit'); ?></p> |
| 26 |
<?php endif;?> |
| 27 |
|
| 28 |
<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> |
| 34 |
</div> |
| 35 |
<div class="postbox" style="display: block;"> |
| 36 |
<div class="inside"> |
| 37 |
<div class="wdk-tabs-panel"> |
| 38 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_general" checked value="1"> |
| 39 |
<div class="wdk-tab"> |
| 40 |
<?php echo wdk_generate_fields($fields_list_tabs['general'], $db_data); ?> |
| 41 |
</div> |
| 42 |
|
| 43 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_apis" value="1"> |
| 44 |
<div class="wdk-tab"> |
| 45 |
<?php echo wdk_generate_fields($fields_list_tabs['apis'], $db_data); ?> |
| 46 |
</div> |
| 47 |
|
| 48 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_templates" value="1"> |
| 49 |
<div class="wdk-tab"> |
| 50 |
<?php echo wdk_generate_fields($fields_list_tabs['templates'], $db_data); ?> |
| 51 |
</div> |
| 52 |
|
| 53 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_fields" value="1"> |
| 54 |
<div class="wdk-tab"> |
| 55 |
<?php echo wdk_generate_fields($fields_list_tabs['fields'], $db_data); ?> |
| 56 |
</div> |
| 57 |
|
| 58 |
<input type="radio" class="wdk-tab-input" name="wdk_tabs" id="wdk_tab_tools" value="1"> |
| 59 |
<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> |
| 77 |
</div> |
| 78 |
</div> |
| 79 |
</div> |
| 80 |
</div> |
| 81 |
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo __('Save Changes', 'wpdirectorykit'); ?>"> |
| 82 |
</form> |
| 83 |
</div> |
| 84 |
<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> |
| 86 |
</div> |
| 87 |
|
| 88 |
<script> |
| 89 |
jQuery(document).ready(function($) { |
| 90 |
$('#reset_data_field_button').on('click', function(e){ |
| 91 |
var self = $(this); |
| 92 |
|
| 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')?>", ""); |
| 94 |
|
| 95 |
if(res == "<?php echo __('remove', 'wpdirectorykit')?>") { |
| 96 |
return true; |
| 97 |
} else { |
| 98 |
e.preventDefault(); |
| 99 |
e.stopPropagation(); |
| 100 |
$(this).parent().find('.wdk-ajax-indicator').addClass('hidden'); |
| 101 |
return false; |
| 102 |
} |
| 103 |
}) |
| 104 |
$('#generate_listings_images_path').on('click', function(e){ |
| 105 |
e.preventDefault(); |
| 106 |
e.stopPropagation(); |
| 107 |
var self = $(this); |
| 108 |
|
| 109 |
if(self.attr('disabled')) { |
| 110 |
return false; |
| 111 |
} |
| 112 |
|
| 113 |
self.addClass('wdk_btn_load_indicator out'); |
| 114 |
|
| 115 |
self.attr('disabled','disabled'); |
| 116 |
var ajax_param = { |
| 117 |
"page": 'wdk_backendajax', |
| 118 |
"function": 'generated_listings_images_path', |
| 119 |
"action": 'wdk_public_action', |
| 120 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-generated_listings_images_path'));?>', |
| 121 |
}; |
| 122 |
$.post("<?php echo admin_url( 'admin-ajax.php' );?>", ajax_param, |
| 123 |
function(data){ |
| 124 |
|
| 125 |
if(data.popup_text_success) |
| 126 |
wdk_log_notify(data.popup_text_success); |
| 127 |
|
| 128 |
if(data.popup_text_error) |
| 129 |
wdk_log_notify(data.popup_text_error, 'error'); |
| 130 |
|
| 131 |
if(data.success) { |
| 132 |
self.removeClass('wdk_btn_load_indicator out'); |
| 133 |
self.addClass('wdk_btn_load_success out'); |
| 134 |
} else { |
| 135 |
self.removeClass('wdk_btn_load_indicator out'); |
| 136 |
self.addClass('wdk_btn_load_error out'); |
| 137 |
} |
| 138 |
}).always(function(data) { |
| 139 |
|
| 140 |
}); |
| 141 |
return false; |
| 142 |
}) |
| 143 |
|
| 144 |
$('#optimization_listingfields_table').on('click', function(e){ |
| 145 |
e.preventDefault(); |
| 146 |
e.stopPropagation(); |
| 147 |
var self = $(this); |
| 148 |
|
| 149 |
if(self.attr('disabled')) { |
| 150 |
return false; |
| 151 |
} |
| 152 |
|
| 153 |
self.addClass('wdk_btn_load_indicator out'); |
| 154 |
|
| 155 |
self.attr('disabled','disabled'); |
| 156 |
var ajax_param = { |
| 157 |
"page": 'wdk_backendajax', |
| 158 |
"function": 'optimization_listingfields_table', |
| 159 |
"action": 'wdk_public_action', |
| 160 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-optimization_listingfields_table'));?>', |
| 161 |
}; |
| 162 |
$.post("<?php echo admin_url( 'admin-ajax.php' );?>", ajax_param, |
| 163 |
function(data){ |
| 164 |
|
| 165 |
if(data.popup_text_success) |
| 166 |
wdk_log_notify(data.popup_text_success); |
| 167 |
|
| 168 |
if(data.popup_text_error) |
| 169 |
wdk_log_notify(data.popup_text_error, 'error'); |
| 170 |
|
| 171 |
if(data.success) { |
| 172 |
self.removeClass('wdk_btn_load_indicator out'); |
| 173 |
self.addClass('wdk_btn_load_success out'); |
| 174 |
} else { |
| 175 |
self.removeClass('wdk_btn_load_indicator out'); |
| 176 |
self.addClass('wdk_btn_load_error out'); |
| 177 |
} |
| 178 |
}).always(function(data) { |
| 179 |
|
| 180 |
}); |
| 181 |
return false; |
| 182 |
}) |
| 183 |
|
| 184 |
$('.ajax_query').on('click', function(e){ |
| 185 |
e.preventDefault(); |
| 186 |
e.stopPropagation(); |
| 187 |
var self = $(this); |
| 188 |
|
| 189 |
if(self.attr('disabled')) { |
| 190 |
return false; |
| 191 |
} |
| 192 |
|
| 193 |
self.addClass('wdk_btn_load_indicator out'); |
| 194 |
|
| 195 |
self.attr('disabled','disabled'); |
| 196 |
var ajax_param = { |
| 197 |
"page": 'wdk_backendajax', |
| 198 |
"function": self.data('function'), |
| 199 |
"action": 'wdk_public_action', |
| 200 |
"_wpnonce": '<?php echo esc_js(wp_create_nonce( 'wdk-backendajax'));?>', |
| 201 |
}; |
| 202 |
$.post("<?php echo admin_url( 'admin-ajax.php' );?>", ajax_param, |
| 203 |
function(data){ |
| 204 |
|
| 205 |
if(data.popup_text_success) |
| 206 |
wdk_log_notify(data.popup_text_success); |
| 207 |
|
| 208 |
if(data.popup_text_error) |
| 209 |
wdk_log_notify(data.popup_text_error, 'error'); |
| 210 |
|
| 211 |
if(data.success) { |
| 212 |
self.removeClass('wdk_btn_load_indicator out'); |
| 213 |
self.addClass('wdk_btn_load_success out'); |
| 214 |
} else { |
| 215 |
self.removeClass('wdk_btn_load_indicator out'); |
| 216 |
self.addClass('wdk_btn_load_error out'); |
| 217 |
} |
| 218 |
}).always(function(data) { |
| 219 |
|
| 220 |
}); |
| 221 |
return false; |
| 222 |
}) |
| 223 |
}) |
| 224 |
</script> |
| 225 |
|
| 226 |
<?php $this->view('general/footer', $data); ?> |