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

Update dsgnwrks-instagram-importer.php #12

Closed AceMedia closed 10 years ago

AceMedia commented 10 years ago

Fixed 'instagram_user' savePostmeta() input.

jtsternberg commented 10 years ago

Can you please expand on why this is needed/what it's doing?

AceMedia commented 10 years ago

I was trying to grab the 'instagram_user' field meta, to display in a template, then noticed it was not getting filled in. This change fixes that on all new imports.

jtsternberg commented 10 years ago

When I look at the Instagram API, I see no userid parameter, and I don't see any reason the pic->user wouldn't be saved. http://b.ustin.co/7mz2

AceMedia commented 10 years ago

I'm asking it to fill the field with '$this->userid' from the account settings itself, in wp-admin, not a instagram variable. '$this->pic->user' did nothing for me upon testing.

I also tried '$this->pic->username' and a few other variables, nothing else worked, though my current solution does, every time, without fail. I just figured it'd always be the account used to import so made sense.

AceMedia commented 10 years ago

Just for further clarification, it's this custom field it wasn't filling. http://cl.ly/VIqd

jtsternberg commented 10 years ago

The 'instagram_user' post meta will be an object, so will not display properly in the custom fields box. Can you try:

$user = get_post_meta( get_the_ID(), 'instagram_user', 1 );
echo '<xmp>: '. print_r( $user, true ) .'</xmp>';

And see what it spits out? After grabbing that post-meta, $user->username should be what you're looking for.

AceMedia commented 10 years ago

I'd just leave it with my solution. Seems to work better for outputting the username anyway.

I have it working here perfectly, without the xmp stuff. Check the usernames below instagram posts. http://clients.shanerounce.com/fyi/

jtsternberg commented 10 years ago

I'm not going to change it simply because you like it better. The way it saves now provides more functionality and you're proposing to take that away. Considering this plugin has thousands of users, I take backwards-compatibility very seriously. If you want to get the username, you can easily do so the way I suggested, or use the plugin's built-in hooks/filters to save your own post-meta.

There's no reason this wouldn't work for you.

$user = get_post_meta( get_the_ID(), 'instagram_user', 1 );
echo $user->username;
AceMedia commented 10 years ago

Ah, I wasn't proposing it be changed to work better for me. I've made my alterations and I'm happy with how it works. I was simply submitting the change cause I thought/believed it was broken as I couldn't access it through the usual straight-up method, so i assumed it just wasn't being filled (nor even showing as a blank saved field) and couldn't find documentation for it anywhere, other than a list on wp forums of all the meta keys.

Do custom fields with a saved array of objects just not appear as though they've even been used for any given post then? Just trying to understand why wordpress wouldn't just output the string array into the custom field itself?

Also, wouldn't it have been better to initially just populated this field with the usernames, as plaintext, from the start?

Smashing plugin though! :) Just really submitted this incase I was correct about it being broken. Either way, some people might find comfort in having the username visible in the edit post custom field, no?

What functionality am I losing, by the way, by using my method to simply store the instagram username? It doesn't seem to have affected anything other than what was desired, are the objects stored in that field used elsewhere?

And sorry for anything that sounds like nonsense, I'm a front-end dev so 75% of this stuff is greek to me.

jtsternberg commented 10 years ago

Ok makes sense. The main downside to modifying the plugin the way you have, is if you make edits and you update the plugin via the WordPress dashboard when the next update is available, you will lose your edits.

You're right though, I do need some more documentation for the meta data and how to use it. WordPress only displays post-meta saved as a string value, so any data saved as an array or object will not display at all in the custom field metabox.

It probably wouldn't have been a bad idea to save the username as a meta field, and I've gone ahead and added it.

AceMedia commented 10 years ago

Yeah, I get how updates work and stuff. I usually just alter the version number for any edited plugin, then manually upgrade in future.

Just hope I've helped more than hindered you.

On 2 May 2014, at 13:52, Justin Sternberg notifications@github.com wrote:

Ok makes sense. The main downside to modifying the plugin the way you have, is if you make edits and you update the plugin via the WordPress dashboard when the next update is available, you will lose your edits.

You're right though, I do need some more documentation for the meta data and how to use it. WordPress only displays post-meta saved as a string value, so any data saved as an array or object will not display at all in the custom field metabox.

It probably wouldn't have been a bad idea to save the username as a meta field, and I've gone ahead and added it.

— Reply to this email directly or view it on GitHub.