$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>';
} $rss_items =
$rss->
get_items( 0,
$attributes['itemsToShow'
] );
$list_items = '';
foreach ( $rss_items as $item ) { $title =
esc_html( trim( strip_tags( $item->
get_title() ) ) );
if ( empty( $title ) ) { $title =
__( '(no title)'
);
} $link =
$item->
get_link();
$link =
esc_url( $link );
if ( $link ) { $title = "<a href='{
$link}'>{
$title}</a>";
}