# restore_current_blog()

URL: https://chugunov.pro/api-wordpress/functions/restore_current_blog/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: MU (3.0.0).

## Сигнатура

```php
restore_current_blog(): bool
```

## Описание

См. alsoswitch_to_blog()

## Возвращаемое значение

`bool`

## Исходный код

Файл: `wp-includes/ms-blogs.php:563`

```php
function restore_current_blog() {
	global $wpdb;

	if ( empty( $GLOBALS['_wp_switched_stack'] ) ) {
		return false;
	}

	$new_blog_id  = array_pop( $GLOBALS['_wp_switched_stack'] );
	$prev_blog_id = get_current_blog_id();

	if ( $new_blog_id === $prev_blog_id ) {
		/** This filter is documented in wp-includes/ms-blogs.php */
		do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' );

		// If we still have items in the switched stack, consider ourselves still 'switched'.
		$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );

		return true;
	}

	$wpdb->set_blog_id( $new_blog_id );
	$GLOBALS['blog_id']      = $new_blog_id;
	$GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();

	wp_cache_switch_to_blog( $new_blog_id );

	/** This filter is documented in wp-includes/ms-blogs.php */
	do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' );

	// If we still have items in the switched stack, consider ourselves still 'switched'.
	$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );

	return true;
}
```

## История изменений

- MU (3.0.0) — Introduced.

## Связанные

Использует: [`wp_cache_switch_to_blog`](https://chugunov.pro/api-wordpress/functions/wp_cache_switch_to_blog/), `wpdb::set_blog_id`, `wpdb::get_blog_prefix`, [`get_current_blog_id`](https://chugunov.pro/api-wordpress/functions/get_current_blog_id/), [`do_action`](https://chugunov.pro/api-wordpress/functions/do_action/).
Используется в: `WP_User_Query::get_cache_last_changed`, [`user_can_for_site`](https://chugunov.pro/api-wordpress/functions/user_can_for_site/), [`current_user_can_for_site`](https://chugunov.pro/api-wordpress/functions/current_user_can_for_site/), [`wp_initialize_site`](https://chugunov.pro/api-wordpress/functions/wp_initialize_site/), [`wp_uninitialize_site`](https://chugunov.pro/api-wordpress/functions/wp_uninitialize_site/), [`wp_is_site_initialized`](https://chugunov.pro/api-wordpress/functions/wp_is_site_initialized/), [`get_oembed_response_data_for_url`](https://chugunov.pro/api-wordpress/functions/get_oembed_response_data_for_url/), `WP_Site::get_details`, [`has_custom_logo`](https://chugunov.pro/api-wordpress/functions/has_custom_logo/), [`get_custom_logo`](https://chugunov.pro/api-wordpress/functions/get_custom_logo/), [`wp_get_users_with_no_role`](https://chugunov.pro/api-wordpress/functions/wp_get_users_with_no_role/), [`get_site_icon_url`](https://chugunov.pro/api-wordpress/functions/get_site_icon_url/), `WP_MS_Sites_List_Table::column_blogname`, [`confirm_another_blog_signup`](https://chugunov.pro/api-wordpress/functions/confirm_another_blog_signup/), [`wpmu_delete_user`](https://chugunov.pro/api-wordpress/functions/wpmu_delete_user/), [`upload_space_setting`](https://chugunov.pro/api-wordpress/functions/upload_space_setting/), [`wpmu_delete_blog`](https://chugunov.pro/api-wordpress/functions/wpmu_delete_blog/), `WP_Users_List_Table::get_views`, `WP_User::get_role_caps`, `WP_Theme::get_allowed_on_site`, [`get_home_url`](https://chugunov.pro/api-wordpress/functions/get_home_url/), [`get_site_url`](https://chugunov.pro/api-wordpress/functions/get_site_url/), [`wp_admin_bar_my_sites_menu`](https://chugunov.pro/api-wordpress/functions/wp_admin_bar_my_sites_menu/), [`count_users`](https://chugunov.pro/api-wordpress/functions/count_users/), [`newblog_notify_siteadmin`](https://chugunov.pro/api-wordpress/functions/newblog_notify_siteadmin/), [`create_empty_blog`](https://chugunov.pro/api-wordpress/functions/create_empty_blog/), [`get_blog_post`](https://chugunov.pro/api-wordpress/functions/get_blog_post/), [`add_user_to_blog`](https://chugunov.pro/api-wordpress/functions/add_user_to_blog/), [`remove_user_from_blog`](https://chugunov.pro/api-wordpress/functions/remove_user_from_blog/), [`get_blog_permalink`](https://chugunov.pro/api-wordpress/functions/get_blog_permalink/), [`get_blog_option`](https://chugunov.pro/api-wordpress/functions/get_blog_option/), [`add_blog_option`](https://chugunov.pro/api-wordpress/functions/add_blog_option/), [`delete_blog_option`](https://chugunov.pro/api-wordpress/functions/delete_blog_option/), [`update_blog_option`](https://chugunov.pro/api-wordpress/functions/update_blog_option/), [`get_blog_details`](https://chugunov.pro/api-wordpress/functions/get_blog_details/), `wp_xmlrpc_server::wp_getUsersBlogs`.

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/restore_current_blog/
