public function generate_edit_forms_upsell_ad()
    {
        /*
         *	SimplePie strips out all query strings
         * 	we had to implement a workaround
         *	https://github.com/simplepie/simplepie/issues/317
         */
        include_once ABSPATH . WPINC . '/feed.php';
        $rss = fetch_feed(esc_url('http://yikesplugins.com/feed/?post_type=product_ads&genre=easy-forms-for-mailchimp'));
        $maxitems = 0;
        if (!is_wp_error($rss)) {
            // Checks that the object is created correctly
            // Figure out how many total items there are, but limit it to 1.
            $maxitems = $rss->get_item_quantity(1);
            // Build an array of all the items, starting with element 0 (first element).
            $rss_items = $rss->get_items(0, $maxitems);
        } else {
            return $feed = new WP_Error('Simple Pie RSS Error', $feed->error());
        }
        // loop over returned results
        foreach ($rss_items as $add_on) {
            $add_on_desc = $add_on->get_content();
            ?>
					<h3><?php 
            echo $add_on->get_title();
            ?>
</h3>
					<div class="inside">
					<?php 
            echo $add_on_desc;
            ?>
					</div>
				<?php 
        }
    }
Example #2
0
/* Tell SimplePie to cache the feed using WordPress' cache class */
$feed->set_cache_class('WP_Feed_Cache');
/* Tell SimplePie to use the WordPress class for retrieving feed files */
$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] : '';
    /* Set the URL of the feed you're retrieving */
    $article_feed->set_feed_url($rss_feed_url);
    /* Tell SimplePie to cache the feed using WordPress' cache class */
    $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));