WordPress.org

Plugin Directory

Changeset 417264


Ignore:
Timestamp:
07/30/11 16:18:19 (3 years ago)
Author:
stefsoton
Message:

Uploading version 0.5 of my plugin

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

Legend:

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

    r236220 r417264  
    44 * Plugin URI: http://www.stefaniamarchisio.com/rss-just-better-plugin-for-wordpress/ 
    55 * 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.4 
    7  * Author: Stefania Marchisio 
     6 * Version: 0.5 
     7 * Author: Stef Marchisio 
    88 * Author URI: http://stefaniamarchisio.com/about/ 
    99 * 
     
    8181    $title = apply_filters('widget_title', $instance['title'] ); 
    8282    $feed = $instance['name']; 
    83      
     83    $filter = $instance['filter']; 
     84 
    8485    $num = $instance['number']; 
    8586    $list = $instance['list']; 
     
    104105 
    105106    /* Call the function to read the feed content */ 
    106         echo rssjb_List($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex); 
     107        echo rssjb_List($feed, $filter, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex); 
    107108 
    108109    /* After widget (defined by themes). */ 
     
    119120    $instance['title'] = strip_tags($new_instance['title']); 
    120121    $instance['name'] = strip_tags($new_instance['name']); 
     122    $instance['filter'] = strip_tags($new_instance['filter']); 
     123 
     124 
    121125    $instance['number'] = strip_tags($new_instance['number']); 
    122126    $instance['charex'] = strip_tags($new_instance['charex']); 
     
    144148 
    145149    /* Default widget settings. */ 
    146     $defaults = array( 'title' => __('The Latest RSS Items', 'RSSjb'), 'name' => __('http://feeds.feedburner.com/StefaniasBlog?format=xml', 'RSSjb'), 'lkbtitle' => 'off', 'number' => '10', 'pubdate' => 'off', 'pubtime' => 'off', 'pubauthor' => 'on', 'excerpt' => 'off', 'charex' => '', 'list' => 'ul', 'target' => '_blank'); 
     150    $defaults = array( 'title' => __('The Latest RSS Items', 'RSSjb'), 'name' => __('http://feeds.feedburner.com/StefaniasBlog?format=xml', 'RSSjb'), 'lkbtitle' => 'off', 'filter' => '', 'number' => '5', 'pubdate' => 'off', 'pubtime' => 'off', 'pubauthor' => 'on', 'excerpt' => 'off', 'charex' => '150', 'list' => 'ul', 'target' => '_blank'); 
    147151 
    148152    $instance = wp_parse_args( (array) $instance, $defaults );  
     
    165169    <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%;" /> 
    166170    </p> 
     171 
     172    <!-- Text Filter: Text Input --> 
     173    <p> 
     174    <label for="<?php echo $this->get_field_id( 'filter' ); ?>"><?php _e('Keywords Filter:', 'RSSjb'); ?></label> 
     175    <input id="<?php echo $this->get_field_id( 'filter' ); ?>" name="<?php echo $this->get_field_name( 'filter' ); ?>" value="<?php echo $instance['filter']; ?>" style="width:100%;" /> 
     176    <br /><span style="font-size: 0.8em;">Example: with [foo -bar] items need to include "foo" and not "bar" words. Case insensitive, no wildchars, quotes, booleans or exact phrases are accepted.</span> 
     177    </p> 
    167178 
    168179    <!-- N. articles to display: Text Input --> 
     
    228239 * Add shortcode to wordpress 
    229240 */ 
    230 add_shortcode('RSSjb', 'RSSjb_funct'); 
    231  
    232 /** 
    233  * Add shortcode to wordpress 
    234  */ 
    235 function RSSjb_funct($atts) { 
    236      extract(shortcode_atts(array( 
    237      "feed" => '', 
    238      "num" => '3', 
    239      "list" => 'ul', 
    240      "target" => '_blank', 
    241      "pubdate" => false, 
    242      "pubtime" => false, 
    243      "pubauthor" => true, 
    244      "excerpt" => false, 
    245      "charex" => '', 
    246      "title" => '', 
    247      "link" => false 
    248      ), $atts)); 
    249  
    250      /* Display name from widget settings if one was input. */ 
    251      $tle = ""; 
    252      if ( $link || $title ) {  
    253         if ( $link ) $tle = "<a target='$target' href='$feed'><img src='/wp-content/plugins/google-news-widget/rss-cube.gif' width='25px' height='25px' alt=' [feed link] '></a> ";  
    254         $tle .= "<b>$title</b>";  
    255      }  
    256      return $tle . rssjb_List($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex); 
    257  
     241// add_shortcode('RSSjb', 'RSSjb_funct'); 
     242 
     243add_shortcode('RSSjb', array('RSSjbClass', 'RSSjb_funct')); 
     244 
     245/** 
     246 * Shortcode Class and Function 
     247 */ 
     248 
     249class RSSjbClass { 
     250 
     251    function RSSjb_funct($atts) { 
     252            extract(shortcode_atts(array( 
     253        "feed" => '', // required 
     254            "filter" => '', 
     255            "num" => '5', 
     256            "list" => 'ul', 
     257            "target" => '_blank', 
     258            "pubdate" => 'false', 
     259            "pubtime" => 'false', 
     260            "pubauthor" => 'true', 
     261            "excerpt" => 'false', 
     262            "charex" => '150', 
     263            "title" => '', 
     264            "link" => 'false' 
     265    ), $atts)); 
     266 
     267    // For debug purposes only 
     268    // echo "<h1>feed: $feed - filter: $filter - num: $num - list: $list - target: $target - pubdate: $pubdate - pubtime: $pubtime - pubauthor: $pubauthor - excerpt: $excerpt - charex: $charex - title: $title - link: $link</h1>"; 
     269     
     270    // taxonomy issue? 
     271    // if (!$feed) $jbfeed = $feed; 
     272 
     273    if ($feed) { 
     274 
     275        /* Display title and/or link-to-feed from given attributes */ 
     276            $tle = ""; 
     277            if ( $link !== false && $link !== "false" ) {  
     278            $tle = "<a target='$target' href='$feed'><img src='/wp-content/plugins/google-news-widget/rss-cube.gif' width='25px' height='25px' alt=' [feed link] '></a> ";  
     279        } 
     280            if ( $title ) {  
     281                $tle .= "<b>$title</b>";  
     282            }  
     283        return $tle . rssjb_List($feed, $filter, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex); 
     284    } else { 
     285 
     286        return "<br>Feed URL not provided. This shortcode does require an attribute as <code>feed = 'http://your-rss-or-atom-feed'</code>. Please, enter one.";  
     287 
     288    } 
     289    } 
    258290} 
    259291 
     
    264296*/ 
    265297 
    266 function rssjb_List($feed, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex) { 
     298function rssjb_List($feed, $filter, $num, $list, $target, $pubdate, $pubtime, $pubauthor, $excerpt, $charex) { 
    267299    include_once(ABSPATH . WPINC . '/feed.php'); 
    268300 
     
    278310    if (!is_wp_error( $rss )) { 
    279311        // Checks that the object is created correctly  
    280             // Figure out how many total items there are, but limit it to 5.  
    281             $numitems = $rss->get_item_quantity($num);  
     312            // Figure out how many total items there are, but limit it to the given value for $num.  
     313            // $numitems = $rss->get_item_quantity($num);  
    282314 
    283315            // Build an array of all the items, starting with element 0 (first element). 
    284             $rss_items = $rss->get_items(0, $numitems);  
     316            $rss_items = $rss->get_items(0, $rss->get_item_quantity());  
    285317 
    286318        // check whether it is an RSS format feed 
     
    289321 
    290322        $flist = "<$list>\n"; 
     323        $nitems = 0; 
    291324        foreach ( $rss_items as $item ) { 
    292             $flist .= "<li>"; 
    293             $title = $item->get_title(); 
    294             $desc = $item->get_description(); 
    295             $permalink = $item->get_permalink(); 
    296             if ( $title || $desc ) { 
    297                 if ( $permalink ) { 
    298                    $motext = isset( $desc ) ? strip_tags(str_replace("><","> <",$desc)): strip_tags($title); 
    299                    $flist .= "<a target='". $target . "' href='".$permalink."' title='$motext'>"; 
     325            $exclude = false; 
     326            $include = 0; 
     327            $includetest = false; 
     328            if ($filter) { 
     329                $aword = explode( ' ' , $filter ); 
     330                // count occurences of each $ainclude element in $title 
     331                foreach ( $aword as $word ) { 
     332                    if ( substr($word,0,1) == "-" ) { 
     333                        // this word needs to be excluded as it starts with a - 
     334                        stripos( $item->get_title(), substr($word,1) )===false?$exclude=false:$exclude=true; 
     335                        // if it finds the word that excludes the item, then breaks the loop 
     336                        if ($exclude) break; 
     337 
     338                    } else { 
     339                        $includetest=true; 
     340                        // this word needs to be included 
     341                        if ( stripos( $item->get_title(), $word )!==false) $include++; 
     342                        // if it finds the word that includes the item, then set the nclusion variable 
     343                        // i cannot break the look as i might still find exclusion words  
     344                    } 
     345                } 
     346            } // if ($filter) 
     347            // either (at least one occurrence of searched words is found AND no excluded words is found) 
     348            if ( !$exclude and ($includetest===false or $include>0)) { 
     349                $flist .= "<li>"; 
     350                // get title from feed 
     351                $title = $item->get_title(); 
     352                // get description from feed 
     353                $desc = $item->get_description(); 
     354 
     355                // get image from feed 
     356                // $img= $item->get_thumbnail(); 
     357                // $flist .= $img." "; 
     358 
     359                $permalink = $item->get_permalink(); 
     360                if ( $title || $desc ) { 
     361                    if ( $permalink ) { 
     362                    $motext = isset( $desc ) ? strip_tags(preg_replace('/\s+/', ' ', $desc)) : $title; 
     363                    $flist .= "<a target='". $target . "' href='".$permalink."' title='$motext'>"; 
     364                    } 
     365                    $flist .= isset( $title ) ? $title : $desc; 
     366                    if ( $permalink ) $flist .= "</a>";  
     367         
     368                    if ( $item->get_date() && $pubdate !== false && $pubdate !== "false" ) 
     369                    $flist .= ' - ' . date ( get_option('date_format'), strtotime( $item->get_date() )); 
     370 
     371                        if ( $item->get_date() && $pubtime !== false && $pubtime !== "false") 
     372                    $flist .= ' at ' . date ( get_option('time_format'), strtotime( $item->get_date() ));  
     373 
     374                    if ( $desc && $excerpt != false && $excerpt != "false") { 
     375                        if ( $charex > '0' ) {  
     376                            $flist .= '<br/>'. substr($desc, 0, $charex); 
     377                            $flist .= ' <a target="' . $target . '" href="' . esc_url( $desc ) . '">[...]</a>'; 
     378                        } else { 
     379                            $flist .= '<br/>'. $desc; 
     380                        }    
     381                    } 
     382                } else { 
     383                    $flist .= urlencode("<li>No standard <item> in file."); 
    300384                } 
    301                 $flist .= isset( $title ) ? $title : $desc; 
    302                 if ( $permalink )   $flist .= "</a>";  
    303          
    304                 if ( $item->get_date() && $pubdate !== false && $pubdate !== "false" ) 
    305                     $flist .= ' - ' . date ( get_option('date_format'), strtotime( $item->get_date() )); 
    306  
    307                     if ( $item->get_date() && $pubtime !== false && $pubtime !== "false") 
    308                     $flist .= ' at ' . date ( get_option('time_format'), strtotime( $item->get_date() ));  
    309  
    310                 if ( $desc && $excerpt != false && $excerpt != "false") { 
    311                     if ( $charex > '0' ) {  
    312                         $flist .= '<br/>'. substr($desc, 0, $charex); 
    313                         $flist .= ' <a target="' . $target . '" href="' . esc_url( $desc ) . '">[...]</a>'; 
    314                     } else { 
    315                         $flist .= '<br/>'. $desc; 
    316                     } 
    317                 } 
    318             } else { 
    319                 $flist .= urlencode("<li>No standard <item> in file."); 
    320             } 
    321             $flist .= "</li>"; 
     385                $flist .= "</li>"; 
     386                $nitems++; 
     387            } // if ($count>0 || !$filter) 
     388            if ($nitems >= $num) break; 
    322389        } // foreach 
    323390        $flist .= "</".$list.">\n"; 
     
    336403    // if pubauthor has been selected 
    337404    if ($pubauthor !== false && $pubauthor !== "false") { 
    338         $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>'; 
     405        $flist .= '<p style="text-align:center; font-size: 0.8em">powered by <a target="_blank" href=" * Plugin URI: http://www.stefaniamarchisio.com/rss-just-better-plugin-for-wordpress/">RSS Just Better</a></p>'; 
    339406    } 
    340407    return $flist; 
  • rss-just-better/trunk/readme.txt

    r236220 r417264  
    44Tags: RSS, Atom, feed, XML, syndication, syndicate, syndicating, news, widget, shortcode 
    55Requires at least: 2.8 
    6 Tested up to: 2.9.2 
    7 Stable tag: 0.4 
    8  
    9 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. 
     6Tested up to: 3.2 
     7Stable tag: 0.5 
    108 
    119== Description == 
     
    1513== Installation == 
    1614 
    17 1. From Plugins->Installed of your wordpress administration, select "Add new", search for "RSS just better" into the search text-box then click on 'Install' (on the right) when prompted with this plugin 
     151. The easiest way is: from Plugins of your wordpress administration, select "Add new", search for "RSS just better" into the search text-box then click on 'Install' (on the right) when prompted with this plugin 
    1816 
    1917                                    OR 
    2018 
    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.3.zip), unzip it (a directory with 2 files will be extracted) and upload it to the '/wp-content/plugins/' directory of your wordpress 
     19you can daownload this plugin from [wordpress repository](http://wordpress.org/extend/plugins/RSS-just-better/), unzip it (a directory with 2 files will be extracted) and upload it to the '/wp-content/plugins/' directory of your wordpress 
    2220 
    23 3. Activate the plugin through the Plugins->Installed menu in your WordPress administration 
     213. Activate the plugin through the Plugins->Installed Plugins menu in your WordPress administration 
    2422 
    25 4. Configure it (see Usage in Other Notes) 
     234. Use it! (see Usage in Other Notes) 
    2624 
    2725== Frequently Asked Questions == 
     
    2927= Why the heck would I need/want it? 
    3028 
    31 = 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?  
     29= It provides the latest items of any rss or atom feed on the Internet: can you imagine what boost of traffic it can bring to your blog?  
    3230Let'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. 
    3331 
    34 = Hey, I cannot find any configuration page in 'Settings' How does it work? 
     32= Hey, I cannot find any configuration page in 'Settings'! How do I use it? 
    3533 
    36 = As a widget, you drag & drop the widget to any widget-ready area of your theme; open and complete the widget form, and click on 'Save' button.  
    37 As a shortcode, you add/edit the post/page you want the news to be displayed into - IN HTML MODE! - and enter your shortcode as explained in Usage (in Other Notes).   
     34= As a widget, you drag & drop the widget to any widget-ready area of your theme; open and complete the widget form and click on the 'Save' button. Close the widget if you want. Check your wp site now. 
     35As a shortcode, choose the post or page you want your feed items to be displayed into, selecte HTML mode (IMPORTANT!) - and enter your shortcode as explained in Usage (in Other Notes).   
    3836 
    3937== Screenshots == 
    4038 
    41 1. Widget Form explained. 
     391. Widget Form with standard 
     402. Shortcode with all attributes 
    4241 
    4342== Changelog == 
     43 
     44= 0.5 = 
     45 
     46* Added attribute "filter" to include or exclude given words 
     47* Changed footer's author link to the plugin homepage 
     48* Set attribute Charex default value to 150 so that if excerpt is true, an excerpt is automatically displayed (for 150 chars). 
     49* Changed attribute num default value to 5 
     50* Enclosed shortcode in a class (it seems attribute feed collided with wordpress since 3.2) 
    4451 
    4552= 0.4 = 
     
    7380== Upgrade Notice == 
    7481 
     82= 0.5 = 
     83 
     84* Added attributed "filter" to include or exclude the given words 
     85 
    7586= 0.4 = 
    7687 
     
    101112As a widget: 
    102113 
    103 * Drag & Drop your widget in the widget-ready area; 
    104 * Enter a title to be given to this items list; 
    105 * Enter the feed URL of the items you wish to display; 
    106 * Choose whether you want the widget title linkable to the feed URL or not; 
    107 * Choose whether you want a publication date/time, excerpt (and for how many char) or not; 
    108 * Select whether you want a dotted list (default) or a numbered/ordered list; 
    109 * Select whether you want the linked items to open up in a new page (default) or in the same page; 
    110 * Choose whether you allow this plugin's author footer to be displayed or not (please, say yes); 
    111 * Click on 'Save' (and Close, if you want). 
     114* in Appearance - > Widgets of your wp administration, drag & drop the RSS Just Better widget to any widget-ready area of your wp; 
     115* Now, complete the widget form: enter a title to be given to your items list; 
     116** Enter the rss or atom feed (the URL) of the items you wish to display; 
     117** Enter enter any keyword which needs to be present or excluded in the titles of the choosen feed's items. (*) 
     118** Choose whether you want the widget title linkable to the feed (URL) or not; 
     119** Choose whether you want a publication date/time, excerpt (and for how many char) or not; 
     120** Select whether you want a dotted list (default) or a numbered/ordered list; 
     121** Select whether you want the linked items to open up in a new page (default) or in the same page; 
     122** Choose whether you allow this plugin's author footer to be displayed or not (please, say yes); 
     123** Click on 'Save' (and 'Close' the widget form, if you want). 
    112124 
    113125As a shortcode: 
    114126 
    115 * Your admin wp page->Posts/Pages->Add New or Edit, select HTML in the entry form; 
    116 * enter [RSSjb feed="..."] where "..." is any website feed you wish to display;  
     127* In Posts/Pages->Add New or Edit of your wp adminstration, select the HTML tab in the entry form; 
     128* enter [RSSjb feed="..."] where "..." is any rss or atom feed you wish to display;  
    117129That's the sole mandatory attribute. Optional attributes are: 
    118130 
     131* filter: enter any keyword which needs to be present or avoided in the titles of the choosen feed's items. (*) 
    119132* num: number of items to be displayed (default: 3); 
    120 * pubdate: either true or false to display the publication date/not; 
    121 * pubtime: either true or false to display the publication time/not; 
    122 * excerpt: either true or false to display the excerpt/not; 
     133* pubdate: either true or false to display the publication date/not (default: false); 
     134* pubtime: either true or false to display the publication time/not (default: false); 
     135* excerpt: either true or false to display the excerpt/not (default: false); 
    123136* charex: limit the number of the ecerpt chars to be displayed; 
    124 * list: either "UL" or "OL" to get unordered or ordered lists; 
    125 * target: either "_blank" or "_self" to get links opened in new/the same windows; 
    126 * pubauthor: true/false whether you allow this plugin's author footer to be displayed or not (please, say yes); 
     137* list: either "ul" or "ol" to get unordered or ordered lists (default: "ul"); 
     138* target: either "_blank" or "_self" to get links opened in a new or the same window (default: "_blank"); 
     139* pubauthor: true/false whether you allow this plugin's author footer to be displayed or not (please, say yes) (default: "_blank"); 
    127140 
    128 Example: [RSSjb feed="" num="8" list="OL" target="_self"] 
     141(*) Notes on 'filter' attribute: 
     142You can enter one of more words to be able to select your feed's items by keyword. 
     143So if you write "foo bar" you will INCLUDE ONLY those titles where ANY of the two word(s) is present  
     144and if you write "-foo -bar" you will EXCLUDE ALL those titles where any of the two words is present instead. 
     145You can also mix inclusive and exclusive terms as in "foo -bar" of course (it will include only titles with "foo" and without "bar".) 
     146Search is case insensitive and searches for keywords in the titles only. 
     147Wildshars, quotes and boolean are not enabled for this search. 
     148 
     149Example of shortcode with all attributes and default values:  
     150[RSSjb feed="http://feeds.feedburner.com/StefaniasBlog" filter="" num="5", list="ul", target="_blank", pubdate="false", pubtime="false", pubauthor="true", excerpt="false", charex="150", title="", link="false"] 
    129151 
    130152== The Future == 
    131 * Less-nerdy attributes values. 
     153* images view 
     154* search for description too (new attribute) 
     155* integration with google news(?) 
     156 
    132157 
    133158== Interaction == 
Note: See TracChangeset for help on using the changeset viewer.