Ticket #9198: simplepie.diff
File simplepie.diff, 8.0 KB (added by , 12 years ago) |
---|
-
wp-includes/feed.php
534 534 return apply_filters( 'feed_content_type', $content_type, $type ); 535 535 } 536 536 537 function fetch_feed($url) { 538 require_once (ABSPATH . WPINC . '/simplepie.inc'); 539 540 $feed = new SimplePie(); 541 $feed->set_feed_url($url); 542 $feed->enable_cache(false); // TODO Create custom cache class that uses get_transient() and set_transient(). 543 $feed->init(); 544 $feed->handle_content_type(); 545 546 return $feed; 547 } 548 537 549 ?> -
wp-includes/widgets.php
1501 1501 if ( empty($url) ) 1502 1502 return; 1503 1503 1504 require_once(ABSPATH . WPINC . '/rss.php'); 1505 1506 $rss = fetch_rss($url); 1507 $link = clean_url(strip_tags($rss->channel['link'])); 1504 $rss = fetch_feed($url); 1505 $link = clean_url(strip_tags($rss->get_permalink())); 1508 1506 while ( strstr($link, 'http') != $link ) 1509 1507 $link = substr($link, 1); 1510 $desc = attribute_escape(strip_tags(html_entity_decode($rss-> channel['description'], ENT_QUOTES)));1508 $desc = attribute_escape(strip_tags(html_entity_decode($rss->get_description(), ENT_QUOTES))); 1511 1509 $title = $options[$number]['title']; 1512 1510 if ( empty($title) ) 1513 $title = htmlentities(strip_tags($rss-> channel['title']));1511 $title = htmlentities(strip_tags($rss->get_title())); 1514 1512 if ( empty($title) ) 1515 1513 $title = $desc; 1516 1514 if ( empty($title) ) … … 1541 1539 */ 1542 1540 function wp_widget_rss_output( $rss, $args = array() ) { 1543 1541 if ( is_string( $rss ) ) { 1544 require_once(ABSPATH . WPINC . '/rss.php'); 1545 if ( !$rss = fetch_rss($rss) ) 1542 if ( !$rss = fetch_feed($rss) ) 1546 1543 return; 1547 1544 } elseif ( is_array($rss) && isset($rss['url']) ) { 1548 require_once(ABSPATH . WPINC . '/rss.php');1549 1545 $args = $rss; 1550 if ( !$rss = fetch_ rss($rss['url']) )1546 if ( !$rss = fetch_feed($rss['url']) ) 1551 1547 return; 1552 1548 } elseif ( !is_object($rss) ) { 1553 1549 return; … … 1564 1560 $show_author = (int) $show_author; 1565 1561 $show_date = (int) $show_date; 1566 1562 1567 if ( is_array( $rss->items ) && !empty( $rss->items ) ) { 1568 $rss->items = array_slice($rss->items, 0, $items); 1569 echo '<ul>'; 1570 foreach ( (array) $rss->items as $item ) { 1571 while ( strstr($item['link'], 'http') != $item['link'] ) 1572 $item['link'] = substr($item['link'], 1); 1573 $link = clean_url(strip_tags($item['link'])); 1574 $title = attribute_escape(strip_tags($item['title'])); 1575 if ( empty($title) ) 1576 $title = __('Untitled'); 1577 $desc = ''; 1578 if ( isset( $item['description'] ) && is_string( $item['description'] ) ) 1579 $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES)))); 1580 elseif ( isset( $item['summary'] ) && is_string( $item['summary'] ) ) 1581 $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['summary'], ENT_QUOTES)))); 1582 if ( 360 < strlen( $desc ) ) 1583 $desc = wp_html_excerpt( $desc, 360 ) . ' […]'; 1584 $summary = $desc; 1563 if ( !$rss->get_item_quantity() ) { 1564 echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>'; 1565 return; 1566 } 1585 1567 1586 if ( $show_summary ) { 1587 $desc = ''; 1588 $summary = wp_specialchars( $summary ); 1589 $summary = "<div class='rssSummary'>$summary</div>"; 1590 } else { 1591 $summary = ''; 1592 } 1568 echo '<ul>'; 1569 $count = 0; 1570 foreach ( $rss->get_items() as $item ) { 1571 $link = $item->get_link(); 1572 while ( strstr($link, 'http') != $link ) 1573 $link = substr($link, 1); 1574 $link = clean_url(strip_tags($link)); 1575 $title = attribute_escape(strip_tags($item->get_title())); 1576 if ( empty($title) ) 1577 $title = __('Untitled'); 1593 1578 1594 $date = ''; 1595 if ( $show_date ) { 1596 if ( isset($item['pubdate']) ) 1597 $date = $item['pubdate']; 1598 elseif ( isset($item['published']) ) 1599 $date = $item['published']; 1579 $desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item->get_description(), ENT_QUOTES)))); 1580 $desc = wp_html_excerpt( $desc, 360 ) . ' […]'; 1581 $desc = wp_specialchars( $desc ); 1600 1582 1601 if ( $date ) { 1602 if ( $date_stamp = strtotime( $date ) ) 1603 $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>'; 1604 else 1605 $date = ''; 1606 } 1607 } 1583 if ( $show_summary ) { 1584 $summary = "<div class='rssSummary'>$desc</div>"; 1585 } else { 1586 $summary = ''; 1587 } 1608 1588 1609 $author = ''; 1610 if ( $show_author ) { 1611 if ( isset($item['dc']['creator']) ) 1612 $author = ' <cite>' . wp_specialchars( strip_tags( $item['dc']['creator'] ) ) . '</cite>'; 1613 elseif ( isset($item['author_name']) ) 1614 $author = ' <cite>' . wp_specialchars( strip_tags( $item['author_name'] ) ) . '</cite>'; 1615 } 1589 $date = ''; 1590 if ( $show_date ) { 1591 $date = $item->get_date(); 1616 1592 1617 if ( $link == '' ) { 1618 echo "<li>$title{$date}{$summary}{$author}</li>"; 1619 } else { 1620 echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>"; 1593 if ( $date ) { 1594 if ( $date_stamp = strtotime( $date ) ) 1595 $date = ' <span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>'; 1596 else 1597 $date = ''; 1621 1598 } 1622 } 1623 echo '</ul>'; 1624 } else { 1625 echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>'; 1599 } 1600 1601 $author = ''; 1602 if ( $show_author ) { 1603 $author = $item->get_author(); 1604 $author = $author->get_name(); 1605 $author = ' <cite>' . wp_specialchars( strip_tags( $author ) ) . '</cite>'; 1606 } 1607 1608 if ( $link == '' ) { 1609 echo "<li>$title{$date}{$summary}{$author}</li>"; 1610 } else { 1611 echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>"; 1612 } 1613 $count++; 1614 if ( $count >= $items ) 1615 break; 1626 1616 } 1617 echo '</ul>'; 1627 1618 } 1628 1619 1629 1620 /** … … 1810 1801 $show_date = (int) $widget_rss['show_date']; 1811 1802 1812 1803 if ( $check_feed ) { 1813 require_once(ABSPATH . WPINC . '/rss.php'); 1814 $rss = fetch_rss($url); 1804 $rss = fetch_feed($url); 1815 1805 $error = false; 1816 1806 $link = ''; 1817 1807 if ( !is_object($rss) ) { 1818 1808 $url = wp_specialchars(__('Error: could not find an RSS or ATOM feed at that URL.'), 1); 1819 1809 $error = sprintf(__('Error in RSS %1$d'), $widget_number ); 1820 1810 } else { 1821 $link = clean_url(strip_tags($rss-> channel['link']));1811 $link = clean_url(strip_tags($rss->get_permalink())); 1822 1812 while ( strstr($link, 'http') != $link ) 1823 1813 $link = substr($link, 1); 1824 1814 } -
wp-admin/includes/dashboard.php
670 670 function wp_dashboard_secondary_output() { 671 671 $widgets = get_option( 'dashboard_widget_options' ); 672 672 @extract( @$widgets['dashboard_secondary'], EXTR_SKIP ); 673 $rss = @fetch_ rss( $url );673 $rss = @fetch_feed( $url ); 674 674 675 if ( ! isset($rss->items) || 0 == count($rss->items) )675 if ( !$rss->get_item_quantity() ) 676 676 return false; 677 677 678 $rss->items = array_slice($rss->items, 0, $items);679 680 if ( 'http://planet.wordpress.org/' == $rss->channel['link'] ) {681 foreach ( array_keys($rss->items) as $i ) {682 list($site, $description) = explode( ':', wp_specialchars($rss->items[$i]['title']), 2 );683 $rss->items[$i]['dc']['creator'] = trim($site);684 $rss->items[$i]['title'] = trim($description);685 }686 }687 688 678 echo "<div class='rss-widget'>"; 689 679 wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] ); 690 680 echo "</div>"; … … 778 768 } 779 769 780 770 781 require_once( ABSPATH . WPINC . '/rss.php' ); 782 init(); // initialize rss constants 783 784 $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE ); 785 771 /* TODO Cache check here. 786 772 foreach ( $check_urls as $check_url ) { 787 $status = $cache->check_cache( $check_url ); 773 788 774 if ( 'HIT' !== $status ) { 789 775 echo $loading; 790 776 return false; 791 777 } 792 778 } 779 */ 793 780 794 781 if ( $callback && is_callable( $callback ) ) { 795 782 $args = array_slice( func_get_args(), 2 );