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 |
|---|---|
| 382 | if ( empty($switched_stack) ) |
| 383 | $switched_stack = array(); |
| 384 | |
| 385 | $switched_stack[] = $blog_id; |
| 386 | |
| 387 | /* If we're switching to the same blog id that we're on, |
| 388 | * set the right vars, do the associated actions, but skip |
| 389 | * the extra unnecessary work */ |
| 390 | if ( $blog_id == $new_blog ) { |
| 391 | do_action( 'switch_blog', $blog_id, $blog_id ); |
| 392 | $switched = true; |
| 393 | return true; |
| 394 | } |
| 395 | |
| 396 | $wpdb->set_blog_id($new_blog); |
| 397 | $table_prefix = $wpdb->prefix; |
| 398 | $prev_blog_id = $blog_id; |
| 399 | $blog_id = $new_blog; |
| 400 | |
| Line | Code |
| 418 | wp_cache_init(); |
| 419 | if ( function_exists('wp_cache_add_global_groups') ) { |
| 420 | if ( is_array( $global_groups ) ) |
| 421 | wp_cache_add_global_groups( $global_groups ); |
| 422 | else |
| 423 | wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'site-transient', 'global-posts' ) ); |
| 424 | wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' )); |
| 425 | } |
| 426 | |
| 427 | do_action('switch_blog', $blog_id, $prev_blog_id); |
| 428 | $switched = true; |
| 429 | return true; |
| 430 | } |
| 431 | |
| 432 | function restore_current_blog() { |
| 433 | global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $current_user, $wp_object_cache; |
| 434 | |
| 435 | if ( !$switched ) |
| 436 | return false; |
| 437 | |
| 438 | if ( !is_array( $switched_stack ) ) |
| 439 | return false; |
| 440 | |
| 441 | $blog = array_pop( $switched_stack ); |
| 442 | if ( $blog_id == $blog ) { |
| 443 | do_action( 'switch_blog', $blog, $blog ); |
| 444 | /* If we still have items in the switched stack, consider ourselves still 'switched' */ |
| 445 | $switched = ( is_array( $switched_stack ) && count( $switched_stack ) > 0 ); |
| 446 | return true; |
| 447 | } |
| 448 | |
| 449 | $wpdb->set_blog_id($blog); |
| 450 | $prev_blog_id = $blog_id; |
| 451 | $blog_id = $blog; |
| 452 | $table_prefix = $wpdb->prefix; |
| Line | Code |
| 471 | wp_cache_init(); |
| 472 | if ( function_exists('wp_cache_add_global_groups') ) { |
| 473 | if ( is_array( $global_groups ) ) |
| 474 | wp_cache_add_global_groups( $global_groups ); |
| 475 | else |
| 476 | wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'site-transient' ) ); |
| 477 | wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' )); |
| 478 | } |
| 479 | |
| 480 | do_action('switch_blog', $blog_id, $prev_blog_id); |
| 481 | |
| 482 | /* If we still have items in the switched stack, consider ourselves still 'switched' */ |
| 483 | $switched = ( is_array( $switched_stack ) && count( $switched_stack ) > 0 ); |
| 484 | return true; |
| 485 | } |
| 486 | |
| 487 | function is_archived( $id ) { |
| 488 | return get_blog_status($id, 'archived'); |
| 489 | } |