| 1 |
<?php |
| 2 |
// Ensure no whitespace or output before this tag! |
| 3 |
|
| 4 |
if (!defined('ABSPATH')) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
/* Plugin-prefixed global name */ |
| 8 |
/* Plugin-prefixed global name */ |
| 9 |
$gmap_embed_admin_messages_group = 'wgm_messages'; |
| 10 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only used for displaying a message based on URL parameter. |
| 11 |
if (isset($_GET['settings-updated'])) { |
| 12 |
// add settings saved message with the class of "updated" |
| 13 |
add_settings_error($gmap_embed_admin_messages_group, 'wgm_message', __('Settings updated successfully.', 'gmap-embed'), 'updated'); |
| 14 |
} |
| 15 |
settings_errors($gmap_embed_admin_messages_group); |
| 16 |
/* Plugin-prefixed global name */ |
| 17 |
$gmap_embed_admin_settings_nonce = wp_create_nonce('wgm_settings'); |
| 18 |
$gmap_embed_admin_api_base_url = esc_url('https://wpgooglemap.com'); |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
// Updating api key |
| 23 |
|
| 24 |
|
| 25 |
// Messages are handled via wgm_messages_viewer.php and redirect parameters. |
| 26 |
$gmap_embed_admin_settings_nonce = wp_create_nonce('wgm_settings'); |
| 27 |
$gmap_embed_admin_api_base_url = esc_url('https://wpgooglemap.com'); |
| 28 |
?> |
| 29 |
<div class="wrap"> |
| 30 |
<h1 class="wp-heading-inline"><?php esc_html_e('Settings', 'gmap-embed'); ?></h1> |
| 31 |
<?php |
| 32 |
if (!_wgm_is_premium()) { |
| 33 |
echo '<a target="_blank" href="' . esc_url('https://wpgooglemap.com/pricing?utm_source=gmap-embed&utm_medium=wordpress-plugin&utm_campaign=upgrade-to-pro&utm_content=settings-page-header-upgrade-btn') . '" class="button wgm_btn" style="float:right;width:auto;padding: 5px 7px;font-size: 11px;margin-left:5px;"><i style="line-height: 25px;" class="dashicons dashicons-star-filled"></i> ' . esc_html__('Upgrade ($19 only)', 'gmap-embed') . '</a>'; |
| 34 |
} |
| 35 |
echo '<a target="_blank" href="' . esc_url('https://tawk.to/chat/6083e29962662a09efc1acd5/1f41iqarp') . '" class="button wgm_btn" style="float:right;width:auto;padding: 5px 7px;font-size: 11px;margin-right:5px;background-color: #cb5757 !important;color: white !important;"><i style="line-height: 28px;" class="dashicons dashicons-format-chat"></i> ' . esc_html__('LIVE Chat', 'gmap-embed') . '</a>'; |
| 36 |
echo '<a href="' . esc_url(admin_url('admin.php?page=wpgmapembed-support')) . '" class="button wgm_btn" style="float:right;width:auto;padding: 5px 7px;font-size: 11px;margin-right:5px;"><i style="line-height: 25px;" class="dashicons dashicons-editor-help"></i> ' . esc_html__('Documentation', 'gmap-embed') . '</a>'; |
| 37 |
?> |
| 38 |
<hr class="wp-header-end"> |
| 39 |
<!--Settings Tabs--> |
| 40 |
<div class="wgm-settings-menu"> |
| 41 |
<ul> |
| 42 |
<li class="active" data-tab="wgm_general_settings"><a href="#wgm_general_settings">General Settings</a></li> |
| 43 |
<li data-tab="wgm_advanced_settings"><a href="#wgm_advanced_settings">Advanced Settings</a></li> |
| 44 |
<li data-tab="wgm_export_settings"><a href="#wgm_export_settings">Export</a></li> |
| 45 |
<li data-tab="wgm_import_settings"><a href="#wgm_import_settings">Import</a></li> |
| 46 |
<li data-tab="wgm_marker_settings"><a href="#wgm_marker_settings">Marker Settings</a></li> |
| 47 |
</ul> |
| 48 |
</div> |
| 49 |
<div id="gmap_container_inner" style="margin-top: 0;border-top: none;"> |
| 50 |
<?php require_once WGM_PLUGIN_PATH . 'admin/includes/wgm_messages_viewer.php'; ?> |
| 51 |
<div class="wgm_settings_tabs" id="wgm_general_settings" style="display: block;padding: 20px 25px 25px 25px;"> |
| 52 |
<div class="wpgmapembed_get_api_key"> |
| 53 |
<h2><?php esc_html_e('API Key and License Information', 'gmap-embed'); ?></h2> |
| 54 |
<hr /> |
| 55 |
<table class="form-table" role="presentation"> |
| 56 |
|
| 57 |
<tbody> |
| 58 |
<form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>"> |
| 59 |
<input type="hidden" name="action" value="wgm_save_api_key" /> |
| 60 |
<?php wp_nonce_field('wgm_settings_api_key_update', '_wp_nonce'); ?> |
| 61 |
<tr> |
| 62 |
<th scope="row"> |
| 63 |
<label for="wpgmapembed_key"> |
| 64 |
<?php esc_html_e('Enter API Key: ', 'gmap-embed'); ?> |
| 65 |
</label> |
| 66 |
</th> |
| 67 |
<td scope="row"> |
| 68 |
<input type="text" name="wpgmapembed_key" |
| 69 |
value="<?php echo esc_html(get_option('wpgmap_api_key')); ?>" size="45" |
| 70 |
class="regular-text" style="width:100%" id="wpgmapembed_key" /> |
| 71 |
<p class="description" id="tagline-description" style="font-style: italic;"> |
| 72 |
<?php esc_html_e('The API key may take up to 5 minutes to take effect', 'gmap-embed'); ?> |
| 73 |
</p> |
| 74 |
</td> |
| 75 |
<td width="30%" style="vertical-align: top;"> |
| 76 |
<button class="button wgm_btn" |
| 77 |
style="padding: 4px 10px;font-size: 11px;margin-right:5px;width: auto;"><i |
| 78 |
class="dashicons dashicons-update-alt" style="line-height: 23px;"></i> |
| 79 |
<?php esc_html_e('Update', 'gmap-embed'); ?> |
| 80 |
</button> |
| 81 |
|
| 82 |
<a style="margin-left: 5px;" title="Go to Quick Setup Wizard to get an API key" |
| 83 |
href=" |
| 84 |
<?php echo esc_url(admin_url() . 'admin.php?page=wgm_setup_wizard'); ?>" |
| 85 |
class="button media-button button-default button-large"><i |
| 86 |
class="dashicons dashicons-controls-forward" style="line-height: 30px;"></i> |
| 87 |
<?php esc_html_e('Go to Quick Setup', 'gmap-embed'); ?> |
| 88 |
</a> |
| 89 |
</td> |
| 90 |
</tr> |
| 91 |
</form> |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
<form method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>"> |
| 96 |
<input type="hidden" name="action" value="wgm_save_license" /> |
| 97 |
<?php wp_nonce_field('wgm_settings_lc_key_update', '_wp_nonce'); ?> |
| 98 |
<tr> |
| 99 |
<th scope="row"> |
| 100 |
<label for="wpgmapembed_license"> |
| 101 |
<?php esc_html_e('License Key: ', 'gmap-embed'); ?> |
| 102 |
</label> |
| 103 |
</th> |
| 104 |
<td scope="row"> |
| 105 |
<input type="text" name="wpgmapembed_license" |
| 106 |
value="<?php echo esc_html(get_option('wpgmapembed_license')); ?>" size="45" |
| 107 |
class="regular-text" style="width:100%" id="wpgmapembed_license" /> |
| 108 |
<p class="description" id="tagline-description" style="font-style: italic;"> |
| 109 |
<?php esc_html_e('After payment you will get an email with license key', 'gmap-embed'); ?> |
| 110 |
</p> |
| 111 |
</td> |
| 112 |
<td width="30%" style="vertical-align: top;"> |
| 113 |
<button class="button wgm_btn" |
| 114 |
style="padding: 4px 10px;font-size: 11px;margin-right:5px;width: auto;"><i |
| 115 |
class="dashicons dashicons-yes-alt" style="line-height: 23px;"></i> |
| 116 |
<?php esc_html_e('Validate', 'gmap-embed'); ?> |
| 117 |
</button> |
| 118 |
|
| 119 |
<?php |
| 120 |
if (strlen(trim(get_option('wpgmapembed_license'))) !== 32) { |
| 121 |
?> |
| 122 |
<a target="_blank" |
| 123 |
href="<?php echo esc_url('https://wpgooglemap.com/pricing?utm_source=gmap-embed&utm_medium=wordpress-plugin&utm_campaign=upgrade-to-pro&utm_content=settings-license-tab'); ?>" |
| 124 |
class="button media-button button-default button-large"><?php esc_html_e('GET LICENSE KEY', 'gmap-embed'); ?></a> |
| 125 |
<?php |
| 126 |
} |
| 127 |
?> |
| 128 |
</td> |
| 129 |
</tr> |
| 130 |
</form> |
| 131 |
</tbody> |
| 132 |
</table> |
| 133 |
</div> |
| 134 |
<div data-columns="8"> |
| 135 |
<form method="POST" action="options.php"> |
| 136 |
<div class="wpgmap_lng_custom_script_settings"> |
| 137 |
<?php |
| 138 |
settings_fields('wpgmap_general_settings'); |
| 139 |
do_settings_sections('gmap-embed-settings-page-ls'); |
| 140 |
do_settings_sections('gmap-embed-settings-page-cs'); |
| 141 |
do_settings_sections('gmap-embed-general-settings'); |
| 142 |
submit_button(); |
| 143 |
?> |
| 144 |
</div> |
| 145 |
</form> |
| 146 |
</div> |
| 147 |
</div> |
| 148 |
<div class="wgm_settings_tabs" id="wgm_advanced_settings" style="display: none;padding: 20px 25px 25px 25px;"> |
| 149 |
<form method="POST" action="options.php"> |
| 150 |
<div class="wpgmap_lng_custom_script_settings"> |
| 151 |
<?php |
| 152 |
settings_fields('wgm_advance_settings'); |
| 153 |
do_settings_sections('wgm_advance_settings-page'); |
| 154 |
submit_button(); |
| 155 |
?> |
| 156 |
</div> |
| 157 |
</form> |
| 158 |
</div> |
| 159 |
<div class="wgm_settings_tabs" id="wgm_marker_settings" style="display: none;padding: 20px 25px 25px 25px;"> |
| 160 |
<form method="POST" action="options.php"> |
| 161 |
<div class="wpgmap_lng_custom_script_settings"> |
| 162 |
<?php |
| 163 |
settings_fields('wgm_marker_settings'); |
| 164 |
do_settings_sections('wgm_marker_settings-page'); |
| 165 |
submit_button(); |
| 166 |
?> |
| 167 |
</div> |
| 168 |
</form> |
| 169 |
</div> |
| 170 |
|
| 171 |
<div class="wgm_settings_tabs" id="wgm_export_settings" style="display: none; padding: 20px 25px 25px 25px; position: relative;"> |
| 172 |
<?php if (!_wgm_is_premium()) : ?> |
| 173 |
<!-- Pro Upgrade Banner for Export --> |
| 174 |
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 15px 20px; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); border-left: 5px solid #ffd700; position: relative; z-index: 100;"> |
| 175 |
<div style="display: flex; align-items: center; gap: 15px;"> |
| 176 |
<span class="dashicons dashicons-star-filled" style="font-size: 28px; color: #ffd700; width: 28px; height: 28px;"></span> |
| 177 |
<div style="flex: 1;"> |
| 178 |
<h3 style="margin: 0 0 5px 0; color: white; font-size: 16px;"><?php esc_html_e('Unlock Export Feature (Premium)', 'gmap-embed'); ?></h3> |
| 179 |
<p style="margin: 0; font-size: 13px; opacity: 0.95; line-height: 1.4;"> |
| 180 |
<?php esc_html_e('Export your maps and markers to JSON or CSV/Excel for backups or migration. Upgrade now to unlock this feature.', 'gmap-embed'); ?> |
| 181 |
</p> |
| 182 |
</div> |
| 183 |
<a href="<?php echo esc_url('https://wpgooglemap.com/pricing?utm_source=gmap-embed&utm_medium=wordpress-plugin&utm_campaign=upgrade-to-pro&utm_content=settings-export-tab'); ?>" target="_blank" class="button" style="background: #ffd700; color: #764ba2; border: none; padding: 8px 16px; font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.2); height: auto; border-radius: 4px;"><?php esc_html_e('Upgrade Now', 'gmap-embed'); ?></a> |
| 184 |
</div> |
| 185 |
</div> |
| 186 |
<?php endif; ?> |
| 187 |
|
| 188 |
<form method="post" action="<?php echo esc_url(admin_url('admin-post.php?action=wgm_export')); ?>" class="<?php echo !_wgm_is_premium() ? 'wgm-locked-feature' : ''; ?>"> |
| 189 |
<?php wp_nonce_field('wgm_export_nonce', '_wgm_export_nonce'); ?> |
| 190 |
<!-- removed hidden wgm_export_action input because admin-post action handles it --> |
| 191 |
|
| 192 |
<table class="form-table" role="presentation"> |
| 193 |
<tbody> |
| 194 |
<tr> |
| 195 |
<th scope="row"><?php esc_html_e('Export format', 'gmap-embed'); ?></th> |
| 196 |
<td> |
| 197 |
<?php |
| 198 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Non-sensitive initialization of view variable. |
| 199 |
$gmap_embed_admin_export_type = isset($_REQUEST['wgm_export_type']) ? sanitize_text_field(wp_unslash($_REQUEST['wgm_export_type'])) : 'csv'; |
| 200 |
?> |
| 201 |
<select name="wgm_export_type" id="wgm_export_type" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?>> |
| 202 |
<option value="csv" <?php selected($gmap_embed_admin_export_type, 'csv'); ?>>CSV</option> |
| 203 |
<option value="json" <?php selected($gmap_embed_admin_export_type, 'json'); ?>>JSON |
| 204 |
</option> |
| 205 |
</select> |
| 206 |
<p class="description"> |
| 207 |
<?php esc_html_e('Choose the file format to download.', 'gmap-embed'); ?> |
| 208 |
</p> |
| 209 |
</td> |
| 210 |
</tr> |
| 211 |
|
| 212 |
<tr> |
| 213 |
<th scope="row"><?php esc_html_e('Data type', 'gmap-embed'); ?></th> |
| 214 |
<td> |
| 215 |
<?php |
| 216 |
// Determine defaults / incoming selections |
| 217 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Non-sensitive initialization of view variable. |
| 218 |
$gmap_embed_admin_csv_choice = isset($_REQUEST['wgm_export_data']) ? sanitize_text_field(wp_unslash($_REQUEST['wgm_export_data'])) : 'markers'; |
| 219 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Non-sensitive initialization of view variable. |
| 220 |
$gmap_embed_admin_json_choices = isset($_REQUEST['wgm_export_data_types']) && is_array($_REQUEST['wgm_export_data_types']) ? array_map('sanitize_text_field', wp_unslash($_REQUEST['wgm_export_data_types'])) : array('markers'); |
| 221 |
// Available options |
| 222 |
$gmap_embed_admin_export_options = array( |
| 223 |
'markers' => __('Markers', 'gmap-embed'), |
| 224 |
'categories' => __('Categories', 'gmap-embed'), |
| 225 |
); |
| 226 |
?> |
| 227 |
<!-- CSV / single-select control --> |
| 228 |
<div id="wgm_export_data_csv" style="display: none;"> |
| 229 |
<select name="wgm_export_data_type" id="wgm_export_data" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?>> |
| 230 |
<?php foreach ($gmap_embed_admin_export_options as $gmap_embed_admin_val => $gmap_embed_admin_label): ?> |
| 231 |
<option value="<?php echo esc_attr($gmap_embed_admin_val); ?>" <?php selected($gmap_embed_admin_csv_choice, $gmap_embed_admin_val); ?>> |
| 232 |
<?php echo esc_html($gmap_embed_admin_label); ?> |
| 233 |
</option> |
| 234 |
<?php endforeach; ?> |
| 235 |
</select> |
| 236 |
<p class="description"> |
| 237 |
<?php esc_html_e('For CSV/Excel choose a single data type to export.', 'gmap-embed'); ?> |
| 238 |
</p> |
| 239 |
</div> |
| 240 |
|
| 241 |
<!-- JSON / multi-checkbox control --> |
| 242 |
<div id="wgm_export_data_json" style="display: none;"> |
| 243 |
<?php foreach ($gmap_embed_admin_export_options as $gmap_embed_admin_val => $gmap_embed_admin_label): ?> |
| 244 |
<label style="display:block;margin-bottom:4px;"> |
| 245 |
<input type="checkbox" name="wgm_export_data_types[]" |
| 246 |
value="<?php echo esc_attr($gmap_embed_admin_val); ?>" <?php checked(in_array($gmap_embed_admin_val, $gmap_embed_admin_json_choices, true)); ?> <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?> /> |
| 247 |
<?php echo esc_html($gmap_embed_admin_label); ?> |
| 248 |
</label> |
| 249 |
<?php endforeach; ?> |
| 250 |
<p class="description"> |
| 251 |
<?php esc_html_e('For JSON you may select one or more data types to include.', 'gmap-embed'); ?> |
| 252 |
</p> |
| 253 |
</div> |
| 254 |
|
| 255 |
</td> |
| 256 |
</tr> |
| 257 |
<tr class="wgm_maps_select_row"> |
| 258 |
<th scope="row"><?php esc_html_e('Select maps', 'gmap-embed'); ?></th> |
| 259 |
<td> |
| 260 |
<?php |
| 261 |
// Try to list maps for selection (best-effort) |
| 262 |
$gmap_embed_admin_select_maps = array(); |
| 263 |
$gmap_embed_admin_post_type = 'wpgmapembed'; |
| 264 |
$gmap_embed_admin_found = get_posts(array('post_type' => $gmap_embed_admin_post_type, 'post_status' => 'any', 'numberposts' => -1)); |
| 265 |
if (!empty($gmap_embed_admin_found)) { |
| 266 |
foreach ($gmap_embed_admin_found as $gmap_embed_admin_p) { |
| 267 |
// prefer stored meta title if present, otherwise post_title |
| 268 |
$gmap_embed_admin_title = get_post_meta($gmap_embed_admin_p->ID, 'wpgmap_title', true); |
| 269 |
if (empty($gmap_embed_admin_title)) { |
| 270 |
$gmap_embed_admin_title = $gmap_embed_admin_p->post_title; |
| 271 |
} |
| 272 |
$gmap_embed_admin_select_maps[$gmap_embed_admin_p->ID] = $gmap_embed_admin_title; |
| 273 |
} |
| 274 |
} |
| 275 |
if (!empty($gmap_embed_admin_select_maps)) { |
| 276 |
// Top controls |
| 277 |
?> |
| 278 |
<div style="margin-bottom:6px;"> |
| 279 |
<input type="text" id="wgm_map_search" |
| 280 |
placeholder="<?php esc_attr_e('Search maps...', 'gmap-embed'); ?>" |
| 281 |
style="width:300px;padding:6px;margin-right:8px;" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?> /> |
| 282 |
<button type="button" id="wgm_select_all" |
| 283 |
class="button" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?>><?php esc_html_e('Select All', 'gmap-embed'); ?></button> |
| 284 |
<button type="button" id="wgm_select_none" |
| 285 |
class="button" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?>><?php esc_html_e('Select None', 'gmap-embed'); ?></button> |
| 286 |
</div> |
| 287 |
|
| 288 |
<div class="wgm-map-list" |
| 289 |
style="border:1px solid #ddd;padding:8px;max-height:260px;overflow:auto;background:#fff;"> |
| 290 |
<?php |
| 291 |
foreach ($gmap_embed_admin_select_maps as $gmap_embed_admin_id => $gmap_embed_admin_title_val) { |
| 292 |
$gmap_embed_admin_escaped_id = esc_attr($gmap_embed_admin_id); |
| 293 |
$gmap_embed_admin_escaped_title = esc_html($gmap_embed_admin_title_val); |
| 294 |
echo '<div class="wgm-map-item" style="padding:4px 2px;border-bottom:1px solid #f1f1f1;">'; |
| 295 |
echo '<label style="cursor:pointer;"><input type="checkbox" name="wgm_maps[]" value="' . esc_attr($gmap_embed_admin_id) . '" style="margin-right:8px;" ' . (!_wgm_is_premium() ? 'disabled="disabled"' : '') . ' />' . esc_html($gmap_embed_admin_title_val) . '</label>'; |
| 296 |
echo '</div>'; |
| 297 |
} |
| 298 |
?> |
| 299 |
</div> |
| 300 |
|
| 301 |
<!-- Bottom controls for convenience --> |
| 302 |
<div style="margin-top:6px;"> |
| 303 |
<button type="button" id="wgm_select_all_bottom" |
| 304 |
class="button" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?>><?php esc_html_e('Select All', 'gmap-embed'); ?></button> |
| 305 |
<button type="button" id="wgm_select_none_bottom" |
| 306 |
class="button" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?>><?php esc_html_e('Select None', 'gmap-embed'); ?></button> |
| 307 |
</div> |
| 308 |
|
| 309 |
|
| 310 |
<?php |
| 311 |
} else { |
| 312 |
echo '<em>' . esc_html__('No maps found to select. Export "All maps" instead or create maps first.', 'gmap-embed') . '</em>'; |
| 313 |
} |
| 314 |
?> |
| 315 |
</td> |
| 316 |
</tr> |
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
<tr> |
| 321 |
<th scope="row"></th> |
| 322 |
<td> |
| 323 |
<button type="submit" |
| 324 |
class="button button-primary" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?>><?php esc_html_e('Export', 'gmap-embed'); ?></button> |
| 325 |
</td> |
| 326 |
</tr> |
| 327 |
</tbody> |
| 328 |
</table> |
| 329 |
</form> |
| 330 |
<?php if (!_wgm_is_premium()) : ?> |
| 331 |
<div class="wgm-lock-overlay" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.2); backdrop-filter: blur(1.1px); border-radius: inherit; z-index: 10;"> |
| 332 |
<span class="dashicons dashicons-lock" style="font-size: 50px; color: #764ba2; width: 50px; height: 50px; opacity: 0.6;"></span> |
| 333 |
</div> |
| 334 |
<?php endif; ?> |
| 335 |
</div> |
| 336 |
<div class="wgm_settings_tabs" id="wgm_import_settings" style="display: none; padding: 20px 25px 25px 25px; position: relative;"> |
| 337 |
<h2><?php esc_html_e('Import', 'gmap-embed'); ?></h2> |
| 338 |
|
| 339 |
<?php if (!_wgm_is_premium()) : ?> |
| 340 |
<!-- Pro Upgrade Banner for Import --> |
| 341 |
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 15px 20px; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); border-left: 5px solid #ffd700; position: relative; z-index: 100;"> |
| 342 |
<div style="display: flex; align-items: center; gap: 15px;"> |
| 343 |
<span class="dashicons dashicons-star-filled" style="font-size: 28px; color: #ffd700; width: 28px; height: 28px;"></span> |
| 344 |
<div style="flex: 1;"> |
| 345 |
<h3 style="margin: 0 0 5px 0; color: white; font-size: 16px;"><?php esc_html_e('Unlock Import Feature (Premium)', 'gmap-embed'); ?></h3> |
| 346 |
<p style="margin: 0; font-size: 13px; opacity: 0.95; line-height: 1.4;"> |
| 347 |
<?php esc_html_e('Easily import markers and maps from other plugins or your own backups via JSON or CSV. Upgrade now to unlock this feature.', 'gmap-embed'); ?> |
| 348 |
</p> |
| 349 |
</div> |
| 350 |
<a href="<?php echo esc_url('https://wpgooglemap.com/pricing?utm_source=gmap-embed&utm_medium=wordpress-plugin&utm_campaign=upgrade-to-pro&utm_content=settings-import-tab'); ?>" target="_blank" class="button" style="background: #ffd700; color: #764ba2; border: none; padding: 8px 16px; font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.2); height: auto; border-radius: 4px;"><?php esc_html_e('Upgrade Now', 'gmap-embed'); ?></a> |
| 351 |
</div> |
| 352 |
</div> |
| 353 |
<?php endif; ?> |
| 354 |
|
| 355 |
<p class="description"> |
| 356 |
<?php esc_html_e('Import maps or markers from a JSON or CSV file. Choose how to merge data and select a target map if applicable.', 'gmap-embed'); ?> |
| 357 |
</p> |
| 358 |
|
| 359 |
<?php |
| 360 |
?> |
| 361 |
|
| 362 |
<form method="post" action="<?php echo esc_url(admin_url('admin-post.php?action=wgm_import')); ?>" |
| 363 |
enctype="multipart/form-data" class="<?php echo !_wgm_is_premium() ? 'wgm-locked-feature' : ''; ?>"> |
| 364 |
<?php wp_nonce_field('wgm_import_nonce', '_wgm_import_nonce'); ?> |
| 365 |
|
| 366 |
<table class="form-table" role="presentation"> |
| 367 |
<tbody> |
| 368 |
<tr> |
| 369 |
<th scope="row"><?php esc_html_e('File type', 'gmap-embed'); ?></th> |
| 370 |
<td> |
| 371 |
<select name="wgm_import_type" id="wgm_import_type" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?>> |
| 372 |
<option value=""><?php esc_html_e('-- Select --', 'gmap-embed'); ?></option> |
| 373 |
<option value="json">JSON</option> |
| 374 |
<option value="csv">CSV</option> |
| 375 |
</select> |
| 376 |
<p class="description"> |
| 377 |
<?php esc_html_e('Select the format of the file you will upload.', 'gmap-embed'); ?> |
| 378 |
</p> |
| 379 |
</td> |
| 380 |
</tr> |
| 381 |
|
| 382 |
<tr id="wgm_import_data_type_row" style="display:none;"> |
| 383 |
<th scope="row"><?php esc_html_e('CSV data type', 'gmap-embed'); ?></th> |
| 384 |
<td> |
| 385 |
<select name="wgm_import_data_type" id="wgm_import_data_type" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?>> |
| 386 |
<option value=""><?php esc_html_e('-- Select --', 'gmap-embed'); ?></option> |
| 387 |
<option value="markers"><?php esc_html_e('Markers', 'gmap-embed'); ?></option> |
| 388 |
<option value="categories"><?php esc_html_e('Categories', 'gmap-embed'); ?></option> |
| 389 |
</select> |
| 390 |
<p class="description"> |
| 391 |
<?php esc_html_e('When importing CSV, choose whether the file contains maps, markers, or categories.', 'gmap-embed'); ?> |
| 392 |
</p> |
| 393 |
</td> |
| 394 |
</tr> |
| 395 |
|
| 396 |
<tr id="wgm_upload_row" style="display:none;"> |
| 397 |
<th scope="row"><?php esc_html_e('Upload file', 'gmap-embed'); ?></th> |
| 398 |
<td> |
| 399 |
<input type="file" name="wgm_import_file" id="wgm_import_file" |
| 400 |
accept=".json,text/json,.csv,text/csv" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?> /> |
| 401 |
<p class="description"> |
| 402 |
<?php esc_html_e('Choose a .json or .csv file exported from this plugin (or compatible format). Files larger than your PHP upload limit will fail.', 'gmap-embed'); ?> |
| 403 |
</p> |
| 404 |
<p class="description" id="wgm_sample_link_container" style="display:none;"> |
| 405 |
<!-- Dynamic sample link will be inserted here by JS --> |
| 406 |
</p> |
| 407 |
<!-- Preview and mapping UI --> |
| 408 |
<input type="hidden" name="wgm_import_mapping" id="wgm_import_mapping" value="" /> |
| 409 |
<div id="wgm_import_preview" style="margin-top:12px; width:0; min-width:100%; overflow-x:auto;"></div> |
| 410 |
</td> |
| 411 |
</tr> |
| 412 |
|
| 413 |
<tr> |
| 414 |
<th scope="row"><?php esc_html_e('Import mode', 'gmap-embed'); ?></th> |
| 415 |
<td> |
| 416 |
<label><input type="radio" name="wgm_import_mode" value="merge" checked <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?> /> |
| 417 |
<?php esc_html_e('Merge with existing', 'gmap-embed'); ?></label><br /> |
| 418 |
<label><input type="radio" name="wgm_import_mode" value="replace" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?> /> |
| 419 |
<?php esc_html_e('Replace existing (destructive)', 'gmap-embed'); ?></label> |
| 420 |
<p class="description"> |
| 421 |
<?php esc_html_e('Merge will add records and update where applicable. Replace will remove existing items of the selected type first.', 'gmap-embed'); ?> |
| 422 |
</p> |
| 423 |
</td> |
| 424 |
</tr> |
| 425 |
|
| 426 |
<tr id="wgm_import_target_row"> |
| 427 |
<th scope="row"><?php esc_html_e('Target map', 'gmap-embed'); ?></th> |
| 428 |
<td> |
| 429 |
<label style="display:block;"><input type="radio" name="wgm_import_target" value="new" |
| 430 |
checked <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?> /> |
| 431 |
<?php esc_html_e('Create new map from import (when applicable)', 'gmap-embed'); ?></label> |
| 432 |
<label style="display:block;"><input type="radio" name="wgm_import_target" |
| 433 |
value="existing" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?> /> |
| 434 |
<?php esc_html_e('Import into an existing map', 'gmap-embed'); ?></label> |
| 435 |
|
| 436 |
<div id="wgm_import_existing_maps" |
| 437 |
style="margin-top:8px;display:none;border:1px solid #eee;padding:8px;max-height:200px;overflow:auto;background:#fff;"> |
| 438 |
<?php |
| 439 |
$gmap_embed_admin_maps_for_import = get_posts(array( |
| 440 |
'post_type' => 'wpgmapembed', |
| 441 |
'post_status' => 'any', |
| 442 |
'numberposts' => -1, |
| 443 |
)); |
| 444 |
if (!empty($gmap_embed_admin_maps_for_import)) { |
| 445 |
foreach ($gmap_embed_admin_maps_for_import as $gmap_embed_admin_m) { |
| 446 |
$gmap_embed_admin_label = get_post_meta($gmap_embed_admin_m->ID, 'wpgmap_title', true); |
| 447 |
if (empty($gmap_embed_admin_label)) { |
| 448 |
$gmap_embed_admin_label = $gmap_embed_admin_m->post_title; |
| 449 |
} |
| 450 |
echo '<label style="display:block;padding:4px 0;"><input type="radio" name="wgm_target_map_id" value="' . esc_attr($gmap_embed_admin_m->ID) . '" ' . (!_wgm_is_premium() ? 'disabled="disabled"' : '') . ' /> ' . esc_html($gmap_embed_admin_label) . '</label>'; |
| 451 |
} |
| 452 |
} else { |
| 453 |
echo '<em>' . esc_html__('No existing maps found. A new map will be created.', 'gmap-embed') . '</em>'; |
| 454 |
} |
| 455 |
?> |
| 456 |
</div> |
| 457 |
<p class="description"> |
| 458 |
<?php esc_html_e('Choose whether to create a new map or import into one of your existing maps (if applicable to the file).', 'gmap-embed'); ?> |
| 459 |
</p> |
| 460 |
</td> |
| 461 |
</tr> |
| 462 |
|
| 463 |
<tr> |
| 464 |
<th scope="row"><?php esc_html_e('Preview & options', 'gmap-embed'); ?></th> |
| 465 |
<td> |
| 466 |
<label><input type="checkbox" name="wgm_import_dry_run" value="1" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?> /> |
| 467 |
<?php esc_html_e('Dry run (validate file, do not write)', 'gmap-embed'); ?></label> |
| 468 |
<p class="description"> |
| 469 |
<?php esc_html_e('When enabled the import will be validated and a report returned instead of making changes.', 'gmap-embed'); ?> |
| 470 |
</p> |
| 471 |
</td> |
| 472 |
</tr> |
| 473 |
|
| 474 |
<tr> |
| 475 |
<td> |
| 476 |
<button type="submit" |
| 477 |
class="button button-primary" <?php echo !_wgm_is_premium() ? 'disabled="disabled"' : ''; ?>><?php esc_html_e('Import', 'gmap-embed'); ?></button> |
| 478 |
</td> |
| 479 |
</tr> |
| 480 |
</tbody> |
| 481 |
</table> |
| 482 |
</form> |
| 483 |
<?php if (!_wgm_is_premium()) : ?> |
| 484 |
<div class="wgm-lock-overlay" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.2); backdrop-filter: blur(1.1px); border-radius: inherit; z-index: 10;"> |
| 485 |
<span class="dashicons dashicons-lock" style="font-size: 50px; color: #764ba2; width: 50px; height: 50px; opacity: 0.6;"></span> |
| 486 |
</div> |
| 487 |
<?php endif; ?> |
| 488 |
|
| 489 |
</div> |
| 490 |
</div> |
| 491 |
</div> |