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 |
---|---|
513 | * |
514 | * @since MU (3.0.0) |
515 | * @since 5.4.0 The `$context` parameter was added. |
516 | * |
517 | * @param int $new_blog_id New blog ID. |
518 | * @param int $prev_blog_id Previous blog ID. |
519 | * @param string $context Additional context. Accepts 'switch' when called from switch_to_blog() |
520 | * or 'restore' when called from restore_current_blog(). |
521 | */ |
522 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); |
523 |
|
524 | $GLOBALS['switched'] = true; |
525 |
|
526 | return true; |
527 | } |
528 |
|
529 | $wpdb->set_blog_id( $new_blog_id ); |
530 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
531 | $GLOBALS['blog_id'] = $new_blog_id; |
Line | Code |
573 | ) |
574 | ); |
575 | } |
576 |
|
577 | wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); |
578 | } |
579 | } |
580 |
|
581 | /** This filter is documented in wp-includes/ms-blogs.php */ |
582 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); |
583 |
|
584 | $GLOBALS['switched'] = true; |
585 |
|
586 | return true; |
587 | } |
588 |
|
589 | /** |
590 | * Restores the current blog, after calling switch_to_blog(). |
591 | * |
Line | Code |
607 | if ( empty( $GLOBALS['_wp_switched_stack'] ) ) { |
608 | return false; |
609 | } |
610 |
|
611 | $new_blog_id = array_pop( $GLOBALS['_wp_switched_stack'] ); |
612 | $prev_blog_id = get_current_blog_id(); |
613 |
|
614 | if ( $new_blog_id === $prev_blog_id ) { |
615 | /** This filter is documented in wp-includes/ms-blogs.php */ |
616 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); |
617 |
|
618 | // If we still have items in the switched stack, consider ourselves still 'switched'. |
619 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
620 |
|
621 | return true; |
622 | } |
623 |
|
624 | $wpdb->set_blog_id( $new_blog_id ); |
625 | $GLOBALS['blog_id'] = $new_blog_id; |
Line | Code |
668 | ) |
669 | ); |
670 | } |
671 |
|
672 | wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); |
673 | } |
674 | } |
675 |
|
676 | /** This filter is documented in wp-includes/ms-blogs.php */ |
677 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); |
678 |
|
679 | // If we still have items in the switched stack, consider ourselves still 'switched'. |
680 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
681 |
|
682 | return true; |
683 | } |
684 |
|
685 | /** |
686 | * Switches the initialized roles and current user capabilities to another site. |