Make WordPress Core

Ticket #26560: 26560.2.patch

File 26560.2.patch, 1.7 KB (added by stevenkword, 10 years ago)
  • wp-includes/rss.php

     
    886886                }
    887887
    888888                foreach ( (array) $rss->items as $item ) {
    889                         printf(
    890                                 '<li><a href="%1$s" title="%2$s">%3$s</a></li>',
     889                        $item_output = sprintf(
     890                                '<li><a href="%1$s">%2$s</a></li>',
    891891                                esc_url( $item['link'] ),
    892                                 esc_attr( strip_tags( $item['description'] ) ),
    893892                                esc_html( $item['title'] )
    894893                        );
     894
     895                        /**
     896                         * Filter the output of individual RSS items.
     897                         *
     898                         * Provides an opportunity to customize the output of RSS items,
     899                         * so the descriptions can be shown in a more accessible way.
     900                         *
     901                         * @since 4.2.0
     902                         *
     903                         * @param string $item_output Rendered output of an individual RSS item.
     904                         * @param array  $item        Parsed RSS item.
     905                         */
     906                        echo apply_filters( 'rss_item_output', $item_output, $item );
    895907                }
    896908
    897909                echo '</ul>';
     
    921933function get_rss ($url, $num_items = 5) { // Like get posts, but for RSS
    922934        $rss = fetch_rss($url);
    923935        if ( $rss ) {
    924                 $rss->items = array_slice($rss->items, 0, $num_items);
     936                $rss->items = array_slice( $rss->items, 0, $num_items );
    925937                foreach ( (array) $rss->items as $item ) {
    926                         echo "<li>\n";
    927                         echo "<a href='$item[link]' title='$item[description]'>";
    928                         echo esc_html($item['title']);
    929                         echo "</a><br />\n";
    930                         echo "</li>\n";
     938                        $item_output = sprintf(
     939                                '<li><a href="%1$s">%2$s</a></li>',
     940                                esc_url( $item['link'] ),
     941                                esc_html( $item['title'] )
     942                        );
     943
     944                        /** This filter is documented in wp-includes/rss.php */
     945                        echo apply_filters( 'rss_item_output', $item_output, $item );
    931946                }
    932947        } else {
    933948                return false;