Add option to disable chapter list Transients
This commit is contained in:
parent
36ed7e0b32
commit
ceafc06a54
@ -126,11 +126,11 @@ if ( ! defined( 'FICTIONEER_ENABLE_QUERY_RESULT_CACHING' ) ) {
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// ENABLE SHORTCODE TRANSIENTS?
|
||||
// ENABLE TRANSIENTS?
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Return whether shortcode Transients should be enabled
|
||||
* Whether to enable Transients for shortcodes
|
||||
*
|
||||
* @since 5.6.3
|
||||
* @since 5.23.1 - Do not turn off with cache plugin
|
||||
@ -139,19 +139,38 @@ if ( ! defined( 'FICTIONEER_ENABLE_QUERY_RESULT_CACHING' ) ) {
|
||||
*/
|
||||
|
||||
function fictioneer_enable_shortcode_transients() {
|
||||
// Disable in Customizer
|
||||
if ( is_customize_preview() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check constant
|
||||
$bool = FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION > -1;
|
||||
|
||||
// Filter
|
||||
$bool = apply_filters( 'fictioneer_filter_enable_shortcode_transients', $bool );
|
||||
return apply_filters( 'fictioneer_filter_enable_shortcode_transients', $bool );
|
||||
}
|
||||
|
||||
// Return
|
||||
return $bool;
|
||||
/**
|
||||
* Whether to enable Transients for story chapter lists
|
||||
*
|
||||
* Note: By default true unless there is a known cache plugin
|
||||
* active or the Transients are turned off by option. They are
|
||||
* always disabled in the Customizer preview.
|
||||
*
|
||||
* @since 5.25.0
|
||||
*
|
||||
* @param int $post_id Post ID of the story.
|
||||
*
|
||||
* @return boolean Either true or false.
|
||||
*/
|
||||
|
||||
function fictioneer_enable_chapter_list_transients( $post_id ) {
|
||||
if ( is_customize_preview() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$bool = ! fictioneer_caching_active( 'story_chapter_list' ) &&
|
||||
! get_option( 'fictioneer_disable_chapter_list_transients' );
|
||||
|
||||
return apply_filters( 'fictioneer_filter_enable_chapter_list_transients', $bool, $post_id );
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
@ -493,9 +493,7 @@ function fictioneer_story_chapters( $args ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$enable_transients = FICTIONEER_CHAPTER_LIST_TRANSIENTS &&
|
||||
! fictioneer_caching_active( 'story_chapter_list' ) &&
|
||||
! is_customize_preview();
|
||||
$enable_transients = fictioneer_enable_chapter_list_transients( $args['story_id'] );
|
||||
|
||||
// Check for cached chapters output
|
||||
if ( $enable_transients ) {
|
||||
|
@ -725,6 +725,12 @@ define( 'FICTIONEER_OPTIONS', array(
|
||||
'group' => 'fictioneer-settings-general-group',
|
||||
'sanitize_callback' => 'fictioneer_sanitize_checkbox',
|
||||
'default' => 0
|
||||
),
|
||||
'fictioneer_disable_chapter_list_transients' => array(
|
||||
'name' => 'fictioneer_disable_chapter_list_transients',
|
||||
'group' => 'fictioneer-settings-general-group',
|
||||
'sanitize_callback' => 'fictioneer_sanitize_checkbox',
|
||||
'default' => 0
|
||||
)
|
||||
),
|
||||
'integers' => array(
|
||||
@ -1197,6 +1203,7 @@ function fictioneer_get_option_label( $option ) {
|
||||
'fictioneer_disable_menu_transients' => __( 'Disable menu Transient caching', 'fictioneer' ),
|
||||
'fictioneer_enable_line_break_fix' => __( 'Enable fixing of chapter paragraphs', 'fictioneer' ),
|
||||
'fictioneer_show_story_modified_date' => __( 'Show the modified date on story pages', 'fictioneer' ),
|
||||
'fictioneer_disable_chapter_list_transients' => __( 'Disable chapter list Transient caching', 'fictioneer' ),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1377,6 +1377,16 @@ $images = get_template_directory_uri() . '/img/documentation/';
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="fictioneer-card__row">
|
||||
<?php
|
||||
fictioneer_settings_label_checkbox(
|
||||
'fictioneer_disable_chapter_list_transients',
|
||||
__( 'Disable chapter list Transient caching', 'fictioneer' ),
|
||||
__( 'Only do if you encounter problems.', 'fictioneer' )
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="fictioneer-card__row">
|
||||
<?php
|
||||
fictioneer_settings_label_checkbox(
|
||||
|
Loading…
x
Reference in New Issue
Block a user