SimplePie::strip_comments PHP Method

strip_comments() public method

public strip_comments ( $strip = false )
    public function strip_comments($strip = false)
    {
        $this->sanitize->strip_comments($strip);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  *
  * @param object $bookmark
  * @param object $owner
  */
 protected function do_rss($bookmark, $owner)
 {
     // no bookmark, no fun
     if (empty($bookmark) || !is_object($bookmark)) {
         return false;
     }
     // no owner means no email, so no reason to parse
     if (empty($owner) || !is_object($owner)) {
         return false;
     }
     // instead of the way too simple fetch_feed, we'll use SimplePie itself
     if (!class_exists('SimplePie')) {
         require_once ABSPATH . WPINC . '/class-simplepie.php';
     }
     $url = htmlspecialchars_decode($bookmark->link_rss);
     $last_updated = strtotime($bookmark->link_updated);
     static::debug('Fetching: ' . $url, 6);
     $feed = new SimplePie();
     $feed->set_feed_url($url);
     $feed->set_cache_duration(static::revisit_time - 10);
     $feed->set_cache_location($this->cachedir);
     $feed->force_feed(true);
     // optimization
     $feed->enable_order_by_date(true);
     $feed->remove_div(true);
     $feed->strip_comments(true);
     $feed->strip_htmltags(false);
     $feed->strip_attributes(true);
     $feed->set_image_handler(false);
     $feed->init();
     $feed->handle_content_type();
     if ($feed->error()) {
         $err = new WP_Error('simplepie-error', $feed->error());
         static::debug('Error: ' . $err->get_error_message(), 4);
         $this->failed($owner->user_email, $url, $err->get_error_message());
         return $err;
     }
     // set max items to 12
     // especially useful with first runs
     $maxitems = $feed->get_item_quantity(12);
     $feed_items = $feed->get_items(0, $maxitems);
     $feed_title = $feed->get_title();
     // set the link name from the RSS title
     if (!empty($feed_title) && $bookmark->link_name != $feed_title) {
         global $wpdb;
         $wpdb->update($wpdb->prefix . 'links', array('link_name' => $feed_title), array('link_id' => $bookmark->link_id));
     }
     // if there's a feed author, get it, we may need it if there's no entry
     // author
     $feed_author = $feed->get_author();
     $last_updated_ = 0;
     if ($maxitems > 0) {
         foreach ($feed_items as $item) {
             // U stands for Unix Time
             $date = $item->get_date('U');
             if ($date > $last_updated) {
                 $fromname = $feed_title;
                 $author = $item->get_author();
                 if ($author) {
                     $fromname = $fromname . ': ' . $author->get_name();
                 } elseif ($feed_author) {
                     $fromname = $fromname . ': ' . $feed_author->get_name();
                 }
                 // this is to set the sender mail from our own domain
                 $frommail = get_user_meta($owner->ID, 'blogroll2email_email', true);
                 if (!$frommail) {
                     $sitedomain = parse_url(get_bloginfo('url'), PHP_URL_HOST);
                     $frommail = static::schedule . '@' . $sitedomain;
                 }
                 $from = $fromname . '<' . $frommail . '>';
                 $content = $item->get_content();
                 $matches = array();
                 preg_match_all('/farm[0-9]\\.staticflickr\\.com\\/[0-9]+\\/([0-9]+_[0-9a-zA-Z]+_m\\.jpg)/s', $content, $matches);
                 if (!empty($matches[0])) {
                     foreach ($matches[0] as $to_replace) {
                         $clean = str_replace('_m.jpg', '_c.jpg', $to_replace);
                         $content = str_replace($to_replace, $clean, $content);
                     }
                     $content = preg_replace("/(width|height)=\"(.*?)\" ?/is", '', $content);
                 }
                 $content = apply_filters('blogroll2email_message', $content);
                 if ($this->send($owner->user_email, $item->get_link(), $item->get_title(), $from, $url, $item->get_content(), $date)) {
                     if ($date > $last_updated_) {
                         $last_updated_ = $date;
                     }
                 }
             }
         }
     }
     // poke the link's last update field, so we know what was the last sent
     // entry's date
     $this->update_link_date($bookmark, $last_updated_);
 }
All Usage Examples Of SimplePie::strip_comments