Skip to content

Instantly share code, notes, and snippets.

@hayashikejinan
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save hayashikejinan/5fe06a5498521b4d759a to your computer and use it in GitHub Desktop.

Select an option

Save hayashikejinan/5fe06a5498521b4d759a to your computer and use it in GitHub Desktop.
SNAP Twitter URL
/**
* SNAP plugin で保存された Twitter 画像の URL を得る関数 (参考: http://keisuke.tsukayoshi.com/blog/1642
*
* Copyright (c) 2014 hayashikejinan (http://hayashikejinan.com)
* This software is released under the MIT License.
* http://opensource.org/licenses/mit-license.php
*
* @return string
*/
function get_snap_tw_img_url() {
$tw_img_url = '';
if ( $post_meta = get_post_meta( get_the_ID(), 'snapTW', true ) ) {
$tw_user_id = '[ツイッターID]';
$unserialize = maybe_unserialize( $post_meta );
$tw_image_id = $unserialize[0]['pgID'];
if ( $tw_image_id ) {
$tw_img_url = 'https://twitter.com/' . $tw_user_id . '/status/' . $tw_image_id . '/photo/1';
}
}
return esc_url( $tw_img_url );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment