Skip to content

Commit

Permalink
V2.11.1 some cleanup, and OSM nominatum as default
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin J. DeLong committed Jul 17, 2018
1 parent f4c1b36 commit 77c1954
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 20 deletions.
6 changes: 3 additions & 3 deletions class.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ public function admin_menu()
if (current_user_can('manage_options')) {
$main_link = 'leaflet-map';
} else {
$main_link = 'leaflet-get-shortcode';
$main_link = 'leaflet-shortcode-helper';
}

add_menu_page("Leaflet Map", "Leaflet Map", 'manage_options', $main_link, array($this, "settings_page"), plugins_url('images/leaf.png', LEAFLET_MAP__PLUGIN_FILE));
add_submenu_page("leaflet-map", "Default Values", "Default Values", 'manage_options', "leaflet-map", array($this, "settings_page"));
add_submenu_page("leaflet-map", "Shortcode Helper", "Shortcode Helper", 'edit_posts', "leaflet-get-shortcode", array($this, "shortcode_page"));
add_submenu_page("leaflet-map", "Shortcode Helper", "Shortcode Helper", 'edit_posts', "leaflet-shortcode-helper", array($this, "shortcode_page"));
}

/**
Expand All @@ -96,7 +96,7 @@ public function settings_page()
public function shortcode_page()
{
wp_enqueue_style('leaflet_admin_stylesheet');
wp_enqueue_script('custom_plugin_js', plugins_url('scripts/get-shortcode.min.js', LEAFLET_MAP__PLUGIN_FILE), Array('leaflet_js'), false);
wp_enqueue_script('custom_plugin_js', plugins_url('scripts/shortcode-helper.min.js', LEAFLET_MAP__PLUGIN_FILE), Array('leaflet_js'), false);

include 'templates/shortcode-helper.php';
}
Expand Down
17 changes: 9 additions & 8 deletions class.geocoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ private function get_url( $url ) {

curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, get_site_url());
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

Expand Down Expand Up @@ -133,9 +134,9 @@ private function google_geocode ( $address ) {

return (Object) $location;
}
}

return $this->not_found;
}
throw new Exception('No Address Found');
}

/**
Expand All @@ -149,8 +150,8 @@ private function osm_geocode ( $address ) {
$geocode_url = 'https://nominatim.openstreetmap.org/?format=json&limit=1&q=';
$geocode_url .= $address;
$json = $this->get_url($geocode_url);
$json = json_decode($json);

$json = json_decode($json);
if (is_array($json) &&
is_object($json[0]) &&
$json[0]->lat) {
Expand All @@ -161,7 +162,7 @@ private function osm_geocode ( $address ) {
);
}

return $this->not_found;
throw new Exception('No Address Found');
}

/**
Expand Down Expand Up @@ -190,6 +191,6 @@ private function dawa_geocode ( $address ) {
return $location;
}

return $this->not_found;
throw new Exception('No Address Found');
}
}
4 changes: 2 additions & 2 deletions class.plugin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ private function __construct()
),
'geocoder' => array(
'display_name'=>__('Geocoder', 'leaflet-map'),
'default' => 'google',
'default' => 'osm',
'type' => 'select',
'options' => array(
'google' => __('Google Maps', 'leaflet-map'),
'osm' => __('OpenStreetMap Nominatim', 'leaflet-map'),
'google' => __('Google Maps', 'leaflet-map'),
'dawa' => __('Denmark Addresses', 'leaflet-map')
),
'helptext' => __('Select the Geocoding provider to use to retrieve addresses defined in shortcode.', 'leaflet-map')
Expand Down
4 changes: 2 additions & 2 deletions leaflet-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Author URI: https://twitter.com/bozdoz/
* Text Domain: leaflet-map
* Domain Path: /languages/
* Version: 2.11.0
* Version: 2.11.1
* License: GPL2
* Leaflet Map is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -29,7 +29,7 @@
exit;
}

define('LEAFLET_MAP__PLUGIN_VERSION', '2.11.0');
define('LEAFLET_MAP__PLUGIN_VERSION', '2.11.1');
define('LEAFLET_MAP__PLUGIN_FILE', __FILE__);
define('LEAFLET_MAP__PLUGIN_DIR', plugin_dir_path(__FILE__));

Expand Down
10 changes: 7 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Contributors: bozdoz, Remigr, nielsalstrup, jeromelebleu, gerital
Donate link: https://www.paypal.me/bozdoz
Tags: leaflet, map, mobile, javascript, openstreetmap, mapquest, interactive
Requires at least: 3.0.1
Tested up to: 4.9.4
Version: 2.11.0
Stable tag: 2.11.0
Tested up to: 4.9.7
Version: 2.11.1
Stable tag: 2.11.1
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -124,6 +124,10 @@ Yes: use the keyword `attribution` in your shortcode (semi-colon separated list

== Changelog ==

= 2.11.1 =
* Added Dockerfiles to github
* Made OpenStreetMap default geocoder in light of new Google API payment plans

= 2.11.0 =
* Added Popup Anchor for custom markers
* Added SVG Markers
Expand Down
1 change: 0 additions & 1 deletion scripts/get-shortcode.min.js

This file was deleted.

9 changes: 8 additions & 1 deletion scripts/get-shortcode.js → scripts/shortcode-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@
}

function update_map () {
var latlng = map_1.getCenter();
var bounds = map_1.getBounds();
var latlng = bounds.getCenter();
map_input.value = '[leaflet-map lat=' +
latlng.lat +
' lng=' +
latlng.lng +
' zoom=' +
map_1.getZoom() +
']';

// update marker if outside of bounds
if (!bounds.contains(marker_1.getLatLng())) {
// move marker to center
marker_1.setLatLng(latlng);
}
}

marker_1.on('drag', update_marker);
Expand Down
1 change: 1 addition & 0 deletions scripts/shortcode-helper.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 77c1954

Please sign in to comment.