WordPress.org

Make WordPress Core

Changeset 5698


Ignore:
Timestamp:
06/13/07 17:23:38 (8 years ago)
Author:
rob1n
Message:

wp_rss() updates. fixes #3834

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/rss.php

    r5312 r5698  
    818818} 
    819819 
    820 function wp_rss ($url, $num_items) { 
    821     //ini_set("display_errors", false); uncomment to suppress php errors thrown if the feed is not returned. 
    822     $rss = fetch_rss($url); 
    823         if ( $rss ) { 
    824             echo "<ul>"; 
    825             $rss->items = array_slice($rss->items, 0, $num_items); 
    826                 foreach ($rss->items as $item ) { 
    827                     echo "<li>\n"; 
    828                     echo "<a href='$item[link]' title='$item[description]'>"; 
    829                     echo htmlentities($item['title']); 
    830                     echo "</a><br />\n"; 
    831                     echo "</li>\n"; 
    832                 } 
    833             echo "</ul>"; 
    834     } 
    835         else { 
    836             echo 'An error has occurred the feed is probably down, try again later.'; 
     820function wp_rss( $url, $num_items = -1 ) { 
     821    if ( $rss = fetch_rss( $url ) ) { 
     822        echo '<ul>'; 
     823         
     824        if ( $num_items !== -1 ) { 
     825            $rss->items = array_slice( $rss->items, 0, $num_items ); 
     826        } 
     827         
     828        foreach ( $rss->items as $item ) { 
     829            printf( 
     830                '<li><a href="%1$s" title="%2$s">%3$s</a></li>',  
     831                clean_url( $item['link'] ),  
     832                attribute_escape( strip_tags( $item['description'] ) ),  
     833                htmlentities( $item['title'] ) 
     834            ); 
     835        } 
     836         
     837        echo '</ul>'; 
     838    } else { 
     839        _e( 'An error has occurred, which probably means the feed is down. Try again later.' ); 
    837840    } 
    838841} 
Note: See TracChangeset for help on using the changeset viewer.