WordPress.org

Plugin Directory

Changeset 217734


Ignore:
Timestamp:
03/15/10 13:47:18 (4 years ago)
Author:
stefsoton
Message:

uploading version 0.2

Location:
rss-just-better
Files:
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • rss-just-better/trunk/RSS-just-better.php

    r213996 r217734  
    33 * Plugin Name: RSS Just Better 
    44 * Plugin URI: http://www.stefaniamarchisio.com/RSS-Just-Better/ 
    5  * Description: A list of RSS items given the feed URL and the number of displayable Items. It works as both widget and shortcode. 
    6  * Version: 0.1 
     5 * Description: A customizable list of feed items given: URL and number of displayable items. It works as both widget and shortcode. Compatible with RSS vers. 0.91, 0.92 and 2.0. Not compatible with Atom. 
     6 * Version: 0.2 
    77 * Author: Stefania Marchisio 
    88 * Author URI: http://stefaniamarchisio.com/about/ 
     
    1515/*  
    1616This is a wordpress plugin compatible with wordpress 2.8+ as a widget; wordpress 2.5+ as shortcode. 
    17 From the readme.txt: 
    18 A list of RSS items given the feed URL and the number of displayable items. It works as both widget and shortcode. 
    1917 
    2018Copyright (C) 2010  Stefania Marchisio (email: mywizardwebs@gmail.com) 
     
    8684        $list = $instance['list']; 
    8785        $target= $instance['target']; 
     86        $lkbtitle = isset( $instance['lkbtitle'] ) ? $instance['lkbtitle'] : false; 
    8887        $pubdate = isset( $instance['pubdate'] ) ? $instance['pubdate'] : false; 
    8988        $pubtime = isset( $instance['pubtime'] ) ? $instance['pubtime'] : false; 
     
    9695 
    9796        /* Display the widget title if one was input (before and after defined by themes). */ 
    98         if ( $title ) 
    99             echo $before_title . $title . $after_title; 
     97        if ( $title ) { 
     98                   if ( $lkbtitle ) $title = "<a target='_blank' href='$feed' title='$title'>$title</a>"; 
     99                   echo $before_title . $title . $after_title; 
     100                } 
    100101 
    101102        /* Call the function to  */ 
    102     echo rssjb_FeedList($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex); 
     103                echo rssjb_FeedList($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex); 
    103104 
    104105        /* After widget (defined by themes). */ 
     
    123124 
    124125        /* No need to strip tags for boolean */ 
     126        $instance['lkbtitle'] = $new_instance['lkbtitle']; 
    125127        $instance['pubdate'] = $new_instance['pubdate']; 
    126128        $instance['pubtime'] = $new_instance['pubtime']; 
     
    140142 
    141143        /* Default widget settings. */ 
    142         $defaults = array( 'title' => __('The Latest RSS Items', 'RSSjb'), 'name' => __('http://feeds.feedburner.com/StefaniasBlog', 'RSSjb'), 'number' => '10', 'pubdate' => 'off', 'pubtime' => 'off', 'pubauthor' => 'on', 'excerpt' => 'off', 'charex' => ''); 
     144        $defaults = array( 'title' => __('The Latest RSS Items', 'RSSjb'), 'name' => __('http://feeds.feedburner.com/StefaniasBlog', 'RSSjb'), 'lkbtitle' => 'off', 'number' => '10', 'pubdate' => 'off', 'pubtime' => 'off', 'pubauthor' => 'on', 'excerpt' => 'off', 'charex' => ''); 
    143145 
    144146        $instance = wp_parse_args( (array) $instance, $defaults );  
     
    150152    </p> 
    151153 
    152     <!-- RSS feed: Text Input --> 
    153     <p> 
    154         <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e('RSS Feed:', 'RSSjb'); ?></label> 
     154    <!-- Feed URL: Text Input --> 
     155    <p> 
     156        <label for="<?php echo $this->get_field_id( 'name' ); ?>"><?php _e('Feed URL:', 'RSSjb'); ?></label> 
    155157        <input id="<?php echo $this->get_field_id( 'name' ); ?>" name="<?php echo $this->get_field_name( 'name' ); ?>" value="<?php echo $instance['name']; ?>" style="width:100%;" /> 
     158    </p> 
     159 
     160    <!-- Link Title to Feed? Checkbox --> 
     161    <p> 
     162        <label for="<?php echo $this->get_field_id( 'lkbtitle' ); ?>"><?php _e('Link Widget Title to Feed URL?', 'RSSjb'); ?></label> 
     163        <input class="checkbox" type="checkbox" <?php checked( $instance['lkbtitle'], 'on' ); ?> id="<?php echo $this->get_field_id( 'lkbtitle' ); ?>" name="<?php echo $this->get_field_name( 'lkbtitle' ); ?>" />  
    156164    </p> 
    157165 
     
    246254 
    247255function rssjb_FeedList($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex) { 
    248      include_once(ABSPATH . WPINC . '/rss.php'); 
    249  
    250      if ( $feed != "" && $rss = fetch_rss( $feed ) ) { 
     256   // decoding needed when you use a shortcode as URLs are encoded by the shortcode 
     257   $feed = html_entity_decode($feed);   
     258   if ( $feed != "" && $rss = simplexml_load_file($feed) ) { 
    251259        $fList = "<$list>\n"; 
    252     // for ($i = 0; $i < $num; $i++) { 
    253         if ( $num >0 ) { $rss->items = array_slice( $rss->items, 0, $num ); } 
    254     foreach ( (array) $rss->items as $item ) { 
    255        // $item = $rss->items[$i]; 
     260    $i = 0; 
     261 
     262/* 
     263From URL: http://www.rssboard.org/rss-2-0-1#hrelementsOfLtitemgt 
     264(The latest specification of an RSS feed (2.0.1). Backcompatible with versions 2.0, 0.92, 0.91) 
     265A channel may contain any number of <item>s. An item may represent a "story" -- much like a story in a newspaper or magazine; if so its description is a synopsis of the story, and the link points to the full story. An item may also be complete in itself, if so, the description contains the text (entity-encoded HTML is allowed), and the link and title may be omitted. All elements of an item are optional, however at least one of title or description must be present.  
     266*/ 
     267        foreach ($rss->channel->item as $item ) { 
     268       $i++; 
    256269           $fList .= '<li>'; 
    257        $fList .= '<a target="'. $target . '" href="'.esc_url( $item['link'] ).'">'. $item['title'] .'</a>'; 
    258        if ( $pubdate !== false && $pubdate !== "false") { 
    259           $fList .= ' - ' . date ( 'd M y', strtotime( $item['pubdate'] )); 
    260            }  
    261  
    262            if ( $pubtime !== false && $pubtime !== "false") { 
    263           $fList .= ' at ' . date ( 'H:i', strtotime( $item['pubdate'] ));  
    264            } 
    265            if ( $excerpt != false && $excerpt != "false") { 
    266                 if ( $charex > 0 ) {  
    267            $fList .= '<br/>'. substr($item['summary'], 0, $charex); 
    268            $fList .= ' <a target="' . $target . '" href="' . esc_url( $item['link'] ) . '">[...]</a>'; 
    269                } else { 
    270            $fList .= '<br/>'. $item['summary']; 
    271                } 
    272            }  
    273            $fList .= '</li>'; 
    274      } 
    275         $fList .= "</".$list.">\n"; 
     270 
     271      if (!$item->title && !$item->description) { 
     272              $fList .= "Invalid feed item."; 
     273          } else { 
     274          if ( $item->link ) { 
     275                 $motext = isset( $item->description) ? $item->description: $item->title; 
     276                 $fList .= "<a target='". $target . "' href='$item->link' title='$motext'>"; 
     277              } 
     278 
     279              $fList .= isset( $item->title) ? $item->title : $item->description; 
     280          if ( $item->link ) { $fList .= "</a>"; }  
     281 
     282          if ( $item->pubDate && $pubdate !== false && $pubdate !== "false" ) { 
     283             $fList .= ' - ' . date ( 'd M y', strtotime( $item->pubDate )); 
     284              }  
     285 
     286              if ( $item->pubDate && $pubtime !== false && $pubtime !== "false") { 
     287             $fList .= ' at ' . date ( 'H:i', strtotime( $item->pubDate ));  
     288              } 
     289 
     290              if ( $excerpt != false && $excerpt != "false") { 
     291                 if ( $charex > '0' ) {  
     292            $fList .= '<br/>'. substr($item->description, 0, $charex); 
     293            $fList .= ' <a target="' . $target . '" href="' . esc_url( $item->link ) . '">[...]</a>'; 
     294                 } else { 
     295            $fList .= '<br/>'. $item->description; 
     296                 } 
     297             }  
     298          }            
     299 
     300        $fList .= '</li>'; 
     301    if ($i >= $num) break; 
     302        } 
     303     $fList .= "</".$list.">\n"; 
    276304     }  
    277         if ($pubauthor !== false && $pubauthor !== "false") { 
    278             $fList .= '<p style="text-align:center; font-size: 0.7em">powered by <a target="_blank" href="http://www.stefaniamarchisio.com/portfolio/">RSS Just Better plugin</a></p>'; 
     305    if ($pubauthor !== false && $pubauthor !== "false") { 
     306        $fList .= '<p style="text-align:center; font-size: 0.7em">powered by <a target="_blank" href="http://www.stefaniamarchisio.com/portfolio/">RSS Just Better plugin</a></p>'; 
    279307    }  
    280308    return $fList; 
    281309} 
    282  
    283310?> 
  • rss-just-better/trunk/readme.txt

    r214053 r217734  
    22Contributors: stefsoton 
    33Donate link: http://www.stefaniamarchisio.com/donations/ 
    4 Tags: RSS, Atom, feed, XML, news, widget, shortcode 
     4Tags: RSS, Atom, feed, XML, syndication, news, widget, shortcode 
    55Requires at least: 2.8 
    66Tested up to: 2.9.2 
    7 Stable tag: 0.1 
     7Stable tag: 0.2 
    88 
    9 A customizable list of RSS items given: URL and the number of displayable items. It works as both widget and shortcode.  
     9A customizable list of feed items given: URL and number of displayable items. Compatible with RSS 0.91, 0.92, 2.0. Not compatible with Atom. 
    1010 
    1111== Description == 
    1212 
    13 It displays a list of RSS items given: feed URL, the number of displayable items and whether you want publication date, time and excerpt (and how many chars of it). The user can choose to have a ordered (numbered) or unordered (bullet-point) list and to open a new windows or not when clicking on the linked items. 
     13It displays a list of feed items from a given feed URL. You can select the number of displayable items, whether you want publication date, time and/or excerpt (and how many chars of it). The user can choose to have a ordered (numbered) or unordered (bullet-point) list and to open a new windows or not, when clicking on the linked items. 
    1414 
    1515== Installation == 
     
    1919                                    OR 
    2020 
    21 2. Download this plugin from [wordpress repository](http://wordpress.org/extend/plugins/RSS-just-better/) or from [Stefania's blog](http://www.stefaniamarchisio.com/wp-content/uploads/2010/03/RSS-just-better-0.1.zip), unzip it (a directory with 2 files will be extracted) and upload it to the '/wp-content/plugins/' directory of your wordpress 
     212. Download this plugin from [wordpress repository](http://wordpress.org/extend/plugins/RSS-just-better/) or from [Stefania's blog](http://www.stefaniamarchisio.com/wp-content/uploads/2010/03/RSS-just-better-0.2.zip), unzip it (a directory with 2 files will be extracted) and upload it to the '/wp-content/plugins/' directory of your wordpress 
    2222 
    23233. Activate the plugin through the Plugins->Installed menu in your WordPress administration 
     
    3030 
    3131= Well, it provides the latest items of any feed on the Internet: can you imagine what boost of traffic it can bring to your blog?  
    32 Let's pretend you write about volleyball, knitting or lactose-intolerance. You just need to enter the relevant feed in the 'feed URL' and wait for it to display always the latest items on your subject (live). 
     32Let's pretend you write about volleyball, knitting or lactose-intolerance. You just need to enter the relevant feed in the feed URL and wait for it to display the latest items on your subject. 
    3333 
    3434= Hey, I cannot find any configuration page in 'Settings' How does it work? 
     
    4343== Changelog == 
    4444 
     45= 0.2 = 
     46 
     47* Fixed a bug which prevented the shortcode to show feeds from URLs containing & and = 
     48* Made it fully compatible with RSS version 0.92, 2.0, 2.0.1 where link and title might be omitted 
     49* Made the widget title linkable to the feed URL 
     50* Used the native PHP class simpleXML instead of the Wordpress feed parser (Magpie) 
     51 
    4552= 0.1 = 
    4653 
     
    4855 
    4956== Upgrade Notice == 
     57 
     58= 0.2 = 
     59 
     60* Fixed a bug which prevented the shortcode to show feeds from URLs containing & and = 
     61* Made it fully compatible with RSS version 0.92, 2.0, 2.0.1 where link and title might be omitted 
     62* Made the widget title linkable to the feed URL 
    5063 
    5164= 0.1 = 
     
    6073* Enter a title to be given to this items list; 
    6174* Enter the feed URL of the items you wish to display; 
     75* Choose whether you want the widget title linkable to the feed URL or not; 
    6276* Choose whether you want a publication date/time, excerpt (and for how many char) or not; 
    6377* Select whether you want a dotted list (default) or a numbered/ordered list; 
     
    7690* pubtime: either true or false to display the publication time/not; 
    7791* excerpt: either true or false to display the excerpt/not; 
    78 * charex: number of the ecerpt chars to be displayed/not; 
     92* charex: limit the number of the ecerpt chars to be displayed; 
    7993* list: either "UL" or "OL" to get unordered or ordered lists; 
    8094* target: either "_blank" or "_self" to get links opened in new/the same windows; 
Note: See TracChangeset for help on using the changeset viewer.