Skip to content

Commit

Permalink
Merge pull request #152 from dshanske/develop
Browse files Browse the repository at this point in the history
Fix EXIF Issues
  • Loading branch information
dshanske committed Mar 19, 2020
2 parents 4dc714d + 212795f commit 233cca2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 30 deletions.
47 changes: 29 additions & 18 deletions includes/class-geo-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,31 +417,38 @@ public static function attachment( $meta, $post_id ) {
return $meta;
}

$data = $meta['image_meta'];
$data = $meta['image_meta'];
$update = array();
if ( isset( $data['created'] ) ) {
$update['mf2_published'] = $data['created'];
}
if ( isset( $data['location'] ) ) {
update_post_meta( $post_id, 'geo_latitude', $data['location']['latitude'] );
update_post_meta( $post_id, 'geo_longitude', $data['location']['longitude'] );
if ( isset( $data['location']['altitude'] ) ) {
update_post_meta( $post_id, 'geo_altitude', $data['location']['altitude'] );
foreach ( array( 'latitude', 'longitude', 'altitude' ) as $prop ) {
if ( array_key_exists( $prop, $data['location'] ) ) {
$update[ 'geo_' . $prop ] = $data['location'][ $prop ];
}
}
$reverse = Loc_Config::geo_provider();
$reverse->set( $data['location']['latitude'], $data['location']['longitude'] );
$reverse_adr = $reverse->reverse_lookup();
if ( isset( $reverse_adr['display-name'] ) ) {
update_post_meta( $post_id, 'geo_address', $reverse_adr['display-name'] );
$update['geo_address'] = $reverse_adr['display-name'];
}
if ( ! array_key_exists( 'geo_altitude', $update ) ) {
$update['geo_altitude'] = $reverse->elevation();
}
update_post_meta( $post_id, 'geo_altitude', $reverse->elevation() );
$zone = Location_Zones::in_zone( $data['location']['latitude'], $data['location']['longitude'] );
if ( ! empty( $zone ) ) {
update_post_meta( $post_id, 'geo_address', $zone );
$update['geo_address'] = $zone;
self::set_visibility( 'post', $post_id, 'protected' );
update_post_meta( $post_id, 'geo_zone', $zone );
$update['geo_zone'] = $zone;
} else {
self::set_visibility( 'post', $post_id, 'public' );
}
}
if ( isset( $data['created'] ) ) {
update_post_meta( $post_id, 'mf2_published', $data['created'] );
$update = array_filter( $update );
foreach ( $update as $key => $value ) {
update_post_meta( $post_id, $key, $value );
}
return $meta;
}
Expand Down Expand Up @@ -760,7 +767,7 @@ public static function get_geodata( $object = null, $full = true ) {
public static function register_meta() {
$args = array(
'sanitize_callback' => array( 'WP_Geo_Data', 'clean_coordinate' ),
'type' => 'float',
'type' => 'number',
'description' => 'Latitude',
'single' => true,
'show_in_rest' => false,
Expand All @@ -772,7 +779,7 @@ public static function register_meta() {

$args = array(
'sanitize_callback' => array( 'WP_Geo_Data', 'clean_coordinate' ),
'type' => 'float',
'type' => 'number',
'description' => 'Longitude',
'single' => true,
'show_in_rest' => false,
Expand All @@ -783,7 +790,7 @@ public static function register_meta() {
register_meta( 'term', 'geo_longitude', $args );

$args = array(
'type' => 'int',
'type' => 'number',
'description' => 'Altitude',
'single' => true,
'show_in_rest' => false,
Expand Down Expand Up @@ -816,7 +823,7 @@ public static function register_meta() {
register_meta( 'term', 'geo_timezone', $args );

$args = array(
'type' => 'integer',
'type' => 'number',
'description' => 'Geodata Zoom for Map Display',
'single' => true,
'show_in_rest' => false,
Expand All @@ -827,7 +834,7 @@ public static function register_meta() {
register_meta( 'term', 'geo_zoom', $args );

$args = array(
'type' => 'integer',
'type' => 'number',
'description' => 'Geodata Public',
'single' => true,
'show_in_rest' => false,
Expand Down Expand Up @@ -1000,12 +1007,16 @@ function wp_exif_gps_convert( $coordinate ) {
*
*
* @param string $str
* @param string $timezone A timezone or offset string. Default is the WordPress timezone
* @param string|DateTimeZone $timezone A timezone or offset string. Default is the WordPress timezone
* @return DateTime
*/
if ( ! function_exists( 'wp_exif_datetime' ) ) {
function wp_exif_datetime( $str, $timezone = null ) {
$timezone = ( $timezone ) ? new DateTimeZone( $timezone ) : wp_timezone();
if ( is_string( $timezone ) ) {
$timezone = new DateTimeZone( $timezone );
} elseif ( ! $timezone instanceof DateTimeZone ) {
$timezone = wp_timezone();
}
$datetime = new DateTime( $str, $timezone );
return $datetime;
}
Expand Down
16 changes: 8 additions & 8 deletions languages/simple-location.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# This file is distributed under the same license as the Simple Location package.
msgid ""
msgstr ""
"Project-Id-Version: Simple Location 4.0.4\n"
"Project-Id-Version: Simple Location 4.0.5\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/simple-location\n"
"POT-Creation-Date: 2020-02-17 05:53:15+00:00\n"
"POT-Creation-Date: 2020-03-18 23:39:31+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand All @@ -22,7 +22,7 @@ msgid "Private Location"
msgstr ""

#: includes/class-geo-data.php:146 includes/class-geo-data.php:388
#: includes/class-geo-data.php:884 includes/class-loc-config.php:204
#: includes/class-geo-data.php:891 includes/class-loc-config.php:204
#: includes/class-loc-metabox.php:85 includes/class-loc-metabox.php:97
#: templates/loc-side-metabox.php:33
msgid "Location"
Expand Down Expand Up @@ -81,25 +81,25 @@ msgstr ""
msgid "Creation Time"
msgstr ""

#: includes/class-geo-data.php:650
#: includes/class-geo-data.php:657
msgid "Invalid Input"
msgstr ""

#: includes/class-geo-data.php:862 includes/class-location-zones.php:101
#: includes/class-geo-data.php:869 includes/class-location-zones.php:101
#: templates/loc-user-metabox.php:20 templates/loc-user-metabox.php:24
msgid "Latitude"
msgstr ""

#: includes/class-geo-data.php:873 includes/class-location-zones.php:102
#: includes/class-geo-data.php:880 includes/class-location-zones.php:102
#: templates/loc-user-metabox.php:27 templates/loc-user-metabox.php:31
msgid "Longitude"
msgstr ""

#: includes/class-geo-data.php:895
#: includes/class-geo-data.php:902
msgid "Location Visibility"
msgstr ""

#: includes/class-geo-data.php:1031
#: includes/class-geo-data.php:1042
msgid "m"
msgstr ""

Expand Down
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Simple Location #
**Contributors:** [dshanske](https://profiles.wordpress.org/dshanske)
**Tags:** geolocation, timezones, geo, maps, location, weather, indieweb
**Stable tag:** 4.0.4
**Stable tag:** 4.0.5
**Requires at least:** 4.9
**Tested up to:** 5.3.2
**Requires PHP:** 5.4
Expand Down Expand Up @@ -183,6 +183,10 @@ will now be required to show maps for services that require API keys.

## Changelog ##

### 4.0.5 ( 2020-03-18 ) ###
* Fix issue with timezone handling of photo EXIF data by allowing either timezone string or object
* Fix issue with EXIF altitude handling

### 4.0.4 ( 2020-02-17 ) ###
* Update timezone handling in attachments
* Add timezone offsets to REST API
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
=== Simple Location ===
Contributors: dshanske
Tags: geolocation, timezones, geo, maps, location, weather, indieweb
Stable tag: 4.0.4
Stable tag: 4.0.5
Requires at least: 4.9
Tested up to: 5.3.2
Requires PHP: 5.4
Expand Down Expand Up @@ -183,6 +183,10 @@ will now be required to show maps for services that require API keys.

== Changelog ==

= 4.0.5 ( 2020-03-18 ) =
* Fix issue with timezone handling of photo EXIF data by allowing either timezone string or object
* Fix issue with EXIF altitude handling

= 4.0.4 ( 2020-02-17 ) =
* Update timezone handling in attachments
* Add timezone offsets to REST API
Expand Down
4 changes: 2 additions & 2 deletions simple-location.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Simple Location
* Plugin URI: https://wordpress.org/plugins/simple-location/
* Description: Adds Location to WordPress
* Version: 4.0.4
* Version: 4.0.5
* Author: David Shanske
* Author URI: https://david.shanske.com
* Text Domain: simple-location
Expand All @@ -23,7 +23,7 @@


class Simple_Location_Plugin {
public static $version = '4.0.4';
public static $version = '4.0.5';

public static function activate() {
require_once plugin_dir_path( __FILE__ ) . 'includes/class-geo-data.php';
Expand Down

0 comments on commit 233cca2

Please sign in to comment.