614 | 614 | * using SimplePie's multifeed feature. |
615 | 615 | * See also {@link http://simplepie.org/wiki/faq/typical_multifeed_gotchas} |
616 | 616 | * |
617 | 617 | * @return WP_Error|SimplePie WP_Error object on failure or SimplePie object on success |
618 | 618 | */ |
619 | 619 | function fetch_feed( $url ) { |
620 | 620 | require_once( ABSPATH . WPINC . '/class-feed.php' ); |
621 | 621 | |
622 | 622 | $feed = new SimplePie(); |
623 | 623 | |
624 | 624 | $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' ); |
625 | 625 | // We must manually overwrite $feed->sanitize because SimplePie's |
626 | 626 | // constructor sets it before we have a chance to set the sanitization class |
627 | 627 | $feed->sanitize = new WP_SimplePie_Sanitize_KSES(); |
628 | 628 | |
630 | 632 | $feed->set_file_class( 'WP_SimplePie_File' ); |
631 | 633 | |
632 | 634 | $feed->set_feed_url( $url ); |
633 | 635 | /** This filter is documented in wp-includes/class-feed.php */ |
634 | 636 | $feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) ); |
635 | 637 | /** |
636 | 638 | * Fires just before processing the SimplePie feed object. |
637 | 639 | * |
638 | 640 | * @since 3.0.0 |
639 | 641 | * |
640 | 642 | * @param object &$feed SimplePie feed object, passed by reference. |
641 | 643 | * @param mixed $url URL of feed to retrieve. If an array of URLs, the feeds are merged. |
642 | 644 | */ |
643 | 645 | do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) ); |
644 | 646 | $feed->init(); |