wpseek.com
A WordPress-centric search engine for devs and theme authors
restore_current_blog › WordPress Function
Sincen/a
Deprecatedn/a
› restore_current_blog ( No parameters )
| See: | |
| Returns: |
|
| Defined at: |
|
| Codex: | |
| Change Log: |
|
Restores the current blog, after calling switch_to_blog().
Related Functions: restore_current_locale, get_current_blog_id, create_empty_blog, get_current_site, set_current_user
Source
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();
wp_cache_switch_to_blog( $new_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;
}