479 |
479 |
480 foreach ( (array) get_post_custom() as $key => $val ) { |
480 foreach ( (array) get_post_custom() as $key => $val ) { |
481 if ( 'enclosure' === $key ) { |
481 if ( 'enclosure' === $key ) { |
482 foreach ( (array) $val as $enc ) { |
482 foreach ( (array) $val as $enc ) { |
483 $enclosure = explode( "\n", $enc ); |
483 $enclosure = explode( "\n", $enc ); |
|
484 |
|
485 if ( count( $enclosure ) < 3 ) { |
|
486 continue; |
|
487 } |
484 |
488 |
485 // Only get the first element, e.g. 'audio/mpeg' from 'audio/mpeg mpga mp2 mp3'. |
489 // Only get the first element, e.g. 'audio/mpeg' from 'audio/mpeg mpga mp2 mp3'. |
486 $t = preg_split( '/[ \t]/', trim( $enclosure[2] ) ); |
490 $t = preg_split( '/[ \t]/', trim( $enclosure[2] ) ); |
487 $type = $t[0]; |
491 $type = $t[0]; |
488 |
492 |
789 * @since 2.8.0 |
793 * @since 2.8.0 |
790 * |
794 * |
791 * @param string|string[] $url URL of feed to retrieve. If an array of URLs, the feeds are merged |
795 * @param string|string[] $url URL of feed to retrieve. If an array of URLs, the feeds are merged |
792 * using SimplePie's multifeed feature. |
796 * using SimplePie's multifeed feature. |
793 * See also {@link http://simplepie.org/wiki/faq/typical_multifeed_gotchas} |
797 * See also {@link http://simplepie.org/wiki/faq/typical_multifeed_gotchas} |
794 * @return SimplePie|WP_Error SimplePie object on success or WP_Error object on failure. |
798 * @return SimplePie\SimplePie|WP_Error SimplePie object on success or WP_Error object on failure. |
795 */ |
799 */ |
796 function fetch_feed( $url ) { |
800 function fetch_feed( $url ) { |
797 if ( ! class_exists( 'SimplePie', false ) ) { |
801 if ( ! class_exists( 'SimplePie\SimplePie', false ) ) { |
798 require_once ABSPATH . WPINC . '/class-simplepie.php'; |
802 require_once ABSPATH . WPINC . '/class-simplepie.php'; |
799 } |
803 } |
800 |
804 |
801 require_once ABSPATH . WPINC . '/class-wp-feed-cache-transient.php'; |
805 require_once ABSPATH . WPINC . '/class-wp-feed-cache-transient.php'; |
802 require_once ABSPATH . WPINC . '/class-wp-simplepie-file.php'; |
806 require_once ABSPATH . WPINC . '/class-wp-simplepie-file.php'; |
803 require_once ABSPATH . WPINC . '/class-wp-simplepie-sanitize-kses.php'; |
807 require_once ABSPATH . WPINC . '/class-wp-simplepie-sanitize-kses.php'; |
804 |
808 |
805 $feed = new SimplePie(); |
809 $feed = new SimplePie\SimplePie(); |
806 |
810 |
807 $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' ); |
811 $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' ); |
808 /* |
812 /* |
809 * We must manually overwrite $feed->sanitize because SimplePie's constructor |
813 * We must manually overwrite $feed->sanitize because SimplePie's constructor |
810 * sets it before we have a chance to set the sanitization class. |
814 * sets it before we have a chance to set the sanitization class. |
830 /** |
834 /** |
831 * Fires just before processing the SimplePie feed object. |
835 * Fires just before processing the SimplePie feed object. |
832 * |
836 * |
833 * @since 3.0.0 |
837 * @since 3.0.0 |
834 * |
838 * |
835 * @param SimplePie $feed SimplePie feed object (passed by reference). |
839 * @param SimplePie\SimplePie $feed SimplePie feed object (passed by reference). |
836 * @param string|string[] $url URL of feed or array of URLs of feeds to retrieve. |
840 * @param string|string[] $url URL of feed or array of URLs of feeds to retrieve. |
837 */ |
841 */ |
838 do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) ); |
842 do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) ); |
839 |
843 |
840 $feed->init(); |
844 $feed->init(); |
841 $feed->set_output_encoding( get_option( 'blog_charset' ) ); |
845 $feed->set_output_encoding( get_bloginfo( 'charset' ) ); |
842 |
846 |
843 if ( $feed->error() ) { |
847 if ( $feed->error() ) { |
844 return new WP_Error( 'simplepie-error', $feed->error() ); |
848 return new WP_Error( 'simplepie-error', $feed->error() ); |
845 } |
849 } |
846 |
850 |