WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 4 times in this file.
Line | Code |
---|---|
509 | * |
510 | * @since MU (3.0.0) |
511 | * @since 5.4.0 The `$context` parameter was added. |
512 | * |
513 | * @param int $new_blog_id New blog ID. |
514 | * @param int $prev_blog_id Previous blog ID. |
515 | * @param string $context Additional context. Accepts 'switch' when called from switch_to_blog() |
516 | * or 'restore' when called from restore_current_blog(). |
517 | */ |
518 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); |
519 | $GLOBALS['switched'] = true; |
520 | return true; |
521 | } |
522 |
|
523 | $wpdb->set_blog_id( $new_blog_id ); |
524 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
525 | $GLOBALS['blog_id'] = $new_blog_id; |
526 |
|
527 | if ( function_exists( 'wp_cache_switch_to_blog' ) ) { |
Line | Code |
541 | wp_cache_add_global_groups( $global_groups ); |
542 | } else { |
543 | wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details', 'blog_meta' ) ); |
544 | } |
545 | wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); |
546 | } |
547 | } |
548 |
|
549 | /** This filter is documented in wp-includes/ms-blogs.php */ |
550 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); |
551 | $GLOBALS['switched'] = true; |
552 |
|
553 | return true; |
554 | } |
555 |
|
556 | /** |
557 | * Restore the current blog, after calling switch_to_blog(). |
558 | * |
559 | * @see switch_to_blog() |
Line | Code |
574 | if ( empty( $GLOBALS['_wp_switched_stack'] ) ) { |
575 | return false; |
576 | } |
577 |
|
578 | $new_blog_id = array_pop( $GLOBALS['_wp_switched_stack'] ); |
579 | $prev_blog_id = get_current_blog_id(); |
580 |
|
581 | if ( $new_blog_id == $prev_blog_id ) { |
582 | /** This filter is documented in wp-includes/ms-blogs.php */ |
583 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); |
584 | // If we still have items in the switched stack, consider ourselves still 'switched'. |
585 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
586 | return true; |
587 | } |
588 |
|
589 | $wpdb->set_blog_id( $new_blog_id ); |
590 | $GLOBALS['blog_id'] = $new_blog_id; |
591 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
592 |
|
Line | Code |
608 | wp_cache_add_global_groups( $global_groups ); |
609 | } else { |
610 | wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details', 'blog_meta' ) ); |
611 | } |
612 | wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); |
613 | } |
614 | } |
615 |
|
616 | /** This filter is documented in wp-includes/ms-blogs.php */ |
617 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); |
618 |
|
619 | // If we still have items in the switched stack, consider ourselves still 'switched'. |
620 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
621 |
|
622 | return true; |
623 | } |
624 |
|
625 | /** |
626 | * Switches the initialized roles and current user capabilities to another site. |