On this page
get_site_transient( string $transient ): mixed
Retrieves the value of a site transient.
Description
If the transient does not exist, does not have a value, or has expired, then the return value will be false.
See also
Parameters
$transientstring Required-
Transient name. Expected to not be SQL-escaped.
Return
mixed Value of transient.
Source
File: wp-includes/option.php. View all references
function get_site_transient( $transient ) {
/**
* Filters the value of an existing site transient before it is retrieved.
*
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
*
* Returning a value other than boolean false will short-circuit retrieval and
* return that value instead.
*
* @since 2.9.0
* @since 4.4.0 The `$transient` parameter was added.
*
* @param mixed $pre_site_transient The default value to return if the site transient does not exist.
* Any value other than false will short-circuit the retrieval
* of the transient, and return that value.
* @param string $transient Transient name.
*/
$pre = apply_filters( "pre_site_transient_{$transient}", false, $transient );
if ( false !== $pre ) {
return $pre;
}
if ( wp_using_ext_object_cache() || wp_installing() ) {
$value = wp_cache_get( $transient, 'site-transient' );
} else {
// Core transients that do not have a timeout. Listed here so querying timeouts can be avoided.
$no_timeout = array( 'update_core', 'update_plugins', 'update_themes' );
$transient_option = '_site_transient_' . $transient;
if ( ! in_array( $transient, $no_timeout, true ) ) {
$transient_timeout = '_site_transient_timeout_' . $transient;
$timeout = get_site_option( $transient_timeout );
if ( false !== $timeout && $timeout < time() ) {
delete_site_option( $transient_option );
delete_site_option( $transient_timeout );
$value = false;
}
}
if ( ! isset( $value ) ) {
$value = get_site_option( $transient_option );
}
}
/**
* Filters the value of an existing site transient.
*
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
*
* @since 2.9.0
* @since 4.4.0 The `$transient` parameter was added.
*
* @param mixed $value Value of site transient.
* @param string $transient Transient name.
*/
return apply_filters( "site_transient_{$transient}", $value, $transient );
}
Hooks
- apply_filters( "pre_site_transient_{$transient}",
mixed $pre_site_transient ,string $transient ) -
Filters the value of an existing site transient before it is retrieved.
- apply_filters( "site_transient_{$transient}",
mixed $value ,string $transient ) -
Filters the value of an existing site transient.
Related
Uses
| Uses | Description |
|---|---|
| wp_installing() wp-includes/load.php | Check or set whether WordPress is in “installation” mode. |
| wp_using_ext_object_cache() wp-includes/load.php | Toggle |
| delete_site_option() wp-includes/option.php | Removes a option by name for the current network. |
| wp_cache_get() wp-includes/cache.php | Retrieves the cache contents from the cache by key and group. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
| get_site_option() wp-includes/option.php | Retrieve an option value for the current network based on name of option. |
Used By
| Used By | Description |
|---|---|
| WP_REST_URL_Details_Controller::get_cache() wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php | Utility function to retrieve a value from the cache at a given key. |
| WP_REST_Pattern_Directory_Controller::get_items() wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php | Search and retrieve block patterns metadata |
| WP_MS_Themes_List_Table::column_autoupdates() wp-admin/includes/class-wp-ms-themes-list-table.php | Handles the auto-updates column output. |
| WP_Debug_Data::debug_data() wp-admin/includes/class-wp-debug-data.php | Static function for generating site debug data when required. |
| wp_check_php_version() wp-admin/includes/misc.php | Checks if the user needs to update PHP. |
| WP_Plugin_Install_List_Table::get_installed_plugins() wp-admin/includes/class-wp-plugin-install-list-table.php | Return the list of known plugins. |
| WP_Community_Events::get_cached_events() wp-admin/includes/class-wp-community-events.php | Gets cached events. |
| wp_ajax_update_theme() wp-admin/includes/ajax-actions.php | Ajax handler for updating a theme. |
| wp_get_available_translations() wp-admin/includes/translation-install.php | Get available translations from the WordPress.org API. |
| WP_Automatic_Updater::run() wp-admin/includes/class-wp-automatic-updater.php | Kicks off the background update process, looping through all pending updates. |
| Plugin_Upgrader::bulk_upgrade() wp-admin/includes/class-plugin-upgrader.php | Bulk upgrade several plugins at once. |
| Theme_Upgrader::upgrade() wp-admin/includes/class-theme-upgrader.php | Upgrade a theme. |
| Theme_Upgrader::bulk_upgrade() wp-admin/includes/class-theme-upgrader.php | Upgrade several themes at once. |
| Plugin_Upgrader::upgrade() wp-admin/includes/class-plugin-upgrader.php | Upgrade a plugin. |
| wp_prepare_themes_for_js() wp-admin/includes/theme.php | Prepares themes for JavaScript. |
| get_theme_update_available() wp-admin/includes/theme.php | Retrieves the update link if there is a theme update available. |
| get_theme_feature_list() wp-admin/includes/theme.php | Retrieves list of WordPress theme features (aka theme tags). |
| WP_Plugins_List_Table::single_row() wp-admin/includes/class-wp-plugins-list-table.php | |
| WP_Plugins_List_Table::prepare_items() wp-admin/includes/class-wp-plugins-list-table.php | |
| WP_MS_Themes_List_Table::prepare_items() wp-admin/includes/class-wp-ms-themes-list-table.php | |
| get_core_updates() wp-admin/includes/update.php | Gets available core updates. |
| find_core_auto_update() wp-admin/includes/update.php | Gets the best available (and enabled) Auto-Update for WordPress core. |
| find_core_update() wp-admin/includes/update.php | Finds the available update for WordPress core. |
| get_plugin_updates() wp-admin/includes/update.php | Retrieves plugins with updates available. |
| wp_plugin_update_rows() wp-admin/includes/update.php | Adds a callback to display update information for plugins with updates available. |
| wp_plugin_update_row() wp-admin/includes/update.php | Displays update information for a plugin. |
| get_theme_updates() wp-admin/includes/update.php | Retrieves themes with updates available. |
| wp_theme_update_rows() wp-admin/includes/update.php | Adds a callback to display update information for themes with updates available. |
| wp_theme_update_row() wp-admin/includes/update.php | Displays update information for a theme. |
| wp_check_browser_version() wp-admin/includes/dashboard.php | Checks if the user needs a browser update. |
| install_popular_tags() wp-admin/includes/plugin-install.php | Retrieves popular WordPress plugin tags. |
| install_plugin_install_status() wp-admin/includes/plugin-install.php | Determines the status we can perform on a plugin. |
| delete_plugins() wp-admin/includes/plugin.php | Removes directory and files of a plugin for a list of plugins. |
| wp_get_popular_importers() wp-admin/includes/import.php | Returns a list from WordPress.org of popular importer plugins. |
| wp_credits() wp-admin/includes/credits.php | Retrieve the contributor credits. |
| get_theme_roots() wp-includes/theme.php | Retrieves theme roots. |
| search_theme_directories() wp-includes/theme.php | Searches all registered theme directories for complete and valid themes. |
| _maybe_update_plugins() wp-includes/update.php | Checks the last time plugins were run before checking plugin versions. |
| _maybe_update_themes() wp-includes/update.php | Checks themes versions only after a duration of time. |
| wp_version_check() wp-includes/update.php | Checks WordPress version against the newest version. |
| wp_update_plugins() wp-includes/update.php | Checks for available updates to plugins based on the latest versions hosted on WordPress.org. |
| wp_update_themes() wp-includes/update.php | Checks for available updates to themes based on the latest versions hosted on WordPress.org. |
| wp_get_translation_updates() wp-includes/update.php | Retrieves a list of all language updates available. |
| wp_get_update_data() wp-includes/update.php | Collects counts and UI strings for available updates. |
| _maybe_update_core() wp-includes/update.php | Determines whether core should be updated. |
Changelog
| Version | Description |
|---|---|
| 2.9.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_site_transient