jtsternberg / DsgnWrks-Instagram-Importer

Backup your instagram photos & display your instagram archive. Supports importing to custom post-types & adding custom taxonomies.
http://wordpress.org/extend/plugins/dsgnwrks-instagram-importer/
33 stars 16 forks source link

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

Open chrisaldrich opened 7 years ago

chrisaldrich commented 7 years ago

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.

jtsternberg commented 7 years ago

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 );
chrisaldrich commented 7 years ago

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

nfriedly commented 6 years ago

Any reason we couldn't do both?

jtsternberg commented 6 years ago

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.

nfriedly commented 6 years ago

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.

jtsternberg commented 6 years ago

Let's do it.