Make WordPress Core

Ticket #3834: 3834.diff

File 3834.diff, 1.4 KB (added by rob1n, 18 years ago)
  • wp-includes/rss.php

     
    817817        }
    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>";
     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.' );
    834840        }
    835                 else {
    836                         echo 'An error has occurred the feed is probably down, try again later.';
    837         }
    838841}
    839842
    840843function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS