get_site_transient

Definition:
function get_site_transient( $transient ) {}

Get the value of a site transient.
If the transient does not exist or does not have a value, then the return value will be false.

Parameters

  • string $transient: Transient name. Expected to not be SQL-escaped.

Return values

returns:Value of transient

Defined filters

  • pre_site_transient_$transient
    apply_filters( 'pre_site_transient_' . $transient, false )
  • site_transient_$transient
    apply_filters( 'site_transient_' . $transient, $value )

Source code

function get_site_transient( $transient ) {

	global $_wp_using_ext_object_cache;



	$pre = apply_filters( 'pre_site_transient_' . $transient, false );

	if ( false !== $pre )

		return $pre;



	if ( $_wp_using_ext_object_cache ) {

		$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 ) ) {

			$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 );

				return false;

			}

		}



		$value = get_site_option( $transient_option );

	}



	return apply_filters( 'site_transient_' . $transient, $value );

}

1699

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: