From fa9db75fee43cd571743e75166879d302e206b94 Mon Sep 17 00:00:00 2001 From: Gareth Harris Date: Fri, 9 Oct 2020 11:10:02 +0100 Subject: [PATCH] Update class-gistpress.php Added a couple of filters for transient duration. Many gists are not updated regularly, if at all, so a longer transient duration can be used. --- includes/class-gistpress.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/class-gistpress.php b/includes/class-gistpress.php index c92acba..24c278a 100644 --- a/includes/class-gistpress.php +++ b/includes/class-gistpress.php @@ -359,7 +359,8 @@ public function get_gist_html( $url, array $args ) { if ( empty( $html ) ) { $html = get_transient( $raw_key ); - $transient_expire = DAY_IN_SECONDS; + // Filter the transient expiration duration + $transient_expire = apply_filters( 'gistpress_transient_expire', DAY_IN_SECONDS ); if ( $html && $this->unknown() !== $html ) { $html = $this->process_gist_html( $html, $args ); @@ -394,7 +395,8 @@ public function get_gist_html( $url, array $args ) { $html = $this->process_gist_html( $fallback, $args ); // Cache the fallback for an hour. - $transient_expire = HOUR_IN_SECONDS; + // Allow this value to be filterable + $transient_expire = apply_filters( 'gistpress_transient_expire_fallback', HOUR_IN_SECONDS ); $this->debug_log( __( 'Raw Source: Post Meta Fallback', 'gistpress' ), $shortcode_hash ); $this->debug_log( __( 'Output Source: Processed Raw Source', 'gistpress' ), $shortcode_hash );