iTweet
iTweet
// Add Shortcode
function sc_itweet( $atts , $content = null ) {
// Code
$twitter_url = 'https://api.twitter.com/1/statuses/';
if( !$json = get_transient( 'itweet-' . $id ) ) {
$response = wp_remote_get( $twitter_url'oembed.json?align=center&id=' . $id );
}
if( $json ||
( $response['response']['code']==200 && $json = json_decode( $response['body'] ) ) ){
set_transient( 'itweet-' . $id, $json );
}
$tweet = $json->html;
return $tweet;
// Usage : [itweet]123456789[/itweet] where 123456789 is the tweet's id
}
add_shortcode( 'itweet', 'sc_itweet' );