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 |
|---|---|
| 596 | if ( $new_blog == $GLOBALS['blog_id'] ) { |
| 597 | /** |
| 598 | * Fires when the blog is switched. |
| 599 | * |
| 600 | * @since MU |
| 601 | * |
| 602 | * @param int $new_blog New blog ID. |
| 603 | * @param int $new_blog Blog ID. |
| 604 | */ |
| 605 | do_action( 'switch_blog', $new_blog, $new_blog ); |
| 606 | $GLOBALS['switched'] = true; |
| 607 | return true; |
| 608 | } |
| 609 | |
| 610 | $wpdb->set_blog_id( $new_blog ); |
| 611 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
| 612 | $prev_blog_id = $GLOBALS['blog_id']; |
| 613 | $GLOBALS['blog_id'] = $new_blog; |
| 614 | |
| Line | Code |
| 635 | } |
| 636 | |
| 637 | if ( did_action( 'init' ) ) { |
| 638 | $wp_roles->reinit(); |
| 639 | $current_user = wp_get_current_user(); |
| 640 | $current_user->for_blog( $new_blog ); |
| 641 | } |
| 642 | |
| 643 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 644 | do_action( 'switch_blog', $new_blog, $prev_blog_id ); |
| 645 | $GLOBALS['switched'] = true; |
| 646 | |
| 647 | return true; |
| 648 | } |
| 649 | |
| 650 | /** |
| 651 | * Restore the current blog, after calling switch_to_blog() |
| 652 | * |
| 653 | * @see switch_to_blog() |
| Line | Code |
| 659 | global $wpdb, $wp_roles; |
| 660 | |
| 661 | if ( empty( $GLOBALS['_wp_switched_stack'] ) ) |
| 662 | return false; |
| 663 | |
| 664 | $blog = array_pop( $GLOBALS['_wp_switched_stack'] ); |
| 665 | |
| 666 | if ( $GLOBALS['blog_id'] == $blog ) { |
| 667 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 668 | do_action( 'switch_blog', $blog, $blog ); |
| 669 | // If we still have items in the switched stack, consider ourselves still 'switched' |
| 670 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
| 671 | return true; |
| 672 | } |
| 673 | |
| 674 | $wpdb->set_blog_id( $blog ); |
| 675 | $prev_blog_id = $GLOBALS['blog_id']; |
| 676 | $GLOBALS['blog_id'] = $blog; |
| 677 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
| Line | Code |
| 699 | } |
| 700 | |
| 701 | if ( did_action( 'init' ) ) { |
| 702 | $wp_roles->reinit(); |
| 703 | $current_user = wp_get_current_user(); |
| 704 | $current_user->for_blog( $blog ); |
| 705 | } |
| 706 | |
| 707 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 708 | do_action( 'switch_blog', $blog, $prev_blog_id ); |
| 709 | |
| 710 | // If we still have items in the switched stack, consider ourselves still 'switched' |
| 711 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
| 712 | |
| 713 | return true; |
| 714 | } |
| 715 | |
| 716 | /** |
| 717 | * Determines if switch_to_blog() is in effect |