diff --git a/includes/functions/_utility.php b/includes/functions/_utility.php index 82b7c188..98a30bdf 100644 --- a/includes/functions/_utility.php +++ b/includes/functions/_utility.php @@ -3066,12 +3066,13 @@ function fictioneer_get_post_patreon_data( $post = null ) { * @since 5.19.0 * @see get_template_part() * - * @param string $slug The slug name for the generic template. - * @param string|null $name Optional. The name of the specialized template. - * @param array $args Optional. Additional arguments passed to the template. + * @param string $slug The slug name for the generic template. + * @param int|null $expiration Optional. Seconds until the cache expires. Default 24 hours in seconds. + * @param string|null $name Optional. The name of the specialized template. + * @param array $args Optional. Additional arguments passed to the template. */ -function fictioneer_get_static_template_part( $slug, $name = null, $args = [] ) { +function fictioneer_get_static_template_part( $slug, $expiration = null, $name = null, $args = [] ) { // Use default function if... if ( ! get_option( 'fictioneer_enable_static_partials' ) || @@ -3098,7 +3099,7 @@ function fictioneer_get_static_template_part( $slug, $name = null, $args = [] ) if ( file_exists( $path ) ) { $filemtime = filemtime( $path ); - if ( time() - $filemtime < DAY_IN_SECONDS ) { + if ( time() - $filemtime < ( $expiration ?? DAY_IN_SECONDS ) ) { echo file_get_contents( $path ); return; } @@ -3141,7 +3142,7 @@ function fictioneer_clear_cached_html() { $todo = ( $fileinfo->isDir() ? 'rmdir' : 'unlink' ); if ( ! $todo( $fileinfo->getRealPath() ) ) { - error_log( "Failed to delete " . $fileinfo->getRealPath() ); + error_log( 'Failed to delete ' . $fileinfo->getRealPath() ); } } }