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 |
|---|---|
| 613 | if ( $new_blog == $GLOBALS['blog_id'] ) { |
| 614 | /** |
| 615 | * Fires when the blog is switched. |
| 616 | * |
| 617 | * @since MU |
| 618 | * |
| 619 | * @param int $new_blog New blog ID. |
| 620 | * @param int $new_blog Blog ID. |
| 621 | */ |
| 622 | do_action( 'switch_blog', $new_blog, $new_blog ); |
| 623 | $GLOBALS['switched'] = true; |
| 624 | return true; |
| 625 | } |
| 626 | |
| 627 | $wpdb->set_blog_id( $new_blog ); |
| 628 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
| 629 | $prev_blog_id = $GLOBALS['blog_id']; |
| 630 | $GLOBALS['blog_id'] = $new_blog; |
| 631 | |
| Line | Code |
| 652 | } |
| 653 | |
| 654 | if ( did_action( 'init' ) ) { |
| 655 | wp_roles()->reinit(); |
| 656 | $current_user = wp_get_current_user(); |
| 657 | $current_user->for_blog( $new_blog ); |
| 658 | } |
| 659 | |
| 660 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 661 | do_action( 'switch_blog', $new_blog, $prev_blog_id ); |
| 662 | $GLOBALS['switched'] = true; |
| 663 | |
| 664 | return true; |
| 665 | } |
| 666 | |
| 667 | /** |
| 668 | * Restore the current blog, after calling switch_to_blog() |
| 669 | * |
| 670 | * @see switch_to_blog() |
| Line | Code |
| 683 | global $wpdb; |
| 684 | |
| 685 | if ( empty( $GLOBALS['_wp_switched_stack'] ) ) |
| 686 | return false; |
| 687 | |
| 688 | $blog = array_pop( $GLOBALS['_wp_switched_stack'] ); |
| 689 | |
| 690 | if ( $GLOBALS['blog_id'] == $blog ) { |
| 691 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 692 | do_action( 'switch_blog', $blog, $blog ); |
| 693 | // If we still have items in the switched stack, consider ourselves still 'switched' |
| 694 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
| 695 | return true; |
| 696 | } |
| 697 | |
| 698 | $wpdb->set_blog_id( $blog ); |
| 699 | $prev_blog_id = $GLOBALS['blog_id']; |
| 700 | $GLOBALS['blog_id'] = $blog; |
| 701 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
| Line | Code |
| 723 | } |
| 724 | |
| 725 | if ( did_action( 'init' ) ) { |
| 726 | wp_roles()->reinit(); |
| 727 | $current_user = wp_get_current_user(); |
| 728 | $current_user->for_blog( $blog ); |
| 729 | } |
| 730 | |
| 731 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 732 | do_action( 'switch_blog', $blog, $prev_blog_id ); |
| 733 | |
| 734 | // If we still have items in the switched stack, consider ourselves still 'switched' |
| 735 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
| 736 | |
| 737 | return true; |
| 738 | } |
| 739 | |
| 740 | /** |
| 741 | * Determines if switch_to_blog() is in effect |