WordPress.org

Plugin Directory

Changeset 1110767


Ignore:
Timestamp:
03/12/15 00:44:48 (3 years ago)
Author:
zackdesign
Message:

2.0.0

Location:
rss-image-widget
Files:
3 added
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • rss-image-widget/trunk/readme.txt

    r792165 r1110767  
    11=== RSS Image Widget === 
    22Contributors: zackdesign 
    3 http://wp.zackdesign.biz/rss-image-widget/ 
     3http://zackdesign.biz/ 
    44Tags: rss, image, feed, widget, simplepie, plugin 
    55Requires at least: 2.8 
    6 Tested up to: 3.7 
    7 Stable tag: 1.4.2 
     6Tested up to: 4.1.1 
     7Stable tag: 2.0.0 
    88 
    9 This plugin provides you with a widget to display images from a feed. It requires the SimplePie plugin to be installed. 
     9This plugin provides you with a widget to display images from a feed. It requires Wordpress' SimplePie include. 
    1010 
    1111== Description == 
    1212 
    13 This Widget uses automatically downloads each image to cache it locally. These are cached inside `wp-content/cache` so please ensure that the directory is writable. If your images still don't appear check to see that they're readable inside the cache. 
     13New 2.0.0 release! This should be far more stable! Please let me know via zackdesign.biz if there's anything broken in your layouts as a result of moving to Bootstrap HTML. 
    1414 
    1515Image Feeds will work in the plugin providing that they use enclosures. If you want you can change the template provided to suit your feed if necessary, though this should work if enclosures are used correctly. 
    1616 
    17 I have set the default image width in the template to be 150 pixels wide. You can change these options in the widget area. 
    18  
    19 SimplePie plugin is no longer required for this plugin as it now ships with Wordpress 2.8 and above!  
    20  
    21 Next version will include some extra options and possibly better HTML. 
    22  
    23 * Link to full image or enclosure URL option 
    24 * PHPThumb reflection option (and other options) 
    25 * Some cache options 
    26 * Much more 
    27   
    2817Please be aware that I'll only be updating this if I need to. Feel free to come on board and contribute! 
    29  
    30 == Screenshots == 
    31  
    32 [Zack Design Plugin Showcase](http://wp.zackdesign.biz "Plugin Showcase") 
    3318 
    3419== Installation == 
     
    4227 
    4328== Changelog == 
     29 
     302.0.0 
     31 
     32- Now using Lightbox provided by CDN instead of Shadowbox 
     33- Bootstrap-compatible classes and HTML - apologies if you were depending on the original layout 
     34- No more need for caching. I figured this was causing too many issues 
     35- SimplePie caches using the Wordpress upload directory if available 
    4436 
    45371.4.2 
     
    9486= Images aren't appearing = 
    9587 
    96 Usually any problem is related to the cache, and write permissions to that cache. Check the permissions for `wp-content/cache`. 
    97  
    98 The other issue could be that your feed doesn't have enclosures. If you don't know what this is please read this: http://en.wikipedia.org/wiki/RSS_enclosure 
     88It could be that your feed doesn't have enclosures. If you don't know what this is please read this: http://en.wikipedia.org/wiki/RSS_enclosure 
    9989 
    10090= I Need HELP!!! = 
     
    10292That's what I'm here for. I do Wordpress sites for many people in a professional capacity and 
    10393can do the same for you. Check out www.zackdesign.biz 
    104  
    105 = Where do I get SimplePie? = 
    106  
    107 Weren't you paying attention? Read the Description again!!! 
    108  
  • rss-image-widget/trunk/rss_image.php

    r792165 r1110767  
    22/* 
    33Plugin Name: RSS Images 
    4 Plugin URI: http://wp.zackdesign.biz/rss-image-widget/ 
     4Plugin URI: http://zackdesign.biz/ 
    55Description: RSS Image display using SimplePie 
    66Author: Isaac Rowntree 
    7 Version: 1.4.2 
     7Version: 2.0.0 
    88Author URI: http://zackdesign.biz 
    99 
     
    1919 * RSSImages Class 
    2020 */ 
     21 
    2122class RSSImages extends WP_Widget { 
     23 
    2224    /** constructor */ 
    2325    function RSSImages() { 
     
    2527    } 
    2628 
     29 
    2730    /** @see WP_Widget::widget */ 
    28     function widget($args, $instance) {      
     31    function widget($args, $instance) { 
     32 
    2933        extract( $args ); 
     34 
    3035        $title = apply_filters('widget_title', $instance['title']); 
    3136         
    32     echo $before_widget;  
     37        echo $before_widget;  
     38             
     39        if ( $title ) { 
     40            echo $before_title . $title . $after_title;  
     41        } 
    3342         
    34     if ( $title ) 
    35             echo $before_title . $title . $after_title;  
    36      
    37     if (!empty($instance['url'])) 
    38         { 
    39         if (!class_exists('SimplePie')) 
    40             require_once(ABSPATH.'/wp-includes/class-simplepie.php'); 
    41          
    42         $feed = new SimplePie(); 
    43         $feed->set_feed_url($instance['url']); 
    44         $feed->set_cache_location( ABSPATH.'/wp-content/cache'); 
    45         $feed->init(); 
    46          
    47         if ($instance['images']) 
    48         { 
    49             echo '<div class="simplepie">'; 
    50              
    51             $count = 0; 
    52              
    53             foreach ($feed->get_items() as $item) 
    54             { 
    55             if ($count < $instance['images']) 
    56             {                
    57                 $count++; 
    58                 $url = ''; 
    59                  
    60                 if ($enclosure = $item->get_enclosure()) 
    61             {  
    62                  $url = $enclosure->get_link(); 
    63                  
    64                 if (empty($instance['width'])) 
    65                                 $instance['width'] = 150; 
    66                      
    67                 // Remove questions marks as well 
    68                 $image = str_replace("?", '', htmlspecialchars($item->get_title()).'.jpg'); 
    69                  
    70                 $cache_path = ABSPATH.'/wp-content/cache/rss_image_cache_'.date('n'); 
    71                  
    72                 // Create the image file if it doesn't exist 
    73                 if (!file_exists($cache_path.'/'.$image)) 
    74                 { 
    75                     if (!file_exists($cache_path)) 
    76                         mkdir($cache_path); 
    77                     $ch = curl_init($url); 
    78                     $fp = fopen($cache_path . '/' . $image, 'wb'); 
    79                     curl_setopt($ch, CURLOPT_FILE, $fp); 
    80                     curl_setopt($ch, CURLOPT_HEADER, 0); 
    81                     curl_exec($ch); 
    82                     curl_close($ch); 
    83                     fclose($fp); 
    84                 } 
    85                 }            
    86                  
    87                 echo ' 
    88                   <div class="rss_image"> 
    89             <a title="'.$item->get_title().'" class="gallery" href="'.get_bloginfo('wpurl').'/wp-content/cache/rss_image_cache_'.date('n').'/'.$image.'"><img src="'.get_bloginfo('wpurl').'/wp-content/cache/rss_image_cache_'.date('n').'/'.$image.'" alt="'.$item->get_title().'" width="' . $instance['width'] . '" /></a> 
    90             <h5><a title="'.$item->get_title().'" class="site" href="'.$item->get_permalink().'">'.$item->get_title().'</a></h5> 
    91                     </div><br />'; 
    92             } 
    93             else 
    94                 break; 
    95             } 
    96              
    97             echo '</div>'; 
    98         } 
    99     } 
     43        if (!empty($instance['url'])) { 
     44 
     45            if (!class_exists('SimplePie')) { 
     46                require_once(ABSPATH.'/wp-includes/class-simplepie.php'); 
     47            } 
     48             
     49            $feed = new SimplePie(); 
     50            $feed->set_feed_url($instance['url']); 
     51            // If image uploads work this will work 
     52            $feed->set_cache_location(wp_upload_dir()['basedir']);  
     53            $feed->init(); 
     54             
     55            if ($instance['images']) { 
     56                echo '<div class="row rss_image">'; 
     57                $count = 0; 
     58                 
     59                foreach ($feed->get_items() as $item) { 
     60 
     61                    if ($count < $instance['images']) {              
     62 
     63                        $count++; 
     64                        $url = ''; 
     65                         
     66                        if ($enclosure = $item->get_enclosure()) {  
     67                            $url = $enclosure->get_link(); 
     68                        } ?>  
     69<div class="col-xs-12"> 
     70    <a href="<?php echo $url; ?>" class="thumbnail gallery" data-lightbox="feed-gallery" data-title="<?php echo $item->get_title() ?>"> 
     71        <img src="<?php echo $url; ?>" alt="<?php echo $item->get_title(); ?>"> 
     72    </a> 
     73    <div class="caption"> 
     74        <h3><a href="<?php echo $item->get_link(); ?>" target="_blank" title="<?php echo $item->get_title(); ?>"><?php echo $item->get_title(); ?></a></h3> 
     75    </div> 
     76</div> 
     77<?php               } else { 
     78                        break; 
     79                    } 
     80                } 
     81                echo "</div>"; 
     82            } 
     83        } 
     84             
     85        echo $after_widget;  
     86        } 
     87 
     88        /** @see WP_Widget::update */ 
     89        function update($new_instance, $old_instance) {              
     90            return $new_instance; 
     91        } 
     92 
     93        /** @see WP_Widget::form */ 
     94        function form($instance) {               
     95            if (isset($instance['title'])) : $title = esc_attr($instance['title']); else : $title = ''; endif; 
     96        if (isset($instance['url'])) : $url = esc_attr($instance['url']); endif; 
     97        if (isset($instance['images'])) : $images = esc_attr($instance['images']); endif; 
    10098         
    101     echo $after_widget;  
    102     } 
    103  
    104     /** @see WP_Widget::update */ 
    105     function update($new_instance, $old_instance) {              
    106         return $new_instance; 
    107     } 
    108  
    109     /** @see WP_Widget::form */ 
    110     function form($instance) {               
    111         if (isset($instance['title'])) : $title = esc_attr($instance['title']); else : $title = ''; endif; 
    112     if (isset($instance['url'])) : $url = esc_attr($instance['url']); endif; 
    113     if (isset($instance['images'])) : $images = esc_attr($instance['images']); endif; 
    114     if (isset($instance['width'])) : $width = esc_attr($instance['width']); endif; 
    115      
    116     if (empty($url)) 
    117         $url = 'http://api.flickr.com/services/feeds/photos_public.gne?id=25087033@N04&lang=en-us&format=atom'; 
     99        if (empty($url)) 
     100            $url = 'http://api.flickr.com/services/feeds/photos_public.gne?id=25087033@N04&lang=en-us&format=atom'; 
     101             
     102        if (empty($images)) 
     103            $images = 5; 
    118104         
    119     if (empty($images)) 
    120         $images = 5; 
    121      
    122     if (empty($width)) 
    123         $width = 150; 
    124          
    125       ?> 
    126       <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p> 
    127         <p><label for="<?php echo $this->get_field_id('url'); ?>"><?php _e('Feed Url:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('url'); ?>" name="<?php echo $this->get_field_name('url'); ?>" type="text" value="<?php echo $url; ?>" /></label></p> 
    128         <p><label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('# of Images:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('images'); ?>" name="<?php echo $this->get_field_name('images'); ?>" type="text" value="<?php echo $images; ?>" /></label></p> 
    129         <p><label for="<?php echo $this->get_field_id('width'); ?>"><?php _e('Max Image Width:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo $width; ?>" /></label></p> 
    130       <?php  
     105        if (empty($width)) 
     106            $width = 150; 
     107             
     108          ?> 
     109          <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p> 
     110            <p><label for="<?php echo $this->get_field_id('url'); ?>"><?php _e('Feed Url:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('url'); ?>" name="<?php echo $this->get_field_name('url'); ?>" type="text" value="<?php echo $url; ?>" /></label></p> 
     111            <p><label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('# of Images:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('images'); ?>" name="<?php echo $this->get_field_name('images'); ?>" type="text" value="<?php echo $images; ?>" /></label></p> 
     112          <?php  
    131113    } 
    132114 
     
    136118  class RSSImagesMain { 
    137119   
    138     private $cachepath; 
    139      
    140120    function RSSImagesMain() { 
    141        $this->cachepath = ABSPATH.'/wp-content/cache'; 
    142        add_action('init', array($this, 'doEnqueue')); 
     121        add_action('init', array($this, 'doEnqueue')); 
     122        add_action('widgets_init', create_function('', 'return register_widget("RSSImages");')); // register RSSImages widget 
    143123    } 
    144124 
     
    149129    function shadowBoxScript() { 
    150130        if (!is_admin()) { 
    151           wp_enqueue_script('jquery'); 
    152           wp_register_script('shadowbox', plugins_url('/shadowbox-3.0.3/shadowbox.js', __FILE__));             
    153           wp_enqueue_script('shadowbox'); 
    154           wp_register_style('shadowbox', plugins_url('/shadowbox-3.0.3/shadowbox.css', __FILE__)); 
    155           wp_enqueue_style('shadowbox'); 
    156           wp_register_script('shadowBoxInitScript', plugins_url('/js/shadowbox-init.js', __FILE__)); 
    157           wp_enqueue_script('shadowBoxInitScript'); 
     131          wp_enqueue_script('lightbox', 'https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.7.1/js/lightbox.min.js', array('jquery'), '2.7.1', true); 
     132          wp_enqueue_style('lightbox', 'https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.7.1/css/lightbox.css'); 
    158133        } 
    159     } 
    160           
    161          
    162     function checkCache()  
    163     { 
    164       if (file_exists($this->cachepath))  
    165       { 
    166         add_action('widgets_init', create_function('', 'return register_widget("RSSImages");')); // register RSSImages widget 
    167       } 
    168       else 
    169       { 
    170         add_action('admin_notices', array(&$this, 'displayCacheError')); 
    171       } 
    172     } 
    173      
    174     function displayCacheError() 
    175     {         
    176         echo '<div class="error fade" style="background-color:red;"><p><strong>RSS Images: Error - Image cache not found, please create a cache folder under wp-content in your Wordpress folder. (e.g. <i>wp-content/cache</i>)</strong></p></div>';  
    177134    } 
    178135  } 
     
    182139{ 
    183140  $rssImages = new RSSImagesMain(); 
    184   $rssImages->checkCache(); 
    185    
    186    
    187141} 
Note: See TracChangeset for help on using the changeset viewer.