diff --git a/README.md b/README.md index 0d12009..10040d2 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Simple Location # **Contributors:** dshanske **Tags:** location, indieweb -**Stable tag:** 2.0.3 +**Stable tag:** 2.1.0 **Requires at least:** 4.0 **Tested up to:** 4.2 **License:** GPLv2 or later @@ -38,6 +38,10 @@ used to store geodata about a post. ## Changelog ## +### Version 2.1.0 ### + * Revamp in Text Display Parameters, now offering three levels of Detail + * Coordinates will now display and Location will link to map if set for full address + ### Version 2.0.3 ### * Google Static Maps now link to Google Maps * Nominatim now defaultly tries to retrieve in the language of the blog diff --git a/includes/class-google-map-static.php b/includes/class-google-map-static.php index dbf6208..06cfbdc 100644 --- a/includes/class-google-map-static.php +++ b/includes/class-google-map-static.php @@ -1,7 +1,7 @@ '; return $c; } - public function the_map($lat, $lon, $height=300, $width=300, $zoom=14) { + public static function the_map($lat, $lon, $height=300, $width=300, $zoom=14) { echo self::get_the_map($lat, $lon, $height, $width, $zoom); } } diff --git a/includes/class-loc-postmeta.php b/includes/class-loc-postmeta.php index 859dce3..ae6bed3 100755 --- a/includes/class-loc-postmeta.php +++ b/includes/class-loc-postmeta.php @@ -67,12 +67,15 @@ public static function location_metabox( $object, $box ) { ?>

- ID, 'geo_public', true ), "1" ); ?>" /> + ID, 'geo_public', true ); ?> + - - ID, 'geo_full', true ), "1" ); ?>" /> - - + ID, 'geo_map', true ), "1" ); ?>" />

@@ -121,35 +124,22 @@ public static function address_metabox( $object, $box ) { ID, 'geo_lookup', true ), "1" ); ?>" />
- -
- + + " size="30" /> + + " size="30" />

-

- -
- " size="70" /> -

-

- -
- " size="70" /> -

-

+ + " size="30" /> -
- " size="70" /> + " size="30" />

-
- " size="70" /> -

-

+ " size="30" /> -
- " size="70" /> + " size="30" />

