Example #1
0
$feed->set_file_class('WP_SimplePie_File');
$feed->enable_cache(true);
// temporary
/* Tell SimplePie how long to cache the feed data in the WordPress database */
$feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $feed_url));
/* Run any other functions or filters that WordPress normally runs on feeds */
do_action_ref_array('wp_feed_options', array($feed, $feed_url));
/* Initiate the SimplePie instance */
$feed->init();
/* Tell SimplePie to send the feed MIME headers */
$feed->handle_content_type();
if ($feed->error()) {
    return $feed = new WP_Error('simplepie-error', $feed->error());
}
// print_r( $feed->get_items() );
foreach ($feed->get_items() as $add_on) {
    // store the description
    $description_pre_split = $add_on->get_description();
    $permalink = esc_url($add_on->get_permalink());
    $add_on_title = $add_on->get_title();
    // If the returned add-on is this base plugin, skip it
    if ($add_on_title != 'Easy Forms for MailChimp') {
        // extract the image
        preg_match('/<img[^>]+\\>/i', $description_pre_split, $split_string);
        // store the content sans image tag
        $description = preg_replace("/<img[^>]+\\>/i", "", $add_on->get_description());
        // store the image
        $image = count($split_string) > 0 ? $split_string[0] : '';
        // if {hidden} is found, exclude it
        if (strpos($description_pre_split, '{hidden}')) {
            continue;
    $article_feed->set_cache_class('WP_Feed_Cache');
    /* Tell SimplePie to use the WordPress class for retrieving feed files */
    $article_feed->set_file_class('WP_SimplePie_File');
    /* Tell SimplePie how long to cache the feed data in the WordPress database - Cached for 8 hours */
    $article_feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 28800, $rss_feed_url));
    /* Run any other functions or filters that WordPress normally runs on feeds */
    do_action_ref_array('wp_feed_options', array($article_feed, $rss_feed_url));
    /* Initiate the SimplePie instance */
    $article_feed->init();
    /* Tell SimplePie to send the feed MIME headers */
    $article_feed->handle_content_type();
    if ($article_feed->error()) {
        return $article_feed = new WP_Error('simplepie-error', $article_feed->error());
    }
    // loop over latest items
    if ($article_feed->get_items()) {
        ?>
<ul class="knowledge-base-listing">
					<li class="list-title"><?php 
        echo $article_title;
        ?>
</li>
				<?php 
        foreach ($article_feed->get_items(0, 5) as $kb_article) {
            // store the description
            $description_pre_split = $kb_article->get_description();
            $kb_article_permalink = esc_url_raw($kb_article->get_permalink());
            $kb_article_permalink = add_query_arg(array('utm_source' => $page, 'utm_medium' => 'link', 'utm_campaign' => 'easy_forms_for_mailchimp'), esc_url_raw($kb_article_permalink));
            $kb_article_title = $kb_article->get_title();
            // store the content sans image tag
            $description = $kb_article->get_description();