Ticket #4547: simplepieconversion-take2.diff
File simplepieconversion-take2.diff, 7.6 KB (added by , 16 years ago) |
---|
-
wp-admin/index-extra.php
7 7 switch ( $_GET['jax'] ) { 8 8 9 9 case '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); 12 if (1 < count($rss->get_items() ) ) { // Technorati returns a 1-item feed when it has no results 12 13 ?> 13 14 <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 »'); ?></a></cite></h3> 14 15 <ul> 15 16 <?php 16 $ rss->items = array_slice($rss->items,0, 10);17 foreach ($ rss->items as $item ) {17 $items = $rss->get_items(0, 10); 18 foreach ($items as $item ) { 18 19 ?> 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> 20 21 <?php } ?> 21 22 </ul> 22 23 <?php … … 24 25 break; 25 26 26 27 case '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); 30 if ( 0 != count($rss->get_items() ) ) { 29 31 ?> 30 32 <h3><?php echo apply_filters( 'dashboard_primary_title', __('WordPress Development Blog') ); ?></h3> 31 33 <?php 32 $ rss->items = array_slice($rss->items,0, 3);33 foreach ($ rss->items as $item ) {34 $items = $rss->get_items(0, 3); 35 foreach ($items as $item ) { 34 36 ?> 35 <h4><a href='<?php echo wp_filter_kses($item ['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a> — <?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> — <?php printf(__('%s ago'), human_time_diff($item->get_date('U'), time() ) ); ?></h4> 38 <p><?php echo $item->get_description(); ?></p> 37 39 <?php 38 40 } 39 41 } … … 43 45 break; 44 46 45 47 case '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 50 if ( 0 != count($rss->get_items() ) ) { 48 51 ?> 49 52 <h3><?php echo apply_filters( 'dashboard_secondary_title', __('Other WordPress News') ); ?></h3> 50 53 <ul> 51 54 <?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); 56 foreach ($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() ); 57 60 ?> 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> 59 62 <?php 60 63 } 61 64 ?> -
wp-includes/widgets.php
932 932 } 933 933 934 934 function wp_widget_rss($args, $number = 1) { 935 require_once(ABSPATH . WPINC . '/ rss.php');935 require_once(ABSPATH . WPINC . '/class-Simplepie.php'); 936 936 extract($args); 937 937 $options = get_option('widget_rss'); 938 938 if ( isset($options['error']) && $options['error'] ) … … 945 945 $url = substr($url, 1); 946 946 if ( empty($url) ) 947 947 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() ) ); 950 950 while ( strstr($link, 'http') != $link ) 951 951 $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))); 953 953 $title = $options[$number]['title']; 954 954 if ( empty($title) ) 955 $title = htmlentities( strip_tags($rss->channel['title']));955 $title = htmlentities( strip_tags( $rss->get_title() ) ); 956 956 if ( empty($title) ) 957 957 $title = $desc; 958 958 if ( empty($title) ) … … 968 968 <?php $title ? print($before_title . $title . $after_title) : null; ?> 969 969 <ul> 970 970 <?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() ) ); 978 978 if ( empty($title) ) 979 979 $title = __('Untitled'); 980 980 $desc = ''; 981 981 if ( $show_summary ) { 982 $summary = '<div class="rssSummary">' . $item ['description']. '</div>';982 $summary = '<div class="rssSummary">' . $item->get_description() . '</div>'; 983 983 } 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)))); 986 986 $summary = ''; 987 987 } 988 988 echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>$summary</li>"; … … 1003 1003 $url = clean_url(strip_tags(stripslashes($_POST["rss-url-$number"]))); 1004 1004 $newoptions[$number]['title'] = trim(strip_tags(stripslashes($_POST["rss-title-$number"]))); 1005 1005 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' ); 1008 1008 if ( is_object($rss) ) { 1009 1009 $newoptions[$number]['url'] = $url; 1010 1010 $newoptions[$number]['error'] = false;