.*?<\/media:title>/s', '', $content);
if(preg_match('/flickr.com/', get_option('anyfeed_feed_url'))) { /* Resize photos from Flickr */ return preg_replace('/(flickr.com\/[\d]*?\/[\d]*?_.*?_)s\.((jpg|gif|png)") height="75" width="75"/', '$1m.$2', $content); }
elseif(preg_match('/picasaweb.google.com/', get_option('anyfeed_feed_url'))) { /* Resize photos from Google */ return preg_replace('/(media:thumbnail url=\'http:\/\/.*?\.ggpht\.com\/_.*?\/.*?\/.*?\/.*?\/s)160(-c\/.*?\.(jpg|gif|png)\' height=\')160(\' width=\')160(\')/', "\${1}240\${2}240\${4}240\${5}", $content);}
else { return $content; }
}
function path_to_anyfeed() {
$path = (str_replace(basename(__FILE__), "", __FILE__));
$path = end(explode("plugins/", $path));
$path = str_replace("\\", "/", $path);
if(end(explode("/",$path)) == 'mu-') {
$path = '/wp-content/mu-plugins/'.$path;
} else {$path = '/wp-content/plugins/'.$path;}
return $path;
}
// Add the javascripts and CSS to the HTML head
add_action('wp_head', 'anyfeed_head' );
function anyfeed_head() {
if(empty($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] == 'off') $http = 'http://'; else $http = 'https://';
?>
'anyfeed', 'description' => 'XML/RSS/ATOM slideshow widget engine. ' );
/* Widget control settings. */
$control_ops = array( 'width' => 245, 'height' => 200, 'id_base' => 'anyfeed' );
/* Create the widget. */
$this->WP_Widget( 'anyfeed', 'Anyfeed Slideshow', $widget_ops, $control_ops );
wp_enqueue_script('jquery');
}
function widget( $args, $instance ) {
extract( $args );
// Drawing Title
echo $before_widget . $before_title . $instance['title'] . $after_title;
// Check tempfile to see if we need to create a new one or not
if(get_option('anyfeed_cache')){
$tempfile = get_option('anyfeed_tempfile');
if( empty($tempfile) OR // The tempfile filename is not set
!file_exists($tempfile) OR // The file does not exist
!get_option('anyfeed_cache') OR // Cache is not enabled
time() - filemtime($tempfile) > (60*60*24) // Older then 24 hours
) {
@unlink(get_option('anyfeed_tempfile'));
$url = get_option('anyfeed_feed_url');
if(empty($url)) {print('The URL was blank. Did you enter one in the Widget settings?
'.$after_widget); return false;}
$urla = explode("://", $url);
if(isset($urla[1])) { $url = $urla[1]; }
$url = 'http://'.$url;
$temp_file = tempnam(sys_get_temp_dir(), 'ANY');
if(!$f = @fopen($temp_file, 'w')){ print('Failed to open temp file.
'.$after_widget); return false;}
update_option('anyfeed_tempfile', $temp_file);
$f = fopen($temp_file, 'w');
$tmpxml = anyfeed_getfile();
if(preg_match('/flickr.com/', $url)) { /* Resize photos from Flickr */ $tmpxml = preg_replace('/(flickr.com\/[\d]*?\/[\d]*?_.*?_)s.((jpg|gif|png)") height="75" width="75"/', '$1m.$2', $tmpxml); }
if(preg_match('/picasaweb.google.com/', $url)) { /* Resize photos from Google */ $tmpxml = preg_replace('/(media:thumbnail url=\'http:\/\/.*?\.ggpht\.com\/_.*?\/.*?\/.*?\/.*?\/s)160(-c\/.*?\.(jpg|gif|png)\' height=\')160(\' width=\')160(\')/', "\${1}240\${2}240\${4}240\${5}", $tmpxml);}
if(!@fwrite($f, $tmpxml)){ fclose($f); print('Failed to write XML.
'.$after_widget); return false;}
fclose($f);
}// end cache if
}// End if cache
// Drawing Widget
echo '';
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
/* Strip tags (if needed) and update the widget settings. */
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['width'] = strip_tags( $new_instance['width'] ); update_option('anyfeed_width', $instance['width']);
$instance['height'] = strip_tags( $new_instance['height'] );update_option('anyfeed_height', $instance['height']);
$instance['feed_url'] = $new_instance['feed_url']; update_option('anyfeed_feed_url', $instance['feed_url']);
if($new_instance['show_titlebar'] == 'on') { $new_instance['show_titlebar'] = true; } else { $new_instance['show_titlebar'] = false; }
$instance['show_titlebar'] = $new_instance['show_titlebar']; update_option('anyfeed_show_titlebar', $instance['show_titlebar']);
if($new_instance['show_navigation'] == 'on') { $new_instance['show_navigation'] = true; } else { $new_instance['show_navigation'] = false; }
$instance['show_navigation'] = $new_instance['show_navigation']; update_option('anyfeed_show_navigation', $instance['show_navigation']);
$instance['pause_rate'] = $new_instance['pause_rate']; update_option('anyfeed_pause_rate', $instance['pause_rate']);
$instance['fade_rate'] = $new_instance['fade_rate']; update_option('anyfeed_fade_rate', $instance['fade_rate']);
$instance['loading_text'] = $new_instance['loading_text']; update_option('anyfeed_loading_text', $instance['loading_text']);
$instance['media_type'] = $new_instance['media_type']; update_option('anyfeed_media_type', $instance['media_type']);
$instance['bgcolor'] = $new_instance['bgcolor']; update_option('anyfeed_bgcolor', $instance['bgcolor']);
if($new_instance['cache'] == 'on') { $new_instance['cache'] = true; } else { $new_instance['cache'] = false; }
$instance['cache'] = $new_instance['cache']; update_option('anyfeed_cache', $instance['cache']);
return $instance;
}
function form( $instance ) {
print(
'
'."\r\n".
'
(Hover your mouse over the label text for a short description
of the corresponding field)
'."\r\n");
/* Default Widget Settings. */
$defaults = array(
'title' => 'Anyfeed Slideshow',
'width' => '100%',
'height' => '200px',
'feed_url' => 'http://api.flickr.com/services/feeds/photos_public.gne?format=rss_200',
'show_titlebar' => true,
'show_navigation' => true,
'pause_rate' => 5000,
'fade_rate' => 1000,
'loading_text' => 'Loading...',
'media_type' => 'thumbnail',
'bgcolor' => 'transparent',
'cache' => false
);
$instance = wp_parse_args( $instance, $defaults );
wp_enqueue_script("jquery");
?>
Show/Hide Advanced Options