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 |
---|---|
622 | if ( $new_blog == $GLOBALS['blog_id'] ) { |
623 | /** |
624 | * Fires when the blog is switched. |
625 | * |
626 | * @since MU |
627 | * |
628 | * @param int $new_blog New blog ID. |
629 | * @param int $new_blog Blog ID. |
630 | */ |
631 | do_action( 'switch_blog', $new_blog, $new_blog ); |
632 | $GLOBALS['switched'] = true; |
633 | return true; |
634 | } |
635 |
|
636 | $wpdb->set_blog_id( $new_blog ); |
637 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
638 | $prev_blog_id = $GLOBALS['blog_id']; |
639 | $GLOBALS['blog_id'] = $new_blog; |
640 |
|
Line | Code |
661 | } |
662 |
|
663 | if ( did_action( 'init' ) ) { |
664 | wp_roles()->reinit(); |
665 | $current_user = wp_get_current_user(); |
666 | $current_user->for_blog( $new_blog ); |
667 | } |
668 |
|
669 | /** This filter is documented in wp-includes/ms-blogs.php */ |
670 | do_action( 'switch_blog', $new_blog, $prev_blog_id ); |
671 | $GLOBALS['switched'] = true; |
672 |
|
673 | return true; |
674 | } |
675 |
|
676 | /** |
677 | * Restore the current blog, after calling switch_to_blog() |
678 | * |
679 | * @see switch_to_blog() |
Line | Code |
692 | global $wpdb; |
693 |
|
694 | if ( empty( $GLOBALS['_wp_switched_stack'] ) ) |
695 | return false; |
696 |
|
697 | $blog = array_pop( $GLOBALS['_wp_switched_stack'] ); |
698 |
|
699 | if ( $GLOBALS['blog_id'] == $blog ) { |
700 | /** This filter is documented in wp-includes/ms-blogs.php */ |
701 | do_action( 'switch_blog', $blog, $blog ); |
702 | // If we still have items in the switched stack, consider ourselves still 'switched' |
703 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
704 | return true; |
705 | } |
706 |
|
707 | $wpdb->set_blog_id( $blog ); |
708 | $prev_blog_id = $GLOBALS['blog_id']; |
709 | $GLOBALS['blog_id'] = $blog; |
710 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
Line | Code |
732 | } |
733 |
|
734 | if ( did_action( 'init' ) ) { |
735 | wp_roles()->reinit(); |
736 | $current_user = wp_get_current_user(); |
737 | $current_user->for_blog( $blog ); |
738 | } |
739 |
|
740 | /** This filter is documented in wp-includes/ms-blogs.php */ |
741 | do_action( 'switch_blog', $blog, $prev_blog_id ); |
742 |
|
743 | // If we still have items in the switched stack, consider ourselves still 'switched' |
744 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
745 |
|
746 | return true; |
747 | } |
748 |
|
749 | /** |
750 | * Determines if switch_to_blog() is in effect |