restore_current_blog()缓存当前博客的信息(多站点)

目录

描述

Restore the current blog, after calling switch_to_blog().

restore_current_blog() 描述

用法

<?php restore_current_blog() ?>

restore_current_blog() 用法

参数

This function does not accept any parameters

restore_current_blog() 参数

返回值

(boolean

True on success, False if we're already on the current blog

restore_current_blog() 返回值

示例

restore_current_blog() 示例

注意

restore_current_blog() should be called after every switch_to_blog(). If not, a global variable which monitors the switching, $GLOBALS['_wp_switched_stack'], will not be empty even if you use switch_to_blog() to return to the original blog. If $GLOBALS['_wp_switched_stack'] is not empty, WP will think it is in a switched state and can potentially return the wrong URL for the site via wp_upload_dir(). See http://wordpress.stackexchange.com/a/123516/27757

When calling switch_to_blog() repeatedly, either call restore_current_blog() each time, or save the original blog ID until the end and call switch_to_blog() with that and do:

The former is probably preferable, as it is not a hack.

restore_current_blog() 注意

历史

添加于 版本: 3.0.0

restore_current_blog() 历史

源文件

restore_current_blog() 函数的代码位于 wp-includes/ms-blogs.php

restore_current_blog() 源文件

相关