restore_current_blog [ WordPress Function ]
restore_current_blog ( No parameters )
| See: | |
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: get_current_blog_id, create_empty_blog, set_current_user, get_current_site, remove_user_from_blog
Restore the current blog, after calling switch_to_blog()
Source
<?php
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 ( 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;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- WPMU Functions/restore current blog « WordPress Codex
Description. Restores previous blog after a switch_to_blog call. Contrary to the function's name, this does NOT restore the original blog but the previous blog.
codex.wordpress.org - Function Reference/restore current blog « WordPress Codex
Function Reference/restore current blog. Description. Restore the current blog, after calling switch_to_blog(). Return Values. (boolean): True on success, False if ...
codex.wordpress.org - #18797 (Rename restore_current_blog() to restore_previous_blog ...
Contrary to it's name, restore_current_blog() does not restore the current blog but rather the previous blog. If you call switch_to_blog() twice and then call ...
core.trac.wordpress.org - restore_current_blog (WordPress Function) - WPSeek.com
WordPress lookup for restore_current_blog, a WordPress Function. wpseek.com is a WordPress-centric search tool for developers and theme authors.
wpseek.com