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 |
---|---|
816 | if ( $new_blog == $blog_id ) { |
817 | /** |
818 | * Fires when the blog is switched. |
819 | * |
820 | * @since MU (3.0.0) |
821 | * |
822 | * @param int $new_blog New blog ID. |
823 | * @param int $new_blog Blog ID. |
824 | */ |
825 | do_action( 'switch_blog', $new_blog, $new_blog ); |
826 | $GLOBALS['switched'] = true; |
827 | return true; |
828 | } |
829 |
|
830 | $wpdb->set_blog_id( $new_blog ); |
831 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
832 | $prev_blog_id = $blog_id; |
833 | $GLOBALS['blog_id'] = $new_blog; |
834 |
|
Line | Code |
849 | wp_cache_add_global_groups( $global_groups ); |
850 | } else { |
851 | wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) ); |
852 | } |
853 | wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); |
854 | } |
855 | } |
856 |
|
857 | /** This filter is documented in wp-includes/ms-blogs.php */ |
858 | do_action( 'switch_blog', $new_blog, $prev_blog_id ); |
859 | $GLOBALS['switched'] = true; |
860 |
|
861 | return true; |
862 | } |
863 |
|
864 | /** |
865 | * Restore the current blog, after calling switch_to_blog() |
866 | * |
867 | * @see switch_to_blog() |
Line | Code |
882 | if ( empty( $GLOBALS['_wp_switched_stack'] ) ) { |
883 | return false; |
884 | } |
885 |
|
886 | $blog = array_pop( $GLOBALS['_wp_switched_stack'] ); |
887 | $blog_id = get_current_blog_id(); |
888 |
|
889 | if ( $blog_id == $blog ) { |
890 | /** This filter is documented in wp-includes/ms-blogs.php */ |
891 | do_action( 'switch_blog', $blog, $blog ); |
892 | // If we still have items in the switched stack, consider ourselves still 'switched' |
893 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
894 | return true; |
895 | } |
896 |
|
897 | $wpdb->set_blog_id( $blog ); |
898 | $prev_blog_id = $blog_id; |
899 | $GLOBALS['blog_id'] = $blog; |
900 | $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); |
Line | Code |
917 | wp_cache_add_global_groups( $global_groups ); |
918 | } else { |
919 | wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'useremail', 'userslugs', 'site-transient', 'site-options', 'blog-lookup', 'blog-details', 'rss', 'global-posts', 'blog-id-cache', 'networks', 'sites', 'site-details' ) ); |
920 | } |
921 | wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); |
922 | } |
923 | } |
924 |
|
925 | /** This filter is documented in wp-includes/ms-blogs.php */ |
926 | do_action( 'switch_blog', $blog, $prev_blog_id ); |
927 |
|
928 | // If we still have items in the switched stack, consider ourselves still 'switched' |
929 | $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); |
930 |
|
931 | return true; |
932 | } |
933 |
|
934 | /** |
935 | * Switches the initialized roles and current user capabilities to another site. |