Simplify check to enable chapter list transients

This commit is contained in:
Tetrakern 2024-10-12 20:38:37 +02:00
parent 4b7a1333eb
commit 3a1f0174bb

View File

@ -493,10 +493,12 @@ function fictioneer_story_chapters( $args ) {
return;
}
$cache_plugin_active = fictioneer_caching_active( 'story_chapter_list' );
$enable_transients = FICTIONEER_CHAPTER_LIST_TRANSIENTS &&
! fictioneer_caching_active( 'story_chapter_list' ) &&
! is_customize_preview();
// Check for cached chapters output
if ( FICTIONEER_CHAPTER_LIST_TRANSIENTS && ! $cache_plugin_active && ! is_customize_preview() ) {
if ( $enable_transients ) {
$transient_cache = get_transient( 'fictioneer_story_chapter_list_html' . $args['story_id'] );
if ( $transient_cache ) {
@ -707,7 +709,7 @@ function fictioneer_story_chapters( $args ) {
echo $chapters_html;
// Cache for next time (24 hours)
if ( FICTIONEER_CHAPTER_LIST_TRANSIENTS && ! $cache_plugin_active && ! is_customize_preview() ) {
if ( $enable_transients ) {
set_transient( 'fictioneer_story_chapter_list_html' . $story_id, $chapters_html, 86400 );
}
}