# set_site_transient()

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

Тип: функция.
Появился в версии: 2.9.0.

## Сигнатура

```php
set_site_transient( string $transient, mixed $value, int $expiration ): bool
```

## Описание

Сериализовать значения не нужно. Если значение требует сериализации, оно будет сериализовано перед установкой.
См. alsoset_transient()

## Параметры

- `$transient` `string` — обязательный. Имя транзиента. Ожидается, что не экранировано для SQL. Длина не должна превышать 167 символов.
- `$value` `mixed` — обязательный. Значение транзиента. Ожидается, что не экранировано для SQL.
- `$expiration` `int` — необязательный. Время до истечения срока в секундах. Значение по умолчанию 0 (без истечения).

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

`bool`

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

Файл: `wp-includes/option.php:2639`

```php
function set_site_transient( $transient, $value, $expiration = 0 ) {

	/**
	 * Filters the value of a specific site transient before it is set.
	 *
	 * The dynamic portion of the hook name, `$transient`, refers to the transient name.
	 *
	 * @since 3.0.0
	 * @since 4.4.0 The `$transient` parameter was added.
	 *
	 * @param mixed  $value     New value of site transient.
	 * @param string $transient Transient name.
	 */
	$value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient );

	$expiration = (int) $expiration;

	/**
	 * Filters the expiration for a site transient before its value is set.
	 *
	 * The dynamic portion of the hook name, `$transient`, refers to the transient name.
	 *
	 * @since 4.4.0
	 *
	 * @param int    $expiration Time until expiration in seconds. Use 0 for no expiration.
	 * @param mixed  $value      New value of site transient.
	 * @param string $transient  Transient name.
	 */
	$expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient );

	if ( wp_using_ext_object_cache() || wp_installing() ) {
		$result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
	} else {
		$transient_timeout = '_site_transient_timeout_' . $transient;
		$option            = '_site_transient_' . $transient;
		wp_prime_site_option_caches( array( $option, $transient_timeout ) );

		if ( false === get_site_option( $option ) ) {
			if ( $expiration ) {
				add_site_option( $transient_timeout, time() + $expiration );
			}
			$result = add_site_option( $option, $value );
		} else {
			if ( $expiration ) {
				update_site_option( $transient_timeout, time() + $expiration );
			}
			$result = update_site_option( $option, $value );
		}
	}

	if ( $result ) {

		/**
		 * Fires after the value for a specific site transient has been set.
		 *
		 * The dynamic portion of the hook name, `$transient`, refers to the transient name.
		 *
		 * @since 3.0.0
		 * @since 4.4.0 The `$transient` parameter was added
		 *
		 * @param mixed  $value      Site transient value.
		 * @param int    $expiration Time until expiration in seconds.
		 * @param string $transient  Transient name.
		 */
		do_action( "set_site_transient_{$transient}", $value, $expiration, $transient );

		/**
		 * Fires after the value for a site transient has been set.
		 *
		 * @since 6.8.0
		 *
		 * @param string $transient  The name of the site transient.
		 * @param mixed  $value      Site transient value.
		 * @param int    $expiration Time until expiration in seconds.
		 */
		do_action( 'set_site_transient', $transient, $value, $expiration );

		/**
		 * Fires after the value for a site transient has been set.
		 *
		 * @since 3.0.0
		 * @deprecated 6.8.0 Use 'set_site_transient' instead.
		 *
		 * @param string $transient  The name of the site transient.
		 * @param mixed  $value      Site transient value.
		 * @param int    $expiration Time until expiration in seconds.
		 */
		do_action_deprecated( 'setted_site_transient', array( $transient, $value, $expiration ), '6.8.0', 'set_site_transient' );
	}

	return $result;
}
```

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

- 2.9.0 — Introduced.

## Связанные

Использует: [`wp_prime_site_option_caches`](https://chugunov.pro/api-wordpress/functions/wp_prime_site_option_caches/), [`do_action_deprecated`](https://chugunov.pro/api-wordpress/functions/do_action_deprecated/), [`wp_installing`](https://chugunov.pro/api-wordpress/functions/wp_installing/), [`wp_cache_set`](https://chugunov.pro/api-wordpress/functions/wp_cache_set/), [`wp_using_ext_object_cache`](https://chugunov.pro/api-wordpress/functions/wp_using_ext_object_cache/), [`add_site_option`](https://chugunov.pro/api-wordpress/functions/add_site_option/), [`update_site_option`](https://chugunov.pro/api-wordpress/functions/update_site_option/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`do_action`](https://chugunov.pro/api-wordpress/functions/do_action/), [`get_site_option`](https://chugunov.pro/api-wordpress/functions/get_site_option/).
Используется в: `WP_Plugin_Dependencies::get_dependency_api_data`, `WP_Font_Collection::load_from_url`, `WP_Theme::set_pattern_cache`, `WP_REST_URL_Details_Controller::set_cache`, `WP_REST_Pattern_Directory_Controller::get_items`, [`wp_check_php_version`](https://chugunov.pro/api-wordpress/functions/wp_check_php_version/), `WP_Community_Events::cache_events`, [`wp_get_available_translations`](https://chugunov.pro/api-wordpress/functions/wp_get_available_translations/), [`get_theme_feature_list`](https://chugunov.pro/api-wordpress/functions/get_theme_feature_list/), [`wp_check_browser_version`](https://chugunov.pro/api-wordpress/functions/wp_check_browser_version/), [`install_popular_tags`](https://chugunov.pro/api-wordpress/functions/install_popular_tags/), [`delete_plugins`](https://chugunov.pro/api-wordpress/functions/delete_plugins/), [`wp_get_popular_importers`](https://chugunov.pro/api-wordpress/functions/wp_get_popular_importers/), [`wp_credits`](https://chugunov.pro/api-wordpress/functions/wp_credits/), [`search_theme_directories`](https://chugunov.pro/api-wordpress/functions/search_theme_directories/), `WP_Feed_Cache_Transient::save`, `WP_Feed_Cache_Transient::touch`, [`wp_version_check`](https://chugunov.pro/api-wordpress/functions/wp_version_check/), [`wp_update_plugins`](https://chugunov.pro/api-wordpress/functions/wp_update_plugins/), [`wp_update_themes`](https://chugunov.pro/api-wordpress/functions/wp_update_themes/).

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