diff --git a/src/wp-includes/class-wp-feed-cache.php b/src/wp-includes/class-wp-feed-cache.php index 2564dffb80..b3d03ab422 100644 --- a/src/wp-includes/class-wp-feed-cache.php +++ b/src/wp-includes/class-wp-feed-cache.php @@ -5,8 +5,16 @@ * @package WordPress * @subpackage Feed * @since 4.7.0 + * @deprecated 5.6.0 */ +_deprecated_file( + basename( __FILE__ ), + '5.6.0', + '', + __( 'This file is only loaded for backward compatibility with SimplePie 1.2.x. Please consider switching to a recent SimplePie version.' ) +); + /** * Core class used to implement a feed cache. * diff --git a/src/wp-includes/feed.php b/src/wp-includes/feed.php index 0b84cc10a5..265a9a45b2 100644 --- a/src/wp-includes/feed.php +++ b/src/wp-includes/feed.php @@ -789,7 +789,6 @@ function fetch_feed( $url ) { require_once ABSPATH . WPINC . '/class-simplepie.php'; } - require_once ABSPATH . WPINC . '/class-wp-feed-cache.php'; require_once ABSPATH . WPINC . '/class-wp-feed-cache-transient.php'; require_once ABSPATH . WPINC . '/class-wp-simplepie-file.php'; require_once ABSPATH . WPINC . '/class-wp-simplepie-sanitize-kses.php'; @@ -801,7 +800,16 @@ function fetch_feed( $url ) { // constructor sets it before we have a chance to set the sanitization class. $feed->sanitize = new WP_SimplePie_Sanitize_KSES(); - $feed->set_cache_class( 'WP_Feed_Cache' ); + // Register the cache handler using the recommended method for SimplePie 1.3 or later. + if ( method_exists( 'SimplePie_Cache', 'register' ) ) { + SimplePie_Cache::register( 'wp_transient', 'WP_Feed_Cache_Transient' ); + $feed->set_cache_location( 'wp_transient' ); + } else { + // Back-compat for SimplePie 1.2.x. + require_once ABSPATH . WPINC . '/class-wp-feed-cache.php'; + $feed->set_cache_class( 'WP_Feed_Cache' ); + } + $feed->set_file_class( 'WP_SimplePie_File' ); $feed->set_feed_url( $url );