get_transient( string $transient ): mixed
- Since
- 2.8.0
- Source
wp-includes/option.php:1429
Retrieves the value of a transient.
Description
If the transient does not exist, does not have a value, or has expired, then the return value will be false.
Parameters
$transientstring- Transient name. Expected to not be SQL-escaped.
Return
mixed- Value of transient.
Hooks fired · 2
2 hooks fire while get_transient() runs, in this order:
- apply_filters( pre_transient_{$transient} )filterline 1447 (+18 into the body)
Filters the value of an existing transient before it is retrieved.
- apply_filters( transient_{$transient} )filterline 1489 (+60 into the body)
Filters an existing transient's value.
Uses · 8
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_using_ext_object_cache()Toggles `$_wp_using_ext_object_cache` on and off without directly touching global.
- wp_installing()Checks or sets whether WordPress is in "installation" mode.
- wp_cache_get()Retrieves the cache contents from the cache by key and group.
- wp_load_alloptions()Loads and caches all autoloaded options, if available or all options.
- wp_prime_option_caches()Primes specific options into the cache with a single database query.
- get_option()Retrieves an option value based on an option name.
- delete_option()Removes an option by name. Prevents removal of protected WordPress options.
Used by · 23
- Featured_Content::get_featured_post_ids()Gets featured post IDs.
- RSSCache::check_cache()
- RSSCache::get()
- WP_Site_Health::enqueue_scripts()Enqueues the site health scripts.
- WP_oEmbed_Controller::get_proxy_item()Callback for the proxy API endpoint.
- clean_dirsize_cache()Cleans directory size cache used by recurse_dirsize().
- get_settings_errors()Fetches settings errors registered by add_settings_error().
- install_themes_feature_list()Retrieves the list of WordPress theme features (aka theme tags).
- is_multi_author()Determines whether this site has more than one author.
- recurse_dirsize()Gets the size of a directory recursively.
- register_core_block_style_handles()Registers core block style handles.
- spawn_cron()Sends a request to run cron through HTTP request that doesn't halt page loading.
Show all 23
- twentyfifteen_categorized_blog()Determines whether blog/site has more than one category.
- twentyfourteen_categorized_blog()Finds out if blog has more than one category.
- twentyseventeen_categorized_blog()Returns true if a blog has more than 1 category.
- twentysixteen_categorized_blog()Determines whether blog/site has more than one category.
- wp_add_global_styles_for_blocks()Adds global style rules to the inline style for each block.
- wp_dashboard_cached_rss_widget()Checks to see if all of the feed url in $check_urls are cached.
- wp_dashboard_plugins_output()Display plugins text for the WordPress news widget.
- wp_dashboard_site_health()Displays the Site Health Status widget.
- wp_maybe_generate_attachment_metadata()Maybe attempts to generate attachment metadata, if missing.
- wp_rand()Generates a random non-negative number.
- wp_start_scraping_edited_file_errors()Starts scraping edited file errors.
Source
function get_transient( $transient ) { /** * Filters the value of an existing transient before it is retrieved. * * The dynamic portion of the hook name, `$transient`, refers to the transient name. * * Returning a value other than false from the filter will short-circuit retrieval * and return that value instead. * * @since 2.8.0 * @since 4.4.0 The `$transient` parameter was added * * @param mixed $pre_transient The default value to return if the 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_transient_{$transient}", false, $transient ); if ( false !== $pre ) { return $pre; } if ( wp_using_ext_object_cache() || wp_installing() ) { $value = wp_cache_get( $transient, 'transient' ); } else { $transient_option = '_transient_' . $transient; if ( ! wp_installing() ) { // If option is not in alloptions, it is not autoloaded and thus has a timeout. $alloptions = wp_load_alloptions(); if ( ! isset( $alloptions[ $transient_option ] ) ) { $transient_timeout = '_transient_timeout_' . $transient; wp_prime_option_caches( array( $transient_option, $transient_timeout ) ); $timeout = get_option( $transient_timeout ); if ( false !== $timeout && $timeout < time() ) { delete_option( $transient_option ); delete_option( $transient_timeout ); $value = false; } } } if ( ! isset( $value ) ) { $value = get_option( $transient_option ); } } /** * Filters an existing transient's value. * * The dynamic portion of the hook name, `$transient`, refers to the transient name. * * @since 2.8.0 * @since 4.4.0 The `$transient` parameter was added * * @param mixed $value Value of transient. * @param string $transient Transient name. */ return apply_filters( "transient_{$transient}", $value, $transient );}History
Introduced in 2.8.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/option.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.