/**
* Renders the `core/rss` block on server.
*
* @param array $attributes The block attributes.
*
* @return string Returns the block content with received rss items.
*/
function render_block_core_rss( $attributes ) { if ( in_array( untrailingslashit( $attributes['feedURL'
] ), array
( site_url(),
home_url() ), true
) ) { return '<div class="components-placeholder"><div class="notice notice-error">' .
__( 'Adding an RSS feed to this site’s homepage is not supported, as it could lead to a loop that slows down your site. Try using another block, like the <strong>Latest Posts</strong> block, to list posts from the site.'
) . '</div></div>';
} $rss =
fetch_feed( $attributes['feedURL'
] );
if ( is_wp_error( $rss ) ) { return '<div class="components-placeholder"><div class="notice notice-error"><strong>' .
__( 'RSS Error:'
) . '</strong> ' .
esc_html( $rss->
get_error_message() ) . '</div></div>';
} if ( !
$rss->
get_item_quantity() ) { return '<div class="components-placeholder"><div class="notice notice-error">' .
__( 'An error has occurred, which probably means the feed is down. Try again later.'
) . '</div></div>';
}