Skip to content

Commit

Permalink
Upgraded to use new WP3.4 oEmbed functions
Browse files Browse the repository at this point in the history
Upgraded plugin to 0.85, primary change is to allow the plugin to take
advantage of Twitter oEmbed now native in WordPress, if the user is
running 3.4 or greater.
  • Loading branch information
AramZS committed Jun 15, 2012
1 parent 1db5bc3 commit 6a1ab2f
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 36 deletions.
8 changes: 8 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ This plugin allows you to place a shortcode in your post that will archive a Twi

This plugin allows you to place a shortcode in your post that will archive a Twitter search term, including hashtags.

Now upgraded to take advantage of WordPress's native oEmbed of tweets!

Shortcode [searchtwitter] options:

* [searchtwitter for="#term"] - The 'for' attribute allows you to designate the search term you wish to search for and archive. You can use any term you'd normally but into the search.twitter.com search box. If you don't put anything in there, it will just search for me, which is cool and all, but probobly not what you want. It doesn't have to be a hashtag.
Expand Down Expand Up @@ -73,6 +75,9 @@ I don't think so, I hope not, but I can't tell you for certain. You use the plug

== Changelog ==

= 0.85 =
* Built in integration with WordPress's oEmbed function for tweets.

= 0.8 =
* Created Dashboard options page for plugin with instructions for use.
* Now allow users to set a custom datetime for all archives to reference.
Expand All @@ -88,6 +93,9 @@ I don't think so, I hope not, but I can't tell you for certain. You use the plug

== Upgrade Notice ==

= 0.85 =
* Now upgraded to take advantage of WordPress's native oEmbed of tweets!

= 0.8 =
* Created Dashboard options page for plugin with instructions for use.
* Now allow users to set a custom datetime for all archives to reference.
Expand Down
99 changes: 63 additions & 36 deletions twitterchat-shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin Name: Twitter Archival Shortcode
Plugin URI: http://aramzs.me/twitterarchival
Description: This plugin allows you to place a shortcode in your post that will archive a Twitter search term, including hashtags.
Version: 0.67
Version: 0.85
Author: Aram Zucker-Scharff
Author URI: http://aramzs.me
License: GPL2
Expand Down Expand Up @@ -265,44 +265,71 @@ function output_data($xml,$datelimit,$ordered,$keepGoing,$blackbird)
$unixtime = strtotime($timestamp);
$datetime = date('h:i:s A, n-j-y', $unixtime);

//Ok, so here's where it gets complex... If you are running WP3.4, there is now an awesome oEmbed function that rendders tweets for us.
//See http://codex.wordpress.org/Embeds and http://core.trac.wordpress.org/browser/tags/3.4/wp-includes/media.php#L0 for more info.
//But if you are running a WP version before that, no-go.
//So let's use this new function, but create a fallback.
//Remember we got the WordPress version before?
//Well, to provide forward compatability, we need to convert it to a number.
//Using this PHP function allows us to turn the string into a decimal number PHP understands.
//Let's get the current WordPress version.
$wpver = get_bloginfo('version');
//Should get a string like '3.4' - for more info see http://core.trac.wordpress.org/browser/tags/3.4/wp-includes/version.php#L0
$floatWPVer = floatval($wpver);


//If you've designated a date to retrieve from, either a year, month or day, you can restrict Tweets that appear only to that period.
if (!empty($datelimit)) {
//The given date string must be in the 2012-4-24 format
//If it matches the published time of the tweet, save it to the object.
//Otherwise, don't.
if(strstr($entry->published,$datelimit))
{
$output_archive .= "<div class=\"ta-twitter_user ta\">
<ul class=\"ta-ul\">
<li class=\"ta-image ta\"><img class=\"ta-avatar ta\" src=\"$image\"></li>
<li class=\"ta-published ta\"><a href=\"$link\">$datetime</a></li>
<li class=\"ta-user ta\"><a href=\"$uri\" target=\"_blank\">$name</a></li>
<li class=\"ta-description ta\">$entry->title</li>
//If you've designated a date to retrieve from, either a year, month or day, you can restrict Tweets that appear only to that period.
if (!empty($datelimit)) {
//The given date string must be in the 2012-4-24 format
//If it matches the published time of the tweet, save it to the object.
//Otherwise, don't.
if(strstr($entry->published,$datelimit))
{

</ul>
</div>";
$keepGoing = true;
}
else { $keepGoing = false; }
} //End of datecheck.
else {

$output_archive .= "<div class=\"ta-twitter_user ta\">
<ul class=\"ta-ul\">
<li class=\"ta-image ta\"><img class=\"ta-avatar ta\" src=\"$image\"></li>
<li class=\"ta-published ta\"><a href=\"$link\">$datetime</a></li>
<li class=\"ta-user ta\"><a href=\"$uri\" target=\"_blank\">$name</a></li>
<li class=\"ta-description ta\">$entry->title</li>
</ul>
</div>";
//Now, we check if the version of WordPress we are running is equal to or greater than 3.4.
if ($floatWPVer >= 3.4){


$outputlink = (string) $entry->link[0]['href'];
$output_archive .= wp_oembed_get($outputlink);

} else {
$output_archive .= "<div class=\"ta-twitter_user ta\">
<ul class=\"ta-ul\">
<li class=\"ta-image ta\"><img class=\"ta-avatar ta\" src=\"$image\"></li>
<li class=\"ta-published ta\"><a href=\"$link\">$datetime</a></li>
<li class=\"ta-user ta\"><a href=\"$uri\" target=\"_blank\">$name</a></li>
<li class=\"ta-description ta\">$entry->title</li>
</ul>
</div>";
$keepGoing = true;
}
}
else { $keepGoing = false; }
} //End of datecheck.
else {
//Now, we check if the version of WordPress we are running is equal to or greater than 3.4.
if ($floatWPVer >= 3.4){


$outputlink = (string) $entry->link[0]['href'];
$output_archive .= wp_oembed_get($outputlink);

} else {
$output_archive .= "<div class=\"ta-twitter_user ta\">
<ul class=\"ta-ul\">
<li class=\"ta-image ta\"><img class=\"ta-avatar ta\" src=\"$image\"></li>
<li class=\"ta-published ta\"><a href=\"$link\">$datetime</a></li>
<li class=\"ta-user ta\"><a href=\"$uri\" target=\"_blank\">$name</a></li>
<li class=\"ta-description ta\">$entry->title</li>
</ul>
</div>";
}
}

}

} //end foreach.

} // end blackbirdpie no.
Expand Down

0 comments on commit 6a1ab2f

Please sign in to comment.