wp_cache_switch_to_blog example

require_once ABSPATH . WPINC . '/cache.php';
    }

    require_once ABSPATH . WPINC . '/cache-compat.php';

    /* * If cache supports reset, reset instead of init if already * initialized. Reset signals to the cache that global IDs * have changed and it may need to update keys and cleanup caches. */
    if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) ) {
        wp_cache_switch_to_blog( get_current_blog_id() );
    } elseif ( function_exists( 'wp_cache_init' ) ) {
        wp_cache_init();
    }

    if ( function_exists( 'wp_cache_add_global_groups' ) ) {
        wp_cache_add_global_groups(
            array(
                'blog-details',
                'blog-id-cache',
                'blog-lookup',
                'blog_meta',
                
$GLOBALS['switched'] = true;

        return true;
    }

    $wpdb->set_blog_id( $new_blog_id );
    $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
    $GLOBALS['blog_id']      = $new_blog_id;

    if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
        wp_cache_switch_to_blog( $new_blog_id );
    } else {
        global $wp_object_cache;

        if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) ) {
            $global_groups = $wp_object_cache->global_groups;
        } else {
            $global_groups = false;
        }

        wp_cache_init();

        
Home | Imprint | This part of the site doesn't use cookies.