
%s
%s';
//! to re-order use %1$s .. %4$s where:
// 1: URL
// 2: Thumb URL
// 3: Title
// 4: Description
// ie: '
Link: %1$s'
// more information @ http://php.net/sprintf
//
//! Start
//
if (!$tag)
{
$content = $GLOBALS["wp_query"];
$content = $content->post->post_content;
if (ereg("\[tags\]", $content)) {
$tmp = substr($content, strpos($content,"[tags]")+6);
$tmp = substr($tmp, 0, strpos($tmp,"[/tags]"));
$tag = (ereg(",",$tmp))?substr($tmp,0,strpos($tmp,",")):$tmp;
}
}
echo "\n";
if ($tag)
{
$feed="http://www.youtube.com/api2_rest?method=youtube.videos.list_by_tag&dev_id=".$dev_id."&tag=".urlencode($tag);
// grab the XML -> $xml
ob_start();
$cp = curl_init($feed);
curl_exec($cp);
$xml = str_replace('\n', '', ob_get_contents());
ob_end_clean();
// strip the stuff you need
$youtube_urls = preg_match_all("/(.*?)<\/url>/mis", $xml, $matches)
? array_pop($matches)
: false;
$youtube_thumbs = preg_match_all("/(.*?)<\/thumbnail_url>/mis", $xml, $matches)
? array_pop($matches)
:false;
$youtube_titles = preg_match_all("/(.*?)<\/title>/mis", $xml, $matches)
? array_pop($matches)
:false;
$youtube_descriptions = preg_match_all("/(.*?)<\/description>/mis", $xml, $matches)
? array_pop($matches)
:false;
// output
if(count($youtube_urls) > 0 && count($youtube_thumbs) > 0)
{
for($i = 0; $i < $display_x; $i++)
{
$valid = true;
if($filter_values)
{ // check description/title
if( preg_match('/' . implode("|", array_values($filters)) . '/i', $youtube_descriptions[$i])
|| preg_match('/' . implode("|", array_values($filters)) . '/i', $youtube_titles[$i]))
$valid = false;
}
if($valid)
@printf($output_template, $youtube_urls[$i], $youtube_thumbs[$i], $youtube_titles[$i], $youtube_descriptions[$i]);
}
}
}else{
echo "\n";
}
echo "";
}
?>