Summery Summery
Restore the current blog, after calling switch_to_blog().
Syntax Syntax
Return Return
(bool) True on success, false if we're already on the current blog.
Source Source
File: wp-includes/ms-blogs.php
* Restore the current blog, after calling switch_to_blog(). * * @see switch_to_blog() * @since MU (3.0.0) * * @global wpdb $wpdb WordPress database abstraction object. * @global array $_wp_switched_stack * @global int $blog_id * @global bool $switched * @global string $table_prefix * @global WP_Object_Cache $wp_object_cache * * @return bool True on success, false if we're already on the current blog. */ function restore_current_blog() { global $wpdb; if ( empty( $GLOBALS['_wp_switched_stack'] ) ) { return false; } $new_blog_id = array_pop( $GLOBALS['_wp_switched_stack'] ); $prev_blog_id = get_current_blog_id(); if ( $new_blog_id == $prev_blog_id ) { /** This filter is documented in wp-includes/ms-blogs.php */ do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); // 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( $new_blog_id ); $GLOBALS['blog_id'] = $new_blog_id; $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); 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(); if ( function_exists( 'wp_cache_add_global_groups' ) ) { if ( is_array( $global_groups ) ) {
Advertisement
Changelog Changelog
Version | Description |
---|---|
MU (3.0.0) | Introduced. |