| 1 |
<?php |
| 2 |
$title = $plugin_data['Name']; |
| 3 |
$description = __('A plugin for creating a Leaflet JS map with a shortcode. Boasts two free map tile services and three free geocoders.', 'leaflet-map'); |
| 4 |
$version = $plugin_data['Version']; |
| 5 |
?> |
| 6 |
<div class="wrap"> |
| 7 |
<h1><?php echo $title; ?> <small>version: <?php echo $version; ?></small></h1> |
| 8 |
<p><?php echo $description; ?></p> |
| 9 |
<?php |
| 10 |
if (isset($_POST['submit'])) { |
| 11 |
/* copy and overwrite $post for checkboxes */ |
| 12 |
$form = $_POST; |
| 13 |
|
| 14 |
foreach ($settings->options as $name => $option) { |
| 15 |
if (!$option->type) continue; |
| 16 |
|
| 17 |
/* checkboxes don't get sent if not checked */ |
| 18 |
if ($option->type === 'checkbox') { |
| 19 |
$form[$name] = isset($_POST[ $name ]) ? 1 : 0; |
| 20 |
} |
| 21 |
|
| 22 |
$settings->set($name, stripslashes( $form[$name])); |
| 23 |
} |
| 24 |
?> |
| 25 |
<div class="notice notice-success is-dismissible"> |
| 26 |
<p><?php _e('Options Updated!', 'leaflet-map'); ?></p> |
| 27 |
</div> |
| 28 |
<?php |
| 29 |
} elseif (isset($_POST['reset'])) { |
| 30 |
$settings->reset(); |
| 31 |
?> |
| 32 |
<div class="notice notice-success is-dismissible"> |
| 33 |
<p><?php _e('Options have been reset to default values!', 'leaflet-map'); ?></p> |
| 34 |
</div> |
| 35 |
<?php |
| 36 |
} elseif (isset($_POST['clear-geocoder-cache'])) { |
| 37 |
include_once(LEAFLET_MAP__PLUGIN_DIR . 'class.geocoder.php'); |
| 38 |
Leaflet_Geocoder::remove_caches(); |
| 39 |
?> |
| 40 |
<div class="notice notice-success is-dismissible"> |
| 41 |
<p><?php _e('Location caches have been cleared!', 'leaflet-map'); ?></p> |
| 42 |
</div> |
| 43 |
<?php |
| 44 |
} |
| 45 |
?> |
| 46 |
<div class="wrap"> |
| 47 |
<div class="wrap"> |
| 48 |
<form method="post"> |
| 49 |
<div class="container"> |
| 50 |
<h2><?php _e('Settings', 'leaflet-map'); ?></h2> |
| 51 |
<hr> |
| 52 |
</div> |
| 53 |
<?php |
| 54 |
foreach ($settings->options as $name => $option) { |
| 55 |
if (!$option->type) continue; |
| 56 |
?> |
| 57 |
<div class="container"> |
| 58 |
<label> |
| 59 |
<span class="label"><?php echo $option->display_name; ?></span> |
| 60 |
<span class="input-group"> |
| 61 |
<?php |
| 62 |
$option->widget($name, $settings->get($name)); |
| 63 |
?> |
| 64 |
</span> |
| 65 |
</label> |
| 66 |
|
| 67 |
<?php |
| 68 |
if ($option->helptext) { |
| 69 |
?> |
| 70 |
<div class="helptext"> |
| 71 |
<p class="description"><?php echo $option->helptext; ?></p> |
| 72 |
</div> |
| 73 |
<?php |
| 74 |
} |
| 75 |
?> |
| 76 |
</div> |
| 77 |
<?php |
| 78 |
} |
| 79 |
?> |
| 80 |
<div class="submit"> |
| 81 |
<input type="submit" |
| 82 |
name="submit" |
| 83 |
id="submit" |
| 84 |
class="button button-primary" |
| 85 |
value="<?php _e('Save Changes', 'leaflet-map'); ?>"> |
| 86 |
<input type="submit" |
| 87 |
name="reset" |
| 88 |
id="reset" |
| 89 |
class="button button-secondary" |
| 90 |
value="<?php _e('Reset to Defaults', 'leaflet-map'); ?>"> |
| 91 |
<input type="submit" |
| 92 |
name="clear-geocoder-cache" |
| 93 |
id="clear-geocoder-cache" |
| 94 |
class="button button-secondary" |
| 95 |
value="<?php _e('Clear Geocoder Cache', 'leaflet-map'); ?>"> |
| 96 |
</div> |
| 97 |
|
| 98 |
</form> |
| 99 |
</div> |
| 100 |
</div> |
| 101 |
|