| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The template for Edit Location. |
| 5 |
* |
| 6 |
* This is the template that form edit |
| 7 |
* |
| 8 |
*/ |
| 9 |
|
| 10 |
if (! defined('ABSPATH')) { |
| 11 |
exit; // Exit if accessed directly. |
| 12 |
} |
| 13 |
?> |
| 14 |
<!-- This file should primarily consist of HTML with a little bit of PHP. --> |
| 15 |
|
| 16 |
<div class="wrap wdk-wrap"> |
| 17 |
<h1 class="wp-heading-inline"><?php echo esc_html__('Location Management', 'wpdirectorykit'); ?></h1> |
| 18 |
<br /> |
| 19 |
<div class="wdk-body"> |
| 20 |
<div class="postbox" style="display: block;"> |
| 21 |
<div class="postbox-header"> |
| 22 |
<h3><?php echo esc_html__('Add/Edit Location', 'wpdirectorykit'); ?></h3> |
| 23 |
|
| 24 |
<?php if (function_exists('run_wdk_svg_map') && wmvc_show_data('idlocation', $db_data, false)): ?> |
| 25 |
<a href="<?php echo esc_url(admin_url('admin.php?page=wdk_location&function=import_from_svg&id=' . wmvc_show_data('idlocation', $db_data, false))); ?>" class="wdk-mr-5 button button-secondary alignright"> |
| 26 |
<span class="dashicons dashicons-admin-page" ></span><?php echo esc_html__('Import sublocations from SVG Map', 'wpdirectorykit'); ?> |
| 27 |
</a> |
| 28 |
<?php endif; ?> |
| 29 |
</div> |
| 30 |
<div class="inside"> |
| 31 |
|
| 32 |
<form method="post" class="form_listing_ai" action="<?php echo esc_url(wmvc_current_edit_url()); ?>" novalidate="novalidate"> |
| 33 |
<?php wp_nonce_field('wdk-location-edit_' . wmvc_show_data('idlocation', $db_data, 0), '_wpnonce'); ?> |
| 34 |
<?php |
| 35 |
$form->messages('class="alert alert-danger"', __('Successfully saved', 'wpdirectorykit')); |
| 36 |
?> |
| 37 |
|
| 38 |
<table class="form-table" role="presentation"> |
| 39 |
<tbody> |
| 40 |
<tr> |
| 41 |
<th scope="row"><label for="parent_id"><?php echo esc_html__('Parent', 'wpdirectorykit'); ?></label></th> |
| 42 |
<td> |
| 43 |
<?php |
| 44 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText |
| 45 |
echo wmvc_select_option('parent_id', $parents, wmvc_show_data('parent_id', $db_data, ''), NULL, __('Root', 'wpdirectorykit'), '0'); |
| 46 |
?> |
| 47 |
|
| 48 |
</td> |
| 49 |
</tr> |
| 50 |
<tr> |
| 51 |
<th scope="row"><label for="location_title"><?php echo esc_html__('Title', 'wpdirectorykit'); ?></label></th> |
| 52 |
<td><input name="location_title" type="text" id="location_title" value="<?php echo esc_attr(wmvc_show_data('location_title', $db_data, '')); ?>" class="regular-text"></td> |
| 53 |
</tr> |
| 54 |
<tr> |
| 55 |
<th scope="row"> |
| 56 |
<label for="titles_for_search"><?php echo esc_html__('Alternative titles for search', 'wpdirectorykit'); ?></label> |
| 57 |
</th> |
| 58 |
<td> |
| 59 |
<input name="titles_for_search" type="text" id="titles_for_search" |
| 60 |
value="<?php echo esc_attr(wmvc_show_data('titles_for_search', $db_data, '')); ?>" |
| 61 |
class="regular-text"> |
| 62 |
<p class="description" id="order_index-description"> |
| 63 |
<?php echo esc_html__('This can be used for search in different languages, please enter titles like: "Croatia,Hrvatska" so supporting multiple titles', 'wpdirectorykit'); ?> |
| 64 |
</p> |
| 65 |
</td> |
| 66 |
</tr> |
| 67 |
<tr> |
| 68 |
<th scope="row"><label for="order_index"><?php echo esc_html__('Order Index', 'wpdirectorykit'); ?></label></th> |
| 69 |
<td> |
| 70 |
<input name="order_index" type="text" id="order_index" value="<?php echo esc_attr(wmvc_show_data('order_index', $db_data, '')); ?>" class="regular-text"> |
| 71 |
<p class="description" id="order_index-description"><?php echo esc_html__('Index for sorting/ordering, you can leave it empty and will be auto added to end of parent list', 'wpdirectorykit'); ?></p> |
| 72 |
</td> |
| 73 |
</tr> |
| 74 |
<?php if (function_exists('run_wdk_svg_map')): ?> |
| 75 |
<tr> |
| 76 |
<th scope="row"><label for="related_svg_map"><?php echo esc_html__('Related SVG Map', 'wpdirectorykit'); ?></label></th> |
| 77 |
<td> |
| 78 |
<?php |
| 79 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText |
| 80 |
echo wmvc_select_option('related_svg_map', $maps_list, wmvc_show_data('related_svg_map', $db_data, ''), "id='related_svg_map'", __('Not Selected', 'wpdirectorykit'), '0'); |
| 81 |
?> |
| 82 |
</td> |
| 83 |
</tr> |
| 84 |
<tr> |
| 85 |
<th scope="row"><label for="related_svg_map_location"><?php echo esc_html__('Related SVG Map Location', 'wpdirectorykit'); ?></label></th> |
| 86 |
<td> |
| 87 |
<?php |
| 88 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText |
| 89 |
echo wmvc_select_option('related_svg_map_location', $map_related_locations, wmvc_show_data('related_svg_map_location', $db_data, ''), "id='related_svg_map_location'", __('Not Selected', 'wpdirectorykit'), '0'); |
| 90 |
?> |
| 91 |
</td> |
| 92 |
</tr> |
| 93 |
<?php endif; ?> |
| 94 |
<tr> |
| 95 |
<th scope="row"><label for="icon_id"><?php echo esc_html__('Icon', 'wpdirectorykit'); ?></label></th> |
| 96 |
<td> |
| 97 |
<?php |
| 98 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText |
| 99 |
echo wmvc_upload_media('icon_id', wmvc_show_data('icon_id', $db_data, '')); |
| 100 |
?> |
| 101 |
<p class="description" id="icon_id-description"><?php echo esc_html__('Icon used for marker/pin on map or special places on website', 'wpdirectorykit'); ?></p> |
| 102 |
</td> |
| 103 |
</tr> |
| 104 |
<tr> |
| 105 |
<th scope="row"><label for="image_id"><?php echo esc_html__('Image', 'wpdirectorykit'); ?></label></th> |
| 106 |
<td> |
| 107 |
<?php |
| 108 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText |
| 109 |
echo wmvc_upload_media('image_id', wmvc_show_data('image_id', $db_data, '')); |
| 110 |
?> |
| 111 |
<p class="description" id="image_id-description"><?php echo esc_html__('Image used for widgets or elements where categories are visible', 'wpdirectorykit'); ?></p> |
| 112 |
</td> |
| 113 |
</tr> |
| 114 |
</tbody> |
| 115 |
</table> |
| 116 |
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo esc_attr__('Save Changes', 'wpdirectorykit'); ?>"> |
| 117 |
</form> |
| 118 |
</div> |
| 119 |
</div> |
| 120 |
<div class="postbox postbox-map" style="<?php if (wmvc_show_data('related_svg_map', $db_data, '')): ?>display: block;<?php else: ?>display: none;<?php endif; ?>"> |
| 121 |
<div class="postbox-header"> |
| 122 |
<h3><?php echo esc_html__('Map', 'wpdirectorykit'); ?></h3> |
| 123 |
</div> |
| 124 |
<div class="inside"> |
| 125 |
<div class="wdk-row"> |
| 126 |
<div class="wdk-col-auto col-list"> |
| 127 |
<div class="map-list"> |
| 128 |
</div> |
| 129 |
</div> |
| 130 |
<div class="wdk-col-auto col-map"> |
| 131 |
<div class="wdk-svg-map-box"> |
| 132 |
<div class="wdk_svg_map" data-map="<?php echo esc_attr(wmvc_show_data('related_svg_map', $db_data, '')); ?>"></div> |
| 133 |
</div> |
| 134 |
</div> |
| 135 |
</div> |
| 136 |
</div> |
| 137 |
</div> |
| 138 |
<div class="alert alert-info" role="alert"><?php |
| 139 |
echo wp_kses( |
| 140 |
sprintf( |
| 141 |
/* translators: 1: Tag with link open, 2: close link tag. */ |
| 142 |
__('%1$s How to add new country in locations? %2$s', 'wpdirectorykit'), |
| 143 |
'<a href="' . esc_url('https://wpdirectorykit.com/documentation/#add-new-country') . '" target="_blank">', |
| 144 |
'</a>' |
| 145 |
), |
| 146 |
array( |
| 147 |
'a' => array( |
| 148 |
'href' => true, |
| 149 |
'target' => true, |
| 150 |
), |
| 151 |
) |
| 152 |
); |
| 153 |
?></div> |
| 154 |
</div> |
| 155 |
</div> |
| 156 |
|
| 157 |
|
| 158 |
<?php if(function_exists('run_wdk_svg_map')):?> |
| 159 |
<script> |
| 160 |
var jqxhr = null; |
| 161 |
jQuery(document).ready(function($) { |
| 162 |
$('#related_svg_map').on('input', function(e) { |
| 163 |
e.preventDefault(); |
| 164 |
e.stopPropagation(); |
| 165 |
var self = $(this); |
| 166 |
|
| 167 |
jQuery('#related_svg_map_location').closest('tr').find('label').addClass('wdk_btn_load_indicator out'); |
| 168 |
|
| 169 |
var ajax_param = { |
| 170 |
"action": 'wdk_svg_map_public_action', |
| 171 |
"page": 'wdk_svg_map_frontendajax', |
| 172 |
"function": 'get_map_data', |
| 173 |
}; |
| 174 |
ajax_param['related_svg_map'] = $(this).val(); |
| 175 |
|
| 176 |
// Assign handlers immediately after making the request, |
| 177 |
// and remember the jqxhr object for this request |
| 178 |
if (jqxhr != null) |
| 179 |
jqxhr.abort(); |
| 180 |
|
| 181 |
jqxhr = $.post("<?php echo esc_url(admin_url('admin-ajax.php')); ?>", ajax_param, |
| 182 |
function(data) { |
| 183 |
var select_list = '<option value=""> <?php echo esc_js('Not Selected', 'wpdirectorykit'); ?> </option>'; |
| 184 |
jQuery.each(data.output.locations, function(i, v) { |
| 185 |
select_list += '<option value="' + i + '"> ' + v + ' </option>'; |
| 186 |
}); |
| 187 |
|
| 188 |
jQuery('#related_svg_map_location').html(select_list); |
| 189 |
|
| 190 |
}).always(function(data) { |
| 191 |
jQuery('#related_svg_map_location').closest('tr').find('label').removeClass('wdk_btn_load_indicator out'); |
| 192 |
}); |
| 193 |
return false; |
| 194 |
}) |
| 195 |
}) |
| 196 |
</script> |
| 197 |
|
| 198 |
|
| 199 |
<?php |
| 200 |
wp_enqueue_style('wdk-svg-map'); |
| 201 |
wp_enqueue_style('wdk-geo-map-lib', WDK_SVG_MAP_URL . 'public/css/wdk-geo-map-lib.css', array(), 1.0, 'all'); |
| 202 |
wp_enqueue_script('wdk-geo-map-lib', WDK_SVG_MAP_URL . 'public/js/wdk-geo-map-lib.js', array('jquery'), 1.0, false); |
| 203 |
wp_enqueue_style('dashicons'); |
| 204 |
|
| 205 |
$params = array( |
| 206 |
'ajax_url' => admin_url('admin-ajax.php') |
| 207 |
); |
| 208 |
wp_localize_script('wdk-geo-map-lib', 'wdk_geo_map_script_parameters', $params); |
| 209 |
|
| 210 |
?> |
| 211 |
|
| 212 |
<script> |
| 213 |
jQuery(document).ready(function($) { |
| 214 |
var that = $('.postbox.postbox-map .inside'); |
| 215 |
var geomap = that.find('.wdk_svg_map').WdkSvgMap('set_config', { |
| 216 |
'base_path': '<?php echo esc_js(WDK_SVG_MAP_PACS_URL); ?>', |
| 217 |
'color_hover': '#2271b1', |
| 218 |
'color_active': '#2271b1', |
| 219 |
'color_border_hover': '#2271b1', |
| 220 |
'color_border_active': '#2271b1', |
| 221 |
}); |
| 222 |
|
| 223 |
/* events */ |
| 224 |
geomap.on('map_generated.WdkSvgMap', function(event) { |
| 225 |
var map_back = that.find('.map-back'); |
| 226 |
if (event.tree_maps.length) { |
| 227 |
var names = ''; |
| 228 |
for (let el of event.tree_maps) { |
| 229 |
if (names != '') |
| 230 |
names += ' - '; |
| 231 |
names += el.location_name; |
| 232 |
} |
| 233 |
map_back.find('.name').html(names); |
| 234 |
|
| 235 |
map_back.show().off().on('click', function(e) { |
| 236 |
e.preventDefault(); |
| 237 |
geomap.WdkSvgMap('set_pre_map'); |
| 238 |
}); |
| 239 |
} else { |
| 240 |
map_back.hide(); |
| 241 |
} |
| 242 |
|
| 243 |
var html = ""; |
| 244 |
if (event.locations_list) { |
| 245 |
html += "<ul>" |
| 246 |
jQuery.each(event.locations_list, function(index, value) { |
| 247 |
html += "<li>" + value + "</li>" |
| 248 |
}) |
| 249 |
html += "</ul>" |
| 250 |
} |
| 251 |
|
| 252 |
jQuery('.map-list').html(html); |
| 253 |
|
| 254 |
}); |
| 255 |
|
| 256 |
geomap.WdkSvgMap('generate_map', that.find('.wdk_svg_map').attr('data-map')); |
| 257 |
|
| 258 |
$('#related_svg_map').on('input', function(e) { |
| 259 |
e.preventDefault(); |
| 260 |
|
| 261 |
if ($(this).val() != '' && $(this).val() != 0) { |
| 262 |
jQuery('.postbox.postbox-map').show(); |
| 263 |
} else { |
| 264 |
jQuery('.postbox.postbox-map').hide(); |
| 265 |
} |
| 266 |
|
| 267 |
geomap.WdkSvgMap('generate_map', $(this).val()); |
| 268 |
}); |
| 269 |
|
| 270 |
}); |
| 271 |
</script> |
| 272 |
|
| 273 |
<?php endif;?> |
| 274 |
|
| 275 |
<?php $this->view('general/footer', $data); ?> |