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 |
|---|---|
| 520 | * |
| 521 | * @since MU (3.0.0) |
| 522 | * @since 5.4.0 The `$context` parameter was added. |
| 523 | * |
| 524 | * @param int $new_blog_id New blog ID. |
| 525 | * @param int $prev_blog_id Previous blog ID. |
| 526 | * @param string $context Additional context. Accepts 'switch' when called from switch_to_blog() |
| 527 | * or 'restore' when called from restore_current_blog(). |
| 528 | */ |
| 529 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); |
| 530 | |
| 531 | $GLOBALS['switched'] = true; |
| 532 | |
| 533 | return true; |
| 534 | } |
| 535 | |
| 536 | $wpdb->set_blog_id( $new_blog_id ); |
| 537 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
| 538 | $GLOBALS['blog_id'] = $new_blog_id; |
| Line | Code |
| 580 | ) |
| 581 | ); |
| 582 | } |
| 583 | |
| 584 | wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 589 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); |
| 590 | |
| 591 | $GLOBALS['switched'] = true; |
| 592 | |
| 593 | return true; |
| 594 | } |
| 595 | |
| 596 | /** |
| 597 | * Restores the current blog, after calling switch_to_blog(). |
| 598 | * |
| Line | Code |
| 616 | if ( empty( $GLOBALS['_wp_switched_stack'] ) ) { |
| 617 | return false; |
| 618 | } |
| 619 | |
| 620 | $new_blog_id = array_pop( $GLOBALS['_wp_switched_stack'] ); |
| 621 | $prev_blog_id = get_current_blog_id(); |
| 622 | |
| 623 | if ( $new_blog_id == $prev_blog_id ) { |
| 624 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 625 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); |
| 626 | |
| 627 | // If we still have items in the switched stack, consider ourselves still 'switched'. |
| 628 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
| 629 | |
| 630 | return true; |
| 631 | } |
| 632 | |
| 633 | $wpdb->set_blog_id( $new_blog_id ); |
| 634 | $GLOBALS['blog_id'] = $new_blog_id; |
| Line | Code |
| 677 | ) |
| 678 | ); |
| 679 | } |
| 680 | |
| 681 | wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | /** This filter is documented in wp-includes/ms-blogs.php */ |
| 686 | do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); |
| 687 | |
| 688 | // If we still have items in the switched stack, consider ourselves still 'switched'. |
| 689 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
| 690 | |
| 691 | return true; |
| 692 | } |
| 693 | |
| 694 | /** |
| 695 | * Switches the initialized roles and current user capabilities to another site. |