Advertisements

get_transient

Definition:
function get_transient( $transient ) {}

Get the value of a 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_transient_$transient
    apply_filters( 'pre_transient_' . $transient, false )
  • transient_$transient
    apply_filters( 'transient_' . $transient, $value )

Source code

function get_transient( $transient ) {

	global $_wp_using_ext_object_cache;



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

	if ( false !== $pre )

		return $pre;



	if ( $_wp_using_ext_object_cache ) {

		$value = wp_cache_get( $transient, 'transient' );

	} else {

		$transient_option = '_transient_' . $transient;

		if ( ! defined( '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;

				if ( get_option( $transient_timeout ) < time() ) {

					delete_option( $transient_option  );

					delete_option( $transient_timeout );

					return false;

				}

			}

		}



		$value = get_option( $transient_option );

	}



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

}

1867

Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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: