• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_cache_switch_to_blog函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_cache_switch_to_blog函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_cache_switch_to_blog函数的具体用法?PHP wp_cache_switch_to_blog怎么用?PHP wp_cache_switch_to_blog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_cache_switch_to_blog函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: switch_to_blog

 /**
  * Cache-safe switching in case any multi-site hiccups might occur.
  * Clears the cache after switching to the given blog to avoid using
  * another blog's cached values.
  * See  wp_cache_reset() in wp-includes/cache.php
  * @see wp_cache_reset()
  * @link http://core.trac.wordpress.org/ticket/14941
  *
  * @param int $blog_id
  */
 public static function switch_to_blog($blog_id)
 {
     switch_to_blog($blog_id);
     if (function_exists('wp_cache_switch_to_blog')) {
         wp_cache_switch_to_blog($blog_id);
         // introduced in WP 3.5.0
     } else {
         wp_cache_reset();
         // deprecated in WP 3.5.0
     }
 }
开发者ID:solsticehc,项目名称:solsticehc,代码行数:21,代码来源:class-groups-controller.php


示例2: wp_start_object_cache

/**
 * Start the WordPress object cache.
 *
 * If an object-cache.php file exists in the wp-content directory,
 * it uses that drop-in as an external object cache.
 *
 * @since 3.0.0
 * @access private
 *
 * @global int $blog_id Blog ID.
 */
function wp_start_object_cache()
{
    global $blog_id;
    $first_init = false;
    if (!function_exists('wp_cache_init')) {
        if (file_exists(WP_CONTENT_DIR . '/object-cache.php')) {
            require_once WP_CONTENT_DIR . '/object-cache.php';
            if (function_exists('wp_cache_init')) {
                wp_using_ext_object_cache(true);
            }
        }
        $first_init = true;
    } elseif (!wp_using_ext_object_cache() && file_exists(WP_CONTENT_DIR . '/object-cache.php')) {
        /*
         * Sometimes advanced-cache.php can load object-cache.php before
         * it is loaded here. This breaks the function_exists check above
         * and can result in `$_wp_using_ext_object_cache` being set
         * incorrectly. Double check if an external cache exists.
         */
        wp_using_ext_object_cache(true);
    }
    if (!wp_using_ext_object_cache()) {
        require_once ABSPATH . WPINC . '/cache.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($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('users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache'));
        wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins'));
    }
}
开发者ID:hughnet,项目名称:WordPress,代码行数:50,代码来源:load.php


示例3: restore_current_blog

/**
 * Restore the current blog, after calling switch_to_blog()
 *
 * @see switch_to_blog()
 * @since MU
 *
 * @return bool True on success, false if we're already on the current blog
 */
function restore_current_blog()
{
    global $wpdb, $wp_roles;
    if (empty($GLOBALS['_wp_switched_stack'])) {
        return false;
    }
    $blog = array_pop($GLOBALS['_wp_switched_stack']);
    if ($GLOBALS['blog_id'] == $blog) {
        /** This filter is documented in wp-includes/ms-blogs.php */
        do_action('switch_blog', $blog, $blog);
        // If we still have items in the switched stack, consider ourselves still 'switched'
        $GLOBALS['switched'] = !empty($GLOBALS['_wp_switched_stack']);
        return true;
    }
    $wpdb->set_blog_id($blog);
    $prev_blog_id = $GLOBALS['blog_id'];
    $GLOBALS['blog_id'] = $blog;
    $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
    if (function_exists('wp_cache_switch_to_blog')) {
        wp_cache_switch_to_blog($blog);
    } 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();
        if (function_exists('wp_cache_add_global_groups')) {
            if (is_array($global_groups)) {
                wp_cache_add_global_groups($global_groups);
            } else {
                wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', ' blog-id-cache'));
            }
            wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins'));
        }
    }
    if (did_action('init')) {
        $wp_roles->reinit();
        $current_user = wp_get_current_user();
        $current_user->for_blog($blog);
    }
    /** This filter is documented in wp-includes/ms-blogs.php */
    do_action('switch_blog', $blog, $prev_blog_id);
    // If we still have items in the switched stack, consider ourselves still 'switched'
    $GLOBALS['switched'] = !empty($GLOBALS['_wp_switched_stack']);
    return true;
}
开发者ID:trinoamez,项目名称:WordpressPlatzi,代码行数:56,代码来源:ms-blogs.php


示例4: restore_current_blog

/**
 * Restore the current blog, after calling switch_to_blog()
 *
 * @see switch_to_blog()
 * @since MU
 *
 * @return bool True on success, False if we're already on the current blog
 */
function restore_current_blog()
{
    global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $wp_object_cache;
    if (!$switched) {
        return false;
    }
    if (!is_array($switched_stack)) {
        return false;
    }
    $blog = array_pop($switched_stack);
    if ($blog_id == $blog) {
        do_action('switch_blog', $blog, $blog);
        /* If we still have items in the switched stack, consider ourselves still 'switched' */
        $switched = is_array($switched_stack) && count($switched_stack) > 0;
        return true;
    }
    $wpdb->set_blog_id($blog);
    $prev_blog_id = $blog_id;
    $blog_id = $blog;
    $table_prefix = $wpdb->prefix;
    if (is_object($wp_roles)) {
        $wpdb->suppress_errors();
        if (method_exists($wp_roles, '_init')) {
            $wp_roles->_init();
        } elseif (method_exists($wp_roles, '__construct')) {
            $wp_roles->__construct();
        }
        $wpdb->suppress_errors(false);
    }
    if (did_action('init')) {
        $current_user = wp_get_current_user();
        if (is_object($current_user)) {
            $current_user->for_blog($blog_id);
        }
    }
    if (function_exists('wp_cache_switch_to_blog')) {
        wp_cache_switch_to_blog($blog_id);
    } else {
        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();
        if (function_exists('wp_cache_add_global_groups')) {
            if (is_array($global_groups)) {
                wp_cache_add_global_groups($global_groups);
            } else {
                wp_cache_add_global_groups(array('users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts'));
            }
            wp_cache_add_non_persistent_groups(array('comment', 'counts', 'plugins'));
        }
    }
    do_action('switch_blog', $blog_id, $prev_blog_id);
    /* If we still have items in the switched stack, consider ourselves still 'switched' */
    $switched = is_array($switched_stack) && count($switched_stack) > 0;
    return true;
}
开发者ID:neshoba78,项目名称:WordPress,代码行数:66,代码来源:ms-blogs.php



注:本文中的wp_cache_switch_to_blog函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_cache_user_agent_is_rejected函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_cache_set函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap