set_cache_class example


    $feed->sanitize = new WP_SimplePie_Sanitize_KSES();

    // 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 );
    /** This filter is documented in wp-includes/class-wp-feed-cache-transient.php */
    $feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );

    /** * Fires just before processing the SimplePie feed object. * * @since 3.0.0 * * @param SimplePie $feed SimplePie feed object (passed by reference). * @param string|string[] $url URL of feed or array of URLs of feeds to retrieve. */
Home | Imprint | This part of the site doesn't use cookies.