Kaynağa Gözat

Merge pull request #614 from rosswintle/patch-1

Add error check on fetch_feed call in bones_rss_dashboard_widget
Eddie Machado 11 yıl önce
ebeveyn
işleme
93960c4dc9
1 değiştirilmiş dosya ile 7 ekleme ve 2 silme
  1. 7 2
      library/admin.php

+ 7 - 2
library/admin.php

@@ -63,8 +63,13 @@ function bones_rss_dashboard_widget() {
 	if ( function_exists( 'fetch_feed' ) ) {
 		// include_once( ABSPATH . WPINC . '/feed.php' );               // include the required file
 		$feed = fetch_feed( 'http://themble.com/feed/rss/' );        // specify the source feed
-		$limit = $feed->get_item_quantity(7);                        // specify number of items
-		$items = $feed->get_items(0, $limit);                        // create an array of items
+		if (is_wp_error($feed)) {
+			$limit = 0;
+			$items = 0;
+		} else {
+			$limit = $feed->get_item_quantity(7);                        // specify number of items
+			$items = $feed->get_items(0, $limit);                        // create an array of items
+		}
 	}
 	if ($limit == 0) echo '<div>The RSS Feed is either empty or unavailable.</div>';   // fallback message
 	else foreach ($items as $item) { ?>