Apple Movie Trailer Wordpress Widget
erich February 13th, 2007
I found another great widget, which displays a random Apple Movie trailer, complete with movie poster.
Sadly, I ran into exactly the same problem that I did with the APOD widget - use of url file access functions is strictly verboten on my web host. So, here is the modded version of the widget to use cURL:
PHP:
-
<?php
-
/*
-
Plugin Name: Apple Trailer Sidebar Widget
-
Description: Adds a sidebar widget that shows the latest movie trailers from apple.com
-
Author: Patrick Queisler
-
Version: 1.1
-
Author URI: http://www.sosuechtig.de
-
Version 1.1 - Erich Beyrent [http://www.beyrent.net]: added cURL functions to fetch the data from Apple
-
*/
-
-
function widget_appletrailer_init() {
-
-
return;
-
-
function widget_appletrailer($args) {
-
-
$options = get_option('widget_appletrailer');
-
$title = $options['title'];
-
-
function appledotcom_parser(){
-
$myfile = '';
-
if($lines)
-
{
-
foreach ($lines as $line_num=> $line)
-
{
-
}
-
}
-
else
-
{
-
$ch = curl_init();
-
curl_setopt($ch, CURLOPT_URL, "http://wdirect.apple.com/trailers/home/externalA.js");
-
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
-
$myfile = curl_exec($ch);
-
curl_close ($ch);
-
}
-
-
$out = eregi_replace("href=\"/trailers/","target=\"_blank\" href=\"http://www.apple.com/trailers/",$myfile);
-
return $out;
-
}
-
function get_trailer(){
-
echo "<center><script language=\"JavaScript\" type=\"text/javascript\">";
-
echo "loadRandomD();
-
</script></center>";
-
}
-
get_trailer();
-
echo $after_widget;
-
}
-
-
-
function widget_appletrailer_control() {
-
-
$options = get_option('widget_appletrailer');
-
if ( $_POST['appletrailer-submit'] ) {
-
-
update_option('widget_appletrailer', $options);
-
}
-
-
-
echo '<p style="text-align:right;"><label for="appletrailer-title">Title: <input style="width: 200px;" id="appletrailer-title" name="appletrailer-title" type="text" value="'.$title.'" /></label></p>';
-
echo '<input type="hidden" id="appletrailer-submit" name="appletrailer-submit" value="1" />';
-
}
-
-
register_sidebar_widget('Apple Trailer', 'widget_appletrailer');
-
register_widget_control('Apple Trailer', 'widget_appletrailer_control', 300, 100);
-
}
-
-
add_action('plugins_loaded', 'widget_appletrailer_init');
-
-
?>
tags: apple, curl, movie, php, plugin, security, trailers, widget, wordpress, beyrent
- Technology , PHP , Wordpress
- Comments(0)

