WordPress.org

Plugin Directory

Changeset 219112


Ignore:
Timestamp:
03/18/10 17:27:01 (4 years ago)
Author:
stefsoton
Message:

upload new version 0.3 compatible with Atom 1.0

Location:
rss-just-better/trunk
Files:
2 edited

Legend:

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

    r217743 r219112  
    33 * Plugin Name: RSS Just Better 
    44 * Plugin URI: http://www.stefaniamarchisio.com/rss-just-better-plugin-for-wordpress/ 
    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 
     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 & Atom 1.0. 
     6 * Version: 0.3 
    77 * Author: Stefania Marchisio 
    88 * Author URI: http://stefaniamarchisio.com/about/ 
     
    5858class WP_RSSjb extends WP_Widget { 
    5959 
    60     /** 
    61     * Widget setup. 
    62     */ 
    63     function WP_RSSjb() { 
    64         /* Widget settings. */ 
    65         $widget_ops = array( 'classname' => 'rssjustbetter', 'description' => __('A list of RSS items given feed URLs and number of displayable news. It works as both widget and shortcode', 'RSSjb') ); 
    66  
    67         /* Widget control settings. */ 
    68         $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'rss-just-better' ); 
    69  
    70         /* Create the widget. */ 
    71         $this->WP_Widget( 'rss-just-better', __('RSS Just Better', 'RSSjb'), $widget_ops, $control_ops ); 
    72     } 
    73  
    74     /** 
    75     * How to display the widget on the screen. 
    76     */ 
    77     function widget( $args, $instance ) { 
    78         extract( $args ); 
    79  
    80         /* Our variables from the widget settings. */ 
    81         $title = apply_filters('widget_title', $instance['title'] ); 
    82         $feed = $instance['name']; 
    83         $num = $instance['number']; 
     60/** 
     61 * Widget setup. 
     62 */ 
     63 function WP_RSSjb() { 
     64 /* Widget settings. */ 
     65 $widget_ops = array( 'classname' => 'rssjustbetter', 'description' => __('A customizable list of feed items given: URL and number of displayable items. Also available as shortcode. Compatible with RSS vers. 0.91, 0.92 and 2.0 & Atom 1.0.', 'RSSjb') ); 
     66 
     67 /* Widget control settings. */ 
     68 $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'rss-just-better' ); 
     69 
     70 /* Create the widget. */ 
     71 $this->WP_Widget( 'rss-just-better', __('RSS Just Better', 'RSSjb'), $widget_ops, $control_ops ); 
     72 } 
     73 
     74/** 
     75 * How to display the widget on the screen. 
     76 */ 
     77 function widget( $args, $instance ) { 
     78  extract( $args ); 
     79 
     80  /* Our variables from the widget settings. */ 
     81  $title = apply_filters('widget_title', $instance['title'] ); 
     82  $feed = $instance['name']; 
     83  $num = $instance['number']; 
    8484        $list = $instance['list']; 
    8585        $target= $instance['target']; 
     
    101101 
    102102        /* Call the function to  */ 
    103                 echo rssjb_FeedList($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex); 
     103                echo rssjb_List($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex); 
    104104 
    105105        /* After widget (defined by themes). */ 
     
    142142 
    143143        /* Default widget settings. */ 
    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' => ''); 
     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' => '', 'list' => 'UL', 'target' => '_blank'); 
    145145 
    146146        $instance = wp_parse_args( (array) $instance, $defaults );  
     
    247247     /* Display name from widget settings if one was input. */ 
    248248     if ( $feed ) {  
    249         return rssjb_FeedList($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex); 
     249        return rssjb_List($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex); 
    250250     } else { 
    251251        return "Error: No Feed given in the shortcode."; 
    252252     } 
    253253} 
    254  
    255 function rssjb_FeedList($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex) { 
    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) ) { 
    259         $fList = "<$list>\n"; 
    260     $i = 0; 
    261254 
    262255/* 
     
    265258A 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.  
    266259*/ 
    267         foreach ($rss->channel->item as $item ) { 
    268        $i++; 
    269            $fList .= '<li>'; 
    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"; 
    304      }  
     260 
     261function rssjb_List($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex) { 
     262    // decoding needed when you use a shortcode as URLs are encoded by the shortcode 
     263    $feed = html_entity_decode($feed);   
     264       $flist = "Error message: "; 
     265 
     266    // check whether a feed URL has been entered 
     267    if ($feed) { 
     268        libxml_use_internal_errors(true); 
     269        if ( $rss = simplexml_load_file($feed) ) {  
     270            // check whether it is an RSS format feed 
     271                if (array_key_exists('item', $rss->channel)) { 
     272                // $flist = "We have an RSS feed: make a list our of this: "; 
     273 
     274                $flist = "<$list>\n"; 
     275                $i = 0; 
     276                foreach ($rss->channel->item as $item ) { 
     277                    $flist .= "<li>"; 
     278                    if ($item->title || $item->description) { 
     279 
     280                    if ( $item->link ) { 
     281                        $motext = isset( $item->description ) ? htmlentities($item->description): htmlentities($item->title); 
     282                        $flist .= "<a target='". $target . "' href='$item->link' title='$motext'>"; 
     283                    } 
     284 
     285                    $flist .= isset( $item->title ) ? htmlentities($item->title) : htmlentities($item->description); 
     286 
     287                    if ( $item->link ) 
     288                        $flist .= "</a>";  
     289         
     290                    if ( $item->pubDate && $pubdate !== false && $pubdate !== "false" ) 
     291                        $flist .= ' - ' . date ( 'd M y', strtotime( $item->pubDate )); 
     292 
     293                          if ( $item->pubDate && $pubtime !== false && $pubtime !== "false") 
     294                        $fList .= ' at ' . date ( 'H:i', strtotime( $item->pubDate ));  
     295 
     296                    if ( $item->description && $excerpt != false && $excerpt != "false") { 
     297                        if ( $charex > '0' ) {  
     298                            $flist .= '<br/>'. substr($item->description, 0, $charex); 
     299                            $flist .= ' <a target="' . $target . '" href="' . esc_url( $item->link ) . '">[...]</a>'; 
     300                        } else { 
     301                            $flist .= '<br/>'. $item->description; 
     302                        } 
     303                    }  
     304                     
     305                    } else { 
     306                        $flist .= "No standard <item> in file"; 
     307                    } 
     308                    $flist .= "</li>"; 
     309                    $i++; 
     310                    if ($i >= $num) break; 
     311                } // foreach 
     312                $flist .= "</".$list.">\n"; 
     313 
     314            // otherwise check whether it is an Atom format feed 
     315            } elseif (array_key_exists('entry', $rss)) { 
     316                // $flist = "We have a Atom feed: make a list our of this: "; 
     317 
     318                $flist = "<$list>\n"; 
     319                $i = 0; 
     320 
     321                foreach ($rss->entry as $entry ) { 
     322                    $flist .= "<li>"; 
     323                    if ($entry->title && $entry->id && $entry->updated) { 
     324 
     325                    if ( $entry->link ) { 
     326                        $motext = isset( $entry->summary ) ? htmlentities($entry->summary): htmlentities($entry->title); 
     327                        $flist .= "<a target='". $target . "' href='$entry->link' title='$motext'>"; 
     328                    } 
     329 
     330                    $flist .= htmlentities($entry->title); 
     331 
     332                    if ( $entry->link ) $flist .= "</a>"; 
     333  
     334                    if ( $entry->updated && $pubdate !== false && $pubdate !== "false" ) 
     335                        $flist .= ' - ' . date ( 'd M y', strtotime( $entry->updated )); 
     336 
     337                          if ( $entry->updated && $pubtime !== false && $pubtime !== "false") 
     338                        $flist .= ' at ' . date ( 'H:i', strtotime( $entry->updated ));  
     339 
     340                    if ( $entry->summary && $excerpt != false && $excerpt != "false") { 
     341                        if ( $charex > '0' ) {  
     342                            $flist .= '<br/>'. substr($entry->summary, 0, $charex); 
     343                            $flist .= ' <a target="' . $target . '" href="' . esc_url( $entry->link ) . '">[...]</a>'; 
     344                        } else { 
     345                            $flist .= '<br/>'. $entry->summary; 
     346                        } 
     347                    }  
     348 
     349                    //$flist .= "Entry $i "; 
     350                    } else { 
     351                        $flist .= "No standard <entry> in file"; 
     352                    } 
     353                    $flist .= "</li>"; 
     354 
     355                    $i++; 
     356                    if ($i >= $num) break; 
     357                } // foreach 
     358 
     359                $flist .= "</".$list.">\n"; 
     360 
     361            } else { 
     362                $flist .= "No typical RSS or Atom feed or not supported by this plugin."; 
     363            } 
     364        } else { 
     365            $flist .= "<i>" . $feed . "</i> not found or is no standard XML file.";  
     366        } 
     367    } else { 
     368        $flist .= "Feed URL not provided. I do need an URL to a RSS or Atom XML file. Please, enter one.";  
     369    } 
     370    // if pubauthor has been selected 
    305371    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>'; 
    307     }  
    308     return $fList; 
     372        $flist .= '<p style="text-align:center; font-size: 0.8em">powered by <a target="_blank" href="http://www.stefaniamarchisio.com/portfolio/">RSS Just Better plugin</a></p>'; 
     373    } 
     374    return $flist; 
    309375} 
    310376?> 
  • rss-just-better/trunk/readme.txt

    r217734 r219112  
    22Contributors: stefsoton 
    33Donate link: http://www.stefaniamarchisio.com/donations/ 
    4 Tags: RSS, Atom, feed, XML, syndication, news, widget, shortcode 
     4Tags: RSS, Atom, feed, XML, syndication, syndicate, syndicating, news, widget, shortcode 
    55Requires at least: 2.8 
    66Tested up to: 2.9.2 
    7 Stable tag: 0.2 
     7Stable tag: 0.3 
    88 
    9 A 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. 
     9A 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 & Atom 1.0. 
    1010 
    1111== Description == 
     
    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.2.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.3.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 
     
    4343== Changelog == 
    4444 
     45= 0.3 = 
     46 
     47* Made it fully compatible with Atom 1.0 
     48* Added proper error messages for: empty, non-existing URLs and invalid/misformatted feeds content 
     49* Added defaults for target and list (widget fields) 
     50* Added instruction to hide Warnings from the xmlsimple_load_file function 
     51* Fixed a bug which prevented proper display of description/summary with tags 
     52 
    4553= 0.2 = 
    4654 
     
    5563 
    5664== Upgrade Notice == 
     65 
     66= 0.3 = 
     67 
     68* Made it fully compatible with Atom 1.0 
     69* Added proper error messages for: empty, non-existing URLs and invalid/misformatted feeds content 
    5770 
    5871= 0.2 = 
     
    98111 
    99112== The Future == 
    100 * Better error messaging; 
    101113* Less-nerdy attributes values. 
    102114 
Note: See TracChangeset for help on using the changeset viewer.