diff --git a/FILTERS.md b/FILTERS.md index 512dec8b..7ac0676f 100644 --- a/FILTERS.md +++ b/FILTERS.md @@ -1682,7 +1682,7 @@ Filters the WP_Query arguments in the `fictioneer_showcase` shortcode. The optio --- ### `apply_filters( 'fictioneer_filter_enable_shortcode_transients', $bool )` -Filters the boolean return value of the `fictioneer_enable_shortcode_transients()` function. By default, this depends on the `FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION` constant being greater than -1 and the `fictioneer_caching_active()` function returning false. Because the Transients would interfere with caching. If you exclude a page from caching, it might make sense to turn them on for that page. +Filters the boolean return value of the `fictioneer_enable_shortcode_transients()` function. By default, this depends on the `FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION` constant being greater than -1. Because the Transients would interfere with caching. If you exclude a page from caching, it might make sense to turn them on for that page. **Parameter:** * $bool (boolean) – Whether the Transients are enabled or not by default. diff --git a/includes/functions/_service-caching.php b/includes/functions/_service-caching.php index 04472fe5..3eff183f 100644 --- a/includes/functions/_service-caching.php +++ b/includes/functions/_service-caching.php @@ -134,18 +134,22 @@ if ( ! defined( 'FICTIONEER_ENABLE_QUERY_RESULT_CACHING' ) ) { * * @since 5.6.3 * @since 5.23.1 - Do not turn off with cache plugin + * @since 5.25.0 - Refactored with option + * + * @param string $shortcode The shortcode in question. * * @return boolean Either true or false. */ -function fictioneer_enable_shortcode_transients() { +function fictioneer_enable_shortcode_transients( $shortcode = null ) { if ( is_customize_preview() ) { return false; } - $bool = FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION > -1; + $bool = FICTIONEER_SHORTCODE_TRANSIENT_EXPIRATION > -1 && + ! get_option( 'fictioneer_disable_shortcode_transients' ); - return apply_filters( 'fictioneer_filter_enable_shortcode_transients', $bool ); + return apply_filters( 'fictioneer_filter_enable_shortcode_transients', $bool, $shortcode ); } /** diff --git a/includes/functions/_setup-shortcodes.php b/includes/functions/_setup-shortcodes.php index 01fe6ac6..feecfef2 100644 --- a/includes/functions/_setup-shortcodes.php +++ b/includes/functions/_setup-shortcodes.php @@ -1,16 +1,5 @@ 'fictioneer-settings-general-group', 'sanitize_callback' => 'fictioneer_sanitize_checkbox', 'default' => 0 + ), + 'fictioneer_disable_shortcode_transients' => array( + 'name' => 'fictioneer_disable_shortcode_transients', + 'group' => 'fictioneer-settings-general-group', + 'sanitize_callback' => 'fictioneer_sanitize_checkbox', + 'default' => 0 ) ), 'integers' => array( @@ -1204,6 +1210,7 @@ function fictioneer_get_option_label( $option ) { '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' ), + 'fictioneer_disable_shortcode_transients' => __( 'Disable shortcode Transient caching', 'fictioneer' ), ); } diff --git a/includes/functions/settings/_settings_page_general.php b/includes/functions/settings/_settings_page_general.php index 13d6f224..26d9db30 100644 --- a/includes/functions/settings/_settings_page_general.php +++ b/includes/functions/settings/_settings_page_general.php @@ -1381,6 +1381,17 @@ $images = get_template_directory_uri() . '/img/documentation/'; ?> +
+ +
+