Skip to content

Commit

Permalink
Add RSS Error handling functionality to RSS Widget displays. Props DD…
Browse files Browse the repository at this point in the history
…32. fixes #9273

git-svn-id: http://svn.automattic.com/wordpress/trunk@10697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
ryan committed Mar 4, 2009
1 parent 65e0cea commit d7b53ad
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
17 changes: 12 additions & 5 deletions wp-admin/includes/dashboard.php
Expand Up @@ -698,12 +698,19 @@ function wp_dashboard_secondary_output() {
@extract( @$widgets['dashboard_secondary'], EXTR_SKIP );
$rss = @fetch_feed( $url );

if ( !$rss->get_item_quantity() )
if ( is_wp_error($rss) ) {
if ( is_admin() || current_user_can('manage_options') ) {
echo '<div class="rss-widget"><p>';
printf(__('<strong>RSS Error</strong>: %s'), $rss->get_error_message());
echo '</p></div>';
}
} elseif ( !$rss->get_item_quantity() ) {
return false;

echo "<div class='rss-widget'>";
wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );
echo "</div>";
} else {
echo '<div class="rss-widget">';
wp_widget_rss_output( $rss, $widgets['dashboard_secondary'] );
echo '</div>';
}
}

function wp_dashboard_plugins() {
Expand Down
9 changes: 9 additions & 0 deletions wp-includes/widgets.php
Expand Up @@ -1549,6 +1549,15 @@ function wp_widget_rss_output( $rss, $args = array() ) {
return;
}

if ( is_wp_error($rss) ) {
if ( is_admin() || current_user_can('manage_options') ) {
echo '<p>';
printf(__('<strong>RSS Error</strong>: %s'), $rss->get_error_message());
echo '</p>';
}
return;
}

$default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0 );
$args = wp_parse_args( $args, $default_args );
extract( $args, EXTR_SKIP );
Expand Down

0 comments on commit d7b53ad

Please sign in to comment.