wp_rss() updates. fixes #3834

git-svn-id: https://develop.svn.wordpress.org/trunk@5698 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
rob1n 2007-06-13 17:23:38 +00:00
parent 3cfb7f5602
commit 60794fc8e2

View File

@ -817,23 +817,26 @@ function parse_w3cdtf ( $date_str ) {
} }
} }
function wp_rss ($url, $num_items) { function wp_rss( $url, $num_items = -1 ) {
//ini_set("display_errors", false); uncomment to suppress php errors thrown if the feed is not returned. if ( $rss = fetch_rss( $url ) ) {
$rss = fetch_rss($url); echo '<ul>';
if ( $rss ) {
echo "<ul>"; if ( $num_items !== -1 ) {
$rss->items = array_slice( $rss->items, 0, $num_items ); $rss->items = array_slice( $rss->items, 0, $num_items );
}
foreach ( $rss->items as $item ) { foreach ( $rss->items as $item ) {
echo "<li>\n"; printf(
echo "<a href='$item[link]' title='$item[description]'>"; '<li><a href="%1$s" title="%2$s">%3$s</a></li>',
echo htmlentities($item['title']); clean_url( $item['link'] ),
echo "</a><br />\n"; attribute_escape( strip_tags( $item['description'] ) ),
echo "</li>\n"; htmlentities( $item['title'] )
);
} }
echo "</ul>";
} echo '</ul>';
else { } else {
echo 'An error has occurred the feed is probably down, try again later.'; _e( 'An error has occurred, which probably means the feed is down. Try again later.' );
} }
} }