reverse_lookup($_POST['geo_latitude'], $_POST['geo_longitude']); update_post_meta( $post_id, 'mf2_adr', $reverse_adr ); } update_post_meta($post_id, 'geo_lookup', 0); diff --git a/includes/class-loc-view.php b/includes/class-loc-view.php index 17b8ed4..5f075b0 100755 --- a/includes/class-loc-view.php +++ b/includes/class-loc-view.php @@ -17,7 +17,6 @@ public static function get_the_geodata($id = false) { $loc['public'] = get_post_meta( $id, 'geo_public', true ); $loc['address'] = get_post_meta( $id, 'geo_address', true ); $loc['map'] = get_post_meta( $id, 'geo_map', true ); - $loc['full'] = get_post_meta( $id, 'geo_full', true ); if ($address!=false) { $loc['adr'] = array_pop($address); } @@ -25,15 +24,52 @@ public static function get_the_geodata($id = false) { } public static function get_location($id = false) { $loc = self::get_the_geodata($id); - if($loc['public']!='1') { + $map = new google_map_static(); + if( isset ($loc['adr']) ) { + $adr = $loc['adr']; + } + else { + $adr = array(); + } + $final = array(); + if($loc['public']==0) { return ""; } - if($loc['full']!='1') { - return self::get_the_adr($loc['adr']); + $c = ''; + if( isset($adr['name']) ) { + $final[] = '' . $adr['name'] . ''; + } + if ($loc['public']==3) { + if( isset($adr['street-address']) ) { + $final[] = '' . $adr['street-address'] . ''; + } + if( isset($adr['extended-address']) ) { + $final[] = '' . $adr['extended-address'] . ''; + } + } + if ($loc['public']>=2) { + if( isset($adr['locality']) ) { + $final[] = ''. $adr['locality'] . ''; + } + } + if( isset($adr['region']) ) { + $final[] = '' . $adr['region'] . ''; + } + if( isset($adr['country-name']) ) { + $final[] = '' . $adr['country-name'] . ''; + } + $c .= implode(", ", $final); + if ($loc['public']==3) { + $c .= self::get_the_geo($loc['latitude'], $loc['longitude']); + $c = '' . $c . ''; } - else{ - return self::get_the_full_adr($loc['adr']); + else { + $c .= ''; } + return $c; + + + } public static function get_map($id = false) { @@ -46,10 +82,10 @@ public static function get_map($id = false) { 'zoom' => '14' ); } - if(($loc['map']!='1')||($loc['public']!='1')) { + if(($loc['map']!='1')||($loc['public']!=3)) { return ""; } - return self::get_the_geo($loc['latitude'], $loc['longitude']) . google_map_static::get_the_map($loc['latitude'], $loc['longitude'], $config['height'], $config['width'], $config['zoom']); + return google_map_static::get_the_map($loc['latitude'], $loc['longitude'], $config['height'], $config['width'], $config['zoom']); } // Return marked up coordinates @@ -61,48 +97,6 @@ public static function get_the_geo($lat, $lon) { return $c; } - public static function get_the_full_adr($loc) { - $c = ''; - if( isset($loc['name']) ) { - $c .= '' . $loc['name'] . ', '; - } - if( isset($loc['street-address']) ) { - $c .= '' . $loc['street-address'] . ', '; - } - if( isset($loc['extended-address']) ) { - $c .= '' . $loc['extended-address'] . ', '; - } - if( isset($loc['locality']) ) { - $c .= ''. $loc['locality'] . ', '; - } - if( isset($loc['region']) ) { - $c .= '' . $loc['region'] . ', '; - } - if( isset($loc['country-name']) ) { - $c .= '' . $loc['country-name'] . ''; - } - $c .= ''; - return $c; - } - - public static function get_the_adr($loc) { - $c = ''; - if( isset($loc['name']) ) { - $c .= '' . $loc['name'] . ', '; - } - if( isset($loc['locality']) ) { - $c .= ''. $loc['locality'] . ', '; - } - if( isset($loc['region']) ) { - $c .= '' . $loc['region'] . ', '; - } - if( isset($loc['country-name']) ) { - $c .= '' . $loc['country-name'] . ''; - } - $c .= ''; - return $c; - } - public static function location_content($content) { $loc = self::get_location(); if(!empty($loc)) { diff --git a/includes/class-osm-static.php b/includes/class-osm-static.php index f58221f..1e3ed23 100644 --- a/includes/class-osm-static.php +++ b/includes/class-osm-static.php @@ -1,7 +1,7 @@ $region, 'country-name' => $address['country'] ?: null, 'postal-code' => $address['postcode'] ?: null, - 'country-code' => $address['country_code'] ?: null, + 'country-code' => strtoupper($address['country_code']) ?: null, 'latitude' => $lat, 'longitude' => $lon, 'altitude' => $alt, 'raw' => $address ); + if (is_null($addr['country-name']) ) { + $codes = json_decode(wp_remote_retrieve_body(wp_remote_get('http://country.io/names.json')), true); + $addr['country-name'] = $codes[$addr['country-code']]; + } return array_filter($addr); } - public function get_the_map_url($lat, $lon, $height=300, $width=300, $zoom=14) { + public static function get_the_map_url($lat, $lon, $height=300, $width=300, $zoom=14) { $map = plugin_dir_url( __FILE__ ) . 'staticmap.php?center=' . $lat . ',' . $lon . '&zoom=' . $zoom . '&size=' . $width . 'x' . $height . '&markers=' . $lat . ',' . $lon . '&maptype=mapnik'; return $map; } + public static function get_the_map_link($lat, $lon) { + return 'http://www.openstreetmap.org/#map=14/' . $lat . '/' . $lon; + } + // Return code for map linked to OSM - public function get_the_map($lat, $lon, $height=300, $width=300, $zoom=14) { + public static function get_the_map($lat, $lon, $height=300, $width=300, $zoom=14) { $c = ''; return $c; } - public function the_map($lat, $lon, $height=300, $width=300, $zoom=14) { + public static function the_map($lat, $lon, $height=300, $width=300, $zoom=14) { echo get_the_map($lat, $lon, $height, $width, $zoom); } } diff --git a/includes/class-post-timezone.php b/includes/class-post-timezone.php index ca0b44f..d9d2d3c 100644 --- a/includes/class-post-timezone.php +++ b/includes/class-post-timezone.php @@ -15,6 +15,9 @@ public static function init() { public static function get_the_date($the_date, $d = '' , $post = null) { $post = get_post( $post ); + if (!$post) { + return $the_date; + } $timezone = get_post_meta( $post->ID, '_timezone', true ); if ( !$timezone ) { return $the_date; @@ -29,6 +32,9 @@ public static function get_the_date($the_date, $d = '' , $post = null) { public static function get_the_time($the_time, $d = '' , $post = null) { $post = get_post( $post ); + if (!$post) { + return $the_time; + } $timezone = get_post_meta( $post->ID, '_timezone', true ); if ( !$timezone ) { return $the_time; diff --git a/includes/interface-map-provider.php b/includes/interface-map-provider.php index ea3891d..454526c 100644 --- a/includes/interface-map-provider.php +++ b/includes/interface-map-provider.php @@ -11,19 +11,28 @@ interface map_provider { * @param string $alt altitude (optional) * @return array microformats2 address elements in an array */ - public function reverse_lookup($lat, $lon, $zoom=18, $alt = NULL); + public static function reverse_lookup($lat, $lon, $zoom=18, $alt = NULL); /** - * Given coordinates return HTML code for a map + * Given coordinates return a URL for a dynamic map + * + * @param string $lat latitude + * @param string $long longitude + * @return string URL of map + */ + public static function get_the_map_link($lat, $lon); + + /** + * Given coordinates return URL for a static map * * @param string $lat latitude * @param string $long longitude * @param string $height * @param string $width * @param string $zoom the map level of detail - * @return string URL of map + * @return string URL of map */ - public function get_the_map_url($lat, $lon, $height=300, $width=300, $zoom=14); + public static function get_the_map_url($lat, $lon, $height=300, $width=300, $zoom=14); /** @@ -36,7 +45,7 @@ public function get_the_map_url($lat, $lon, $height=300, $width=300, $zoom=14); * @param string $zoom the map level of detail * @return string HTML marked up map */ - public function get_the_map($lat, $lon, $height=300, $width=300, $zoom=14); + public static function get_the_map($lat, $lon, $height=300, $width=300, $zoom=14); /** * Given coordinates echo the output of get_the_map @@ -48,5 +57,5 @@ public function get_the_map($lat, $lon, $height=300, $width=300, $zoom=14); * @param string $zoom the map level of detail * @return echos the output */ - public function the_map($lat, $lon, $height=300, $width=300, $zoom=14); + public static function the_map($lat, $lon, $height=300, $width=300, $zoom=14); } diff --git a/languages/simple-location.pot b/languages/simple-location.pot index a1eeebe..f33bb74 100644 --- a/languages/simple-location.pot +++ b/languages/simple-location.pot @@ -2,9 +2,9 @@ # This file is distributed under the same license as the Simple Location package. msgid "" msgstr "" -"Project-Id-Version: Simple Location 2.0.0\n" +"Project-Id-Version: Simple Location 2.1.0\n" "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/simple-location\n" -"POT-Creation-Date: 2015-07-04 04:36:41+00:00\n" +"POT-Creation-Date: 2015-07-11 19:05:41+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -19,7 +19,7 @@ msgid "Location" msgstr "" #: build/trunk/includes/class-loc-postmeta.php:56 -#: includes/class-loc-postmeta.php:56 +#: includes/class-loc-postmeta.php:56 includes/class-loc-postmeta.php:129 msgid "Address" msgstr "" @@ -29,74 +29,82 @@ msgid "Display Text Location" msgstr "" #: build/trunk/includes/class-loc-postmeta.php:72 -#: includes/class-loc-postmeta.php:72 msgid "Full Address" msgstr "" #: build/trunk/includes/class-loc-postmeta.php:75 -#: includes/class-loc-postmeta.php:75 msgid "Display Map and Coordinates" msgstr "" #: build/trunk/includes/class-loc-postmeta.php:80 -#: includes/class-loc-postmeta.php:80 +#: includes/class-loc-postmeta.php:83 msgid "Latitude" msgstr "" #: build/trunk/includes/class-loc-postmeta.php:83 -#: includes/class-loc-postmeta.php:83 +#: includes/class-loc-postmeta.php:86 msgid "Longitude" msgstr "" #: build/trunk/includes/class-loc-postmeta.php:86 -#: includes/class-loc-postmeta.php:86 +#: includes/class-loc-postmeta.php:89 msgid "Altitude" msgstr "" -#: build/trunk/includes/class-loc-postmeta.php:101 -#: includes/class-loc-postmeta.php:120 +#: build/trunk/includes/class-loc-postmeta.php:95 +#: includes/class-loc-postmeta.php:98 +msgid "Override Default Timezone" +msgstr "" + +#: build/trunk/includes/class-loc-postmeta.php:120 +#: includes/class-loc-postmeta.php:123 msgid "" "This data is automatically imported from the location coordinates when " "available on save/publish if the below is checked" msgstr "" -#: build/trunk/includes/class-loc-postmeta.php:102 -#: includes/class-loc-postmeta.php:121 +#: build/trunk/includes/class-loc-postmeta.php:121 +#: includes/class-loc-postmeta.php:124 msgid "Address Lookup" msgstr "" -#: build/trunk/includes/class-loc-postmeta.php:105 -#: includes/class-loc-postmeta.php:124 +#: build/trunk/includes/class-loc-postmeta.php:124 msgid "Display Name" msgstr "" -#: build/trunk/includes/class-loc-postmeta.php:111 -#: includes/class-loc-postmeta.php:130 +#: build/trunk/includes/class-loc-postmeta.php:130 msgid "Street Address" msgstr "" -#: build/trunk/includes/class-loc-postmeta.php:116 -#: includes/class-loc-postmeta.php:135 +#: build/trunk/includes/class-loc-postmeta.php:135 msgid "Extended Address" msgstr "" -#: build/trunk/includes/class-loc-postmeta.php:121 -#: includes/class-loc-postmeta.php:140 +#: build/trunk/includes/class-loc-postmeta.php:140 +#: includes/class-loc-postmeta.php:135 msgid "City/Town/Village" msgstr "" -#: build/trunk/includes/class-loc-postmeta.php:126 -#: includes/class-loc-postmeta.php:145 +#: build/trunk/includes/class-loc-postmeta.php:145 +#: includes/class-loc-postmeta.php:139 msgid "State/County/Province" msgstr "" -#: build/trunk/includes/class-loc-postmeta.php:131 -#: includes/class-loc-postmeta.php:150 +#: build/trunk/includes/class-loc-postmeta.php:150 +#: includes/class-loc-postmeta.php:141 msgid "Country" msgstr "" -#: includes/class-loc-postmeta.php:95 -msgid "Override Default Timezone" +#: includes/class-loc-postmeta.php:78 +msgid "Display Map if Showing Address" +msgstr "" + +#: includes/class-loc-postmeta.php:127 +msgid "Location Name" +msgstr "" + +#: includes/class-loc-postmeta.php:133 +msgid "Neighborhood/Suburb" msgstr "" #. Plugin Name of the plugin/theme @@ -119,7 +127,7 @@ msgstr "" msgid "https://david.shanske.com" msgstr "" -#: build/trunk/includes/class-loc-view.php:109 includes/class-loc-view.php:109 +#: build/trunk/includes/class-loc-view.php:109 includes/class-loc-view.php:103 msgctxt "simple-location" msgid "Location:" msgstr "" \ No newline at end of file diff --git a/readme.txt b/readme.txt index 030019b..77da734 100755 --- a/readme.txt +++ b/readme.txt @@ -1,7 +1,7 @@ === Simple Location === Contributors: dshanske Tags: location, indieweb -Stable tag: 2.0.3 +Stable tag: 2.1.0 Requires at least: 4.0 Tested up to: 4.2 License: GPLv2 or later @@ -38,6 +38,10 @@ It consists of four fields: latitude, longitude, public, and address. Altitude h == Changelog == += Version 2.1.0 = + * Revamp in Text Display Parameters, now offering three levels of Detail + * Coordinates will now display and Location will link to map if set for full address + = Version 2.0.3 = * Google Static Maps now link to Google Maps * Nominatim now defaultly tries to retrieve in the language of the blog diff --git a/simple-location.php b/simple-location.php index 696af99..1fe63d3 100755 --- a/simple-location.php +++ b/simple-location.php @@ -3,12 +3,12 @@ * Plugin Name: Simple Location * Plugin URI: https://wordpress.org/plugins/simple-location/ * Description: Adds Location to Wordpress Pages and Posts. - * Version: 2.0.3 + * Version: 2.1.0 * Author: David Shanske * Author URI: https://david.shanske.com */ -define ("SIMPLE_LOCATION_VERSION", "2.0.3"); +define ("SIMPLE_LOCATION_VERSION", "2.1.0"); // Map Provider Interface require_once( plugin_dir_path( __FILE__ ) . 'includes/interface-map-provider.php');