Make WordPress Core


Ignore:
Timestamp:
03/07/2009 07:44:28 PM (17 years ago)
Author:
azaozz
Message:

Add RSS Error handling functionality to RSS Widget displays, props DD32, fixes #9273

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/dashboard.php

    r10738 r10739  
    604604        $rss = fetch_feed( $url );
    605605
     606        if ( is_wp_error($rss) ) {
     607                if ( is_admin() || current_user_can('manage_options') ) {
     608                        echo '<p>';
     609                        printf(__('<strong>RSS Error</strong>: %s'), $rss->get_error_message());
     610                        echo '</p>';
     611                }
     612                return;
     613        }
     614
    606615        if ( !$rss->get_item_quantity() ) {
    607616                echo '<p>' . __('This dashboard widget queries <a href="http://blogsearch.google.com/">Google Blog Search</a> so that when another blog links to your site it will show up here. It has found no incoming links&hellip; yet. It&#8217;s okay &#8212; there is no rush.') . "</p>\n";
     
    741750
    742751        foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins'), 'updated' => __('Recently Updated') ) as $feed => $label ) {
    743                 if ( !$$feed->get_item_quantity() )
     752                if ( is_wp_error($$feed) || !$$feed->get_item_quantity() )
    744753                        continue;
    745754
     
    899908                if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) {
    900909                        $rss = fetch_feed($widget_options[$widget_id]['url']);
    901                         $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));
     910                        if ( ! is_wp_error($rss) )
     911                                $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title()));
     912                        else
     913                                $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed'));
    902914                }
    903915                update_option( 'dashboard_widget_options', $widget_options );
Note: See TracChangeset for help on using the changeset viewer.