Definition:
function set_site_transient( $transient, $value, $expiration = 0 ) {}
Set/update the value of a site transient.
You do not need to serialize values, if the value needs to be serialize, then it will be serialized before it is set.
Parameters
- string $transient: Transient name. Expected to not be SQL-escaped.
- mixed $value: Transient value. Expected to not be SQL-escaped.
- int $expiration: Time until expiration in seconds, default 0
Return values
returns:False if value was not set and true if value was set.
Defined filters
- pre_set_site_transient_$transient
apply_filters( 'pre_set_site_transient_' . $transient, $value )
Defined actions
- set_site_transient_’.$transient
do_action( 'set_site_transient_' . $transient ); - setted_site_transient
do_action( 'setted_site_transient', $transient );
Source code
function set_site_transient( $transient, $value, $expiration = 0 ) {
global $_wp_using_ext_object_cache;
$value = apply_filters( 'pre_set_site_transient_' . $transient, $value );
if ( $_wp_using_ext_object_cache ) {
$result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
} else {
$transient_timeout = '_site_transient_timeout_' . $transient;
$transient = '_site_transient_' . $transient;
if ( false === get_site_option( $transient ) ) {
if ( $expiration )
add_site_option( $transient_timeout, time() + $expiration );
$result = add_site_option( $transient, $value );
} else {
if ( $expiration )
update_site_option( $transient_timeout, time() + $expiration );
$result = update_site_option( $transient, $value );
}
}
if ( $result ) {
do_action( 'set_site_transient_' . $transient );
do_action( 'setted_site_transient', $transient );
}
return $result;
}
2853

February 12, 2011 


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