/**
* _displayRSS
*
* @param string $url
* @param int $num_items
*/
protected function _displayRSS($url, $num_items = -1)
{
$rss = new SimplePie();
$rss->strip_htmltags(array_diff($rss->strip_htmltags, array('style')));
$rss->strip_attributes(array_diff($rss->strip_attributes, array('style', 'class', 'id')));
$rss->set_feed_url($url);
$rss->set_cache_class('WP_Feed_Cache');
$rss->set_file_class('WP_SimplePie_File');
$rss->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $url));
do_action_ref_array('wp_feed_options', array(&$rss, $url));
$rss->init();
$rss->handle_content_type();
if (!$rss->error()) {
$maxitems = $rss->get_item_quantity(25);
$rss_items = $rss->get_items(0, $maxitems);
echo '<ul>';
if ($num_items !== -1) {
$rss_items = array_slice($rss_items, 0, $num_items);
}
if ($rss_items) {
foreach ((array) $rss_items as $item) {
printf('<li><div class="date">%4$s</div><div class="thethefly-news-item">%2$s</div></li>', esc_url($item->get_permalink()), $item->get_description(), esc_html($item->get_title()), $item->get_date('D, d M Y'));
}
} else {
echo "<li>";
_e('Unfortunately the news channel is temporarily closed', 'thethe-captcha');
echo "</li>";
}
echo '</ul>';
} else {
_e('An error has occurred, which probably means the feed is down. Try again later.', 'thethe-captcha');
}
}