Filter testimonials_widget_cache_get and testimonials_widget_cache_set example
add_filter( 'testimonials_widget_cache_get', array( $this, 'cache_get' ) ); | |
add_filter( 'testimonials_widget_cache_set', array( $this, 'cache_set' ), 10, 2 ); | |
public static function cache_get( $args ) { | |
$hash = self::create_hash( $args ); | |
$do_cache = apply_filters( 'testimonials_widget_disable_cache', true ); | |
$no_cache = isset( $args['no_cache'] ) && Testimonials_Widget_Settings::is_true( $args['no_cache'] ); | |
if ( ! $do_cache || $no_cache ) { | |
delete_transient( $hash ); | |
return false; | |
} | |
$data = get_transient( $hash ); | |
return $data; | |
} | |
public static function cache_set( $data, $args ) { | |
$hash = self::create_hash( $args ); | |
set_transient( $hash, $data, self::$cache_period ); | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment