Make WordPress Core

Ticket #4547: simplepieconversion-take2.diff

File simplepieconversion-take2.diff, 7.6 KB (added by technosailor, 16 years ago)
  • wp-admin/index-extra.php

     
    77switch ( $_GET['jax'] ) {
    88
    99case 'incominglinks' :
    10 $rss = @fetch_rss(apply_filters( 'dashboard_incoming_links_feed', 'http://feeds.technorati.com/cosmos/rss/?url='. trailingslashit(get_option('home')) .'&partner=wordpress' ));
    11 if ( isset($rss->items) && 1 < count($rss->items) ) { // Technorati returns a 1-item feed when it has no results
     10$rss = new SimplePie( (apply_filters( 'dashboard_incoming_links_feed', 'http://feeds.technorati.com/cosmos/rss/?url='. trailingslashit(get_option('home')) .'&partner=wordpress' ) ), ABSPATH . '/wp-content/rsscache', ABSPATH . '/wp-content/rsscache' );
     11$rss->enable_cache(false);
     12if (1 < count($rss->get_items() ) ) { // Technorati returns a 1-item feed when it has no results
    1213?>
    1314<h3><?php _e('Incoming Links'); ?> <cite><a href="<?php echo apply_filters( 'dashboard_incoming_links_link', 'http://www.technorati.com/search/'. trailingslashit(get_option('home')) .'?partner=wordpress' ); ?>"><?php _e('More &raquo;'); ?></a></cite></h3>
    1415<ul>
    1516<?php
    16 $rss->items = array_slice($rss->items, 0, 10);
    17 foreach ($rss->items as $item ) {
     17$items = $rss->get_items(0, 10);
     18foreach ($items as $item ) {
    1819?>
    19         <li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wptexturize(wp_specialchars($item['title'])); ?></a></li>
     20        <li><a href="<?php echo wp_filter_kses( $item->get_link() ); ?>"><?php echo wptexturize(wp_specialchars($item->get_title() ) ); ?></a></li>
    2021<?php } ?>
    2122</ul>
    2223<?php
     
    2425break;
    2526
    2627case 'devnews' :
    27 $rss = @fetch_rss(apply_filters( 'dashboard_primary_feed', 'http://wordpress.org/development/feed/' ));
    28 if ( isset($rss->items) && 0 != count($rss->items) ) {
     28$rss = new SimplePie( apply_filters( 'dashboard_primary_feed', 'http://wordpress.org/development/feed/' ), ABSPATH . '/wp-content/rsscache' );
     29$rss->enable_cache(false);
     30if ( 0 != count($rss->get_items() ) ) {
    2931?>
    3032<h3><?php echo apply_filters( 'dashboard_primary_title', __('WordPress Development Blog') ); ?></h3>
    3133<?php
    32 $rss->items = array_slice($rss->items, 0, 3);
    33 foreach ($rss->items as $item ) {
     34$items = $rss->get_items(0, 3);
     35foreach ($items as $item ) {
    3436?>
    35 <h4><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> &#8212; <?php printf(__('%s ago'), human_time_diff(strtotime($item['pubdate'], time() ) ) ); ?></h4>
    36 <p><?php echo $item['description']; ?></p>
     37<h4><a href='<?php echo wp_filter_kses($item->get_link); ?>'><?php echo wp_specialchars($item->get_title() ); ?></a> &#8212; <?php printf(__('%s ago'), human_time_diff($item->get_date('U'), time() ) ); ?></h4>
     38<p><?php echo $item->get_description(); ?></p>
    3739<?php
    3840        }
    3941}
     
    4345break;
    4446
    4547case 'planetnews' :
    46 $rss = @fetch_rss(apply_filters( 'dashboard_secondary_feed', 'http://planet.wordpress.org/feed/' ));
    47 if ( isset($rss->items) && 0 != count($rss->items) ) {
     48$rss = new SimplePie( apply_filters( 'dashboard_secondary_feed', 'http://planet.wordpress.org/feed/' ), ABSPATH . '/wp-content/rsscache' );
     49
     50if ( 0 != count($rss->get_items() ) ) {
    4851?>
    4952<h3><?php echo apply_filters( 'dashboard_secondary_title', __('Other WordPress News') ); ?></h3>
    5053<ul>
    5154<?php
    52 $rss->items = array_slice($rss->items, 0, 20);
    53 foreach ($rss->items as $item ) {
    54 $title = wp_specialchars($item['title']);
    55 $author = preg_replace( '|(.+?):.+|s', '$1', $item['title'] );
    56 $post = preg_replace( '|.+?:(.+)|s', '$1', $item['title'] );
     55$items = $rss->get_items(0, 20);
     56foreach ($items as $item ) {
     57$title = wp_specialchars($item->get_title() );
     58$author = preg_replace( '|(.+?):.+|s', '$1', $item->get_title() );
     59$post = preg_replace( '|.+?:(.+)|s', '$1', $item->get_title() );
    5760?>
    58 <li><a href='<?php echo wp_filter_kses($item['link']); ?>'><span class="post"><?php echo $post; ?></span><span class="hidden"> - </span><cite><?php echo $author; ?></cite></a></li>
     61<li><a href='<?php echo wp_filter_kses($item->get_link() ); ?>'><span class="post"><?php echo $post; ?></span><span class="hidden"> - </span><cite><?php echo $author; ?></cite></a></li>
    5962<?php
    6063        }
    6164?>
  • wp-includes/widgets.php

     
    932932}
    933933
    934934function wp_widget_rss($args, $number = 1) {
    935         require_once(ABSPATH . WPINC . '/rss.php');
     935        require_once(ABSPATH . WPINC . '/class-Simplepie.php');
    936936        extract($args);
    937937        $options = get_option('widget_rss');
    938938        if ( isset($options['error']) && $options['error'] )
     
    945945                $url = substr($url, 1);
    946946        if ( empty($url) )
    947947                return;
    948         $rss = fetch_rss($url);
    949         $link = clean_url(strip_tags($rss->channel['link']));
     948        $rss = new SimplePie( $url, ABSPATH . '/wp-content/rsscache' );
     949        $link = clean_url( strip_tags( $rss->get_link() ) );
    950950        while ( strstr($link, 'http') != $link )
    951951                $link = substr($link, 1);
    952         $desc = attribute_escape(strip_tags(html_entity_decode($rss->channel['description'], ENT_QUOTES)));
     952        $desc = attribute_escape(strip_tags(html_entity_decode($rss->get_description(), ENT_QUOTES)));
    953953        $title = $options[$number]['title'];
    954954        if ( empty($title) )
    955                 $title = htmlentities(strip_tags($rss->channel['title']));
     955                $title = htmlentities( strip_tags( $rss->get_title() ) );
    956956        if ( empty($title) )
    957957                $title = $desc;
    958958        if ( empty($title) )
     
    968968                        <?php $title ? print($before_title . $title . $after_title) : null; ?>
    969969                        <ul>
    970970<?php
    971         if ( is_array( $rss->items ) ) {
    972                 $rss->items = array_slice($rss->items, 0, $num_items);
    973                 foreach ($rss->items as $item ) {
    974                         while ( strstr($item['link'], 'http') != $item['link'] )
    975                                 $item['link'] = substr($item['link'], 1);
    976                         $link = clean_url(strip_tags($item['link']));
    977                         $title = attribute_escape(strip_tags($item['title']));
     971        if ( is_array( $items = $rss->get_items() ) ) {
     972                $items = $rss->get_items(0, $num_items);
     973                foreach ($items as $item ) {
     974                        while ( strstr($item->get_link(), 'http') != $item->get_link() )
     975                                $item->link = substr($item->get_link(), 1);
     976                        $link = clean_url( strip_tags( $item->link ) );
     977                        $title = attribute_escape( strip_tags( $item->get_title() ) );
    978978                        if ( empty($title) )
    979979                                $title = __('Untitled');
    980980                        $desc = '';
    981981                        if ( $show_summary ) {
    982                                 $summary = '<div class="rssSummary">' . $item['description'] . '</div>';
     982                                $summary = '<div class="rssSummary">' . $item->get_description() . '</div>';
    983983                        } else {
    984                                 if ( isset( $item['description'] ) && is_string( $item['description'] ) )
    985                                         $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
     984                                if ( isset( $item->description ) && is_string( $item->get_description() ) )
     985                                        $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item->get_content(), ENT_QUOTES))));
    986986                                $summary = '';
    987987                        }
    988988                        echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>$summary</li>";
     
    10031003                $url = clean_url(strip_tags(stripslashes($_POST["rss-url-$number"])));
    10041004                $newoptions[$number]['title'] = trim(strip_tags(stripslashes($_POST["rss-title-$number"])));
    10051005                if ( $url !== $options[$number]['url'] ) {
    1006                         require_once(ABSPATH . WPINC . '/rss.php');
    1007                         $rss = fetch_rss($url);
     1006                        require_once(ABSPATH . WPINC . '/class-Simplepie.php');
     1007                        $rss = new SimplePie( $url, ABSPATH . '/wp-content/rsscache' );
    10081008                        if ( is_object($rss) ) {
    10091009                                $newoptions[$number]['url'] = $url;
    10101010                                $newoptions[$number]['error'] = false;