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 |
---|---|
591 | if ( $new_blog == $GLOBALS['blog_id'] ) { |
592 | /** |
593 | * Fires when the blog is switched. |
594 | * |
595 | * @since MU |
596 | * |
597 | * @param int $new_blog New blog ID. |
598 | * @param int $new_blog Blog ID. |
599 | */ |
600 | do_action( 'switch_blog', $new_blog, $new_blog ); |
601 | $GLOBALS['switched'] = true; |
602 | return true; |
603 | } |
604 |
|
605 | $wpdb->set_blog_id( $new_blog ); |
606 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
607 | $prev_blog_id = $GLOBALS['blog_id']; |
608 | $GLOBALS['blog_id'] = $new_blog; |
609 |
|
Line | Code |
629 | } |
630 |
|
631 | if ( did_action( 'init' ) ) { |
632 | $wp_roles->reinit(); |
633 | $current_user = wp_get_current_user(); |
634 | $current_user->for_blog( $new_blog ); |
635 | } |
636 |
|
637 | /** This filter is documented in wp-includes/ms-blogs.php */ |
638 | do_action( 'switch_blog', $new_blog, $prev_blog_id ); |
639 | $GLOBALS['switched'] = true; |
640 |
|
641 | return true; |
642 | } |
643 |
|
644 | /** |
645 | * Restore the current blog, after calling switch_to_blog() |
646 | * |
647 | * @see switch_to_blog() |
Line | Code |
653 | global $wpdb, $wp_roles; |
654 |
|
655 | if ( empty( $GLOBALS['_wp_switched_stack'] ) ) |
656 | return false; |
657 |
|
658 | $blog = array_pop( $GLOBALS['_wp_switched_stack'] ); |
659 |
|
660 | if ( $GLOBALS['blog_id'] == $blog ) { |
661 | /** This filter is documented in wp-includes/ms-blogs.php */ |
662 | do_action( 'switch_blog', $blog, $blog ); |
663 | // If we still have items in the switched stack, consider ourselves still 'switched' |
664 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
665 | return true; |
666 | } |
667 |
|
668 | $wpdb->set_blog_id( $blog ); |
669 | $prev_blog_id = $GLOBALS['blog_id']; |
670 | $GLOBALS['blog_id'] = $blog; |
671 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
Line | Code |
692 | } |
693 |
|
694 | if ( did_action( 'init' ) ) { |
695 | $wp_roles->reinit(); |
696 | $current_user = wp_get_current_user(); |
697 | $current_user->for_blog( $blog ); |
698 | } |
699 |
|
700 | /** This filter is documented in wp-includes/ms-blogs.php */ |
701 | do_action( 'switch_blog', $blog, $prev_blog_id ); |
702 |
|
703 | // If we still have items in the switched stack, consider ourselves still 'switched' |
704 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
705 |
|
706 | return true; |
707 | } |
708 |
|
709 | /** |
710 | * Determines if switch_to_blog() is in effect |