• Resolved snakefoot

    (@snakefoot)


    Hi ya

    I have a feed, that is a combination of many RSS-feeds. When a single RSS-feed is down, then it should display the non-working feed-URL at the top, and still show the posts from all the other working feeds.

    This configuration doesn’t show anything:

    [feedzy-rss feeds="
    http://blogs.msdn.com/b/oldnewthing/atom.aspx,
    https://sxpdata.microsoft.com/feeds/3.0/msdntn/MSDNMagazine_enus
    " max="350" summarylength="250" thumb="no" target="_self"]

    And if removing the last feed, so there is an extra comma, then also doesn’t show anything:

    
    [feedzy-rss feeds="
    http://blogs.msdn.com/b/oldnewthing/atom.aspx,
    " max="350" summarylength="250" thumb="no" target="_self"]
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter snakefoot

    (@snakefoot)

    Made the following changes, so it now is able to recover broken feed URLs:

    	public function feedzy_rss( $atts, $content = '' ) {
    		// Load SimplePie if not already
    		if ( ! class_exists( 'SimplePie' ) ) {
    			require_once( ABSPATH . WPINC . '/feed.php' );
    		}
    		$sc      = $this->get_short_code_attributes( $atts );
    		$feedURL = $this->get_feed_url( $sc['feeds'] );
    		// Load SimplePie Instance
    		$feed = fetch_feed( $feedURL );
    		// TODO report error when is an error loading the feed
    		if ( is_wp_error( $feed ) ) {
    			// Fallback for different edge cases.
    			if ( is_array( $feedURL ) )
    			{
    				$feedURL = array_map( 'html_entity_decode', $feedURL );
    
    			    $checkFeedURL = array();
    				foreach ($feedURL as $singleURL)
    				{
    				    $feed = fetch_feed( $singleURL );
    					if ( is_wp_error( $feed ) )
    					{
    						echo '<p>Invalid feed skipped: ' . $singleURL . '</p>';
    						echo '<ul>';
    						echo '<li>' . implode( '</li><li>', $feed->get_error_messages() ) . '</li>';
    						echo '</ul>';
    					}
    					else
    					{
    						$checkFeedURL[] = $singleURL;
    					}
    				}
    				$feedURL = $checkFeedURL;
    				if (count($feedURL) == 0)
    					return '';
    				else if (count($feedURL) == 1)
    					$feedURL = $feedURL[0];
    			}
    			else
    			{
    				$feedURL = html_entity_decode( $feedURL );
    			}
    
    			$feed = fetch_feed( $feedURL );
    			if ( is_wp_error( $feed ) ) {
    				if (!is_array( $feedURL ) )
    				{
    						echo '<p>Invalid feed skipped: ' . $feedURL . '</p>';
    						echo '<ul>';
    						echo '<li>' . implode( '</li><li>', $feed->get_error_messages() ) . '</li>';
    						echo '</ul>';
    				}
    				return '';
    			}
    		}
    Thread Starter snakefoot

    (@snakefoot)

    Also had to add a TRUE to the printf_r, else it would echo into the content instead of generating a string:

    	public function feedzy_default_error_notice( $error, $feedURL ) {
    		error_log( 'Feedzy RSS Feeds - related feed: ' . print_r( $feedURL, TRUE ) . ' - Error message: ' . $this->feedzy_array_obj_string( $error ) );
    
    		return '<div id="message" class="error" data-error"' . esc_attr( $this->feedzy_array_obj_string( $error ) ) . '"><p>' . __( 'Sorry, this feed is currently unavailable or does not exists anymore.', 'feedzy-rss-feeds' ) . '</p></div>';
    	}
    Plugin Contributor Hardeep Asrani

    (@hardeepasrani)

    Hey there,

    Thanks for reporting this bug and its solution to us. We’ll take a look into it and will fix it in an upcoming release of the plugin.

    Thanks again. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘One broken link ruins entire feed’ is closed to new replies.