DsgnWrks-Instagram-Importer icon indicating copy to clipboard operation
DsgnWrks-Instagram-Importer copied to clipboard

Suggestion: Store GPS coordinates in the recommended WordPress format/standard

Open chrisaldrich opened this issue 8 years ago • 6 comments

It would be nice if the plugin stored the GPS coordinates with the standard/suggested WordPress standard: https://codex.wordpress.org/Geodata

This would allow the usage of secondary plugins (like Simple Location) to access the stored data and do something with it.

chrisaldrich avatar Feb 02 '17 23:02 chrisaldrich

At this point, I can't change it directly as it will break backwards-compatibility, but i've added a filter to allow modifying the meta key/values pre-save. To do so with the geodata:

function dw_modify_dsgnwrks_instagram_post_meta_pre_save( $meta, $pic ) {
	$meta['geo_latitude'] = $meta['instagram_location_lat'];
	unset( $meta['instagram_location_lat'] );

	$meta['geo_longitude'] = $meta['instagram_location_long'];
	unset( $meta['instagram_location_long'] );

	if ( isset( $pic->location->public ) ) {
		$meta['geo_public'] = ! empty( $pic->location->public ) ? 1 : 0;
	}

	if ( ! empty( $meta['instagram_location_name'] ) ) {
		$meta['geo_address'] = $meta['instagram_location_name'];
	}
	unset( $meta['instagram_location_name'] );

	return $meta;
}
add_filter( 'dsgnwrks_instagram_post_meta_pre_save', 'dw_modify_dsgnwrks_instagram_post_meta_pre_save', 10, 2 );

jtsternberg avatar Mar 21 '17 16:03 jtsternberg

I tested this out last week and didn't have a chance to say: Thanks @jtsternberg! This works perfectly!

chrisaldrich avatar Apr 24 '17 23:04 chrisaldrich

Any reason we couldn't do both?

nfriedly avatar Oct 22 '18 18:10 nfriedly

That would store redundant data in the DB, and generally I'm not a fan of that, but maybe for this, we should make an exception, as those meta-keys are the accepted expectation.

jtsternberg avatar Oct 22 '18 18:10 jtsternberg

Yea, I agree with you in principal, that storing redundant info is unnecessary.

In this case, though, I think storing redundant info for now, and maybe changing the documentation to say something like "The instagram_location_* fields are deprecated and will be removed in v3.x" might be the best plan.

nfriedly avatar Oct 22 '18 18:10 nfriedly

Let's do it.

jtsternberg avatar Oct 22 '18 19:10 jtsternberg