<?php
/*
Plugin Name: sg-tweet
Plugin URI: http://www.sureglass.com/plugins/sg-tweet/
Description: Display the latest tweet from a Twitter account. Put <code><?php sgLatestTweet('YOURTWITTERUSERNAME'); ?></code> anywhere in your template.
Version: 1.0
Author: sureglass
Author URI: http://www.sureglass.com/
*/
function sgLatestTweet($username){
$xml = simplexml_load_file("http://twitter.com/statuses/user_timeline/$username.xml?count=1") or die("Either <b>$username</b> is not a valid Twitter account or there was an error connecting to Twitter.");
foreach($xml->status as $update){ $tweet = $update->text; }
if($tweet == null){
echo "<b>$username</b> has not posted a single Tweet yet.";
}
else {
preg_match('/(http:\/\/)(.*)/', $tweet, $link);
if (empty($link[0])) {
echo $tweet;
} else {
$url = "<a href=\"$link[0]\">$link[0]</a>";
$tweet = str_replace($link[0], $url, $tweet);
echo $tweet;
}
}
}
?>
Sementara cara instalasi plugin sg-tweet tersebut adalah :
- Download and extract the plugin's zip file.
- Upload the extracted
sg-tweet
folder to yourwp-content/plugins
directory. - Activate the plugin and enter
<?php sgLatestTweet('YOURTWITTERUSERNAME'); ?>
in your template where you would like to display your latest Tweet
Bagaimana ? bisa kan ? jangan lupa baca juga artikel sebelumnya tentang plugin search term tagging 2. salam anti login, karena hidup untuk berbagi.