Transients, add filters for $expiration
:
* `'expiration_pre_set_site_transient_' . $transient` * `'expiration_pre_set_transient_' . $transient` Props chriscct7, wpsmith, nacin. Fixes #21330. git-svn-id: https://develop.svn.wordpress.org/trunk@34865 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f8b7bba8f6
commit
b054b952bc
@ -695,6 +695,19 @@ function set_transient( $transient, $value, $expiration = 0 ) {
|
|||||||
*/
|
*/
|
||||||
$value = apply_filters( 'pre_set_transient_' . $transient, $value, $expiration, $transient );
|
$value = apply_filters( 'pre_set_transient_' . $transient, $value, $expiration, $transient );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the expiration for a transient before its value is set.
|
||||||
|
*
|
||||||
|
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
|
||||||
|
*
|
||||||
|
* @since 4.4.0
|
||||||
|
*
|
||||||
|
* @param mixed $value New value of transient.
|
||||||
|
* @param int $expiration Time until expiration in seconds.
|
||||||
|
* @param string $transient Transient name.
|
||||||
|
*/
|
||||||
|
$expiration = apply_filters( 'expiration_pre_set_transient_' . $transient, $expiration, $value, $transient );
|
||||||
|
|
||||||
if ( wp_using_ext_object_cache() ) {
|
if ( wp_using_ext_object_cache() ) {
|
||||||
$result = wp_cache_set( $transient, $value, 'transient', $expiration );
|
$result = wp_cache_set( $transient, $value, 'transient', $expiration );
|
||||||
} else {
|
} else {
|
||||||
@ -1589,6 +1602,19 @@ function set_site_transient( $transient, $value, $expiration = 0 ) {
|
|||||||
|
|
||||||
$expiration = (int) $expiration;
|
$expiration = (int) $expiration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the expiration for a transient before its value is set.
|
||||||
|
*
|
||||||
|
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
|
||||||
|
*
|
||||||
|
* @since 4.4.0
|
||||||
|
*
|
||||||
|
* @param mixed $value New value of transient.
|
||||||
|
* @param int $expiration Time until expiration in seconds.
|
||||||
|
* @param string $transient Transient name.
|
||||||
|
*/
|
||||||
|
$expiration = apply_filters( 'expiration_pre_set_site_transient_' . $transient, $expiration, $value, $transient );
|
||||||
|
|
||||||
if ( wp_using_ext_object_cache() ) {
|
if ( wp_using_ext_object_cache() ) {
|
||||||
$result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
|
$result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user