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 |
| 572 | ) |
| 573 | ); |
| 574 | } |
| 575 | |
| 576 | wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 581 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); |
| 582 | |
| 583 | $GLOBALS['switched'] = true; |
| 584 | |
| 585 | return true; |
| 586 | } |
| 587 | |
| 588 | /** |
| 589 | * Restores the current blog, after calling switch_to_blog(). |
| 590 | * |
| Line | Code |
| 606 | if ( empty( $GLOBALS['_wp_switched_stack'] ) ) { |
| 607 | return false; |
| 608 | } |
| 609 | |
| 610 | $new_blog_id = array_pop( $GLOBALS['_wp_switched_stack'] ); |
| 611 | $prev_blog_id = get_current_blog_id(); |
| 612 | |
| 613 | if ( $new_blog_id === $prev_blog_id ) { |
| 614 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 615 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); |
| 616 | |
| 617 | // If we still have items in the switched stack, consider ourselves still 'switched'. |
| 618 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
| 619 | |
| 620 | return true; |
| 621 | } |
| 622 | |
| 623 | $wpdb->set_blog_id( $new_blog_id ); |
| 624 | $GLOBALS['blog_id'] = $new_blog_id; |
| Line | Code |
| 666 | ) |
| 667 | ); |
| 668 | } |
| 669 | |
| 670 | wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 675 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); |
| 676 | |
| 677 | // If we still have items in the switched stack, consider ourselves still 'switched'. |
| 678 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
| 679 | |
| 680 | return true; |
| 681 | } |
| 682 | |
| 683 | /** |
| 684 | * Switches the initialized roles and current user capabilities to another site. |