Apply static caching to selected partials

This commit is contained in:
Tetrakern 2024-05-17 21:26:45 +02:00
parent 2cfe230c3a
commit 1210c2089f
7 changed files with 26 additions and 11 deletions

View File

@ -63,12 +63,12 @@ do_action( 'fictioneer_after_main', $args );
$args['post_type'] == 'fcn_chapter' &&
! post_password_required()
) {
get_template_part( 'partials/_tts-interface' );
fictioneer_get_static_template_part( 'partials/_tts-interface' );
}
// Render cookie banner HTML if required
if ( get_option( 'fictioneer_cookie_banner' ) ) {
get_template_part( 'partials/_consent-banner' );
fictioneer_get_static_template_part( 'partials/_consent-banner' );
}
?>

View File

@ -23,6 +23,9 @@ function fictioneer_watch_for_customizer_updates() {
// Rebuild dynamic scripts
fictioneer_build_dynamic_scripts();
// Clear cached HTML
fictioneer_clear_cached_html();
// Files
$bundled_fonts = WP_CONTENT_DIR . '/themes/fictioneer/cache/bundled-fonts.css';

View File

@ -3063,7 +3063,7 @@ function fictioneer_get_post_patreon_data( $post = null ) {
/**
* Get template part from static cache if available
*
* @since 5.19.0
* @since 5.18.1
* @see get_template_part()
*
* @param string $slug The slug name for the generic template.
@ -3125,7 +3125,7 @@ function fictioneer_get_static_template_part( $slug, $expiration = null, $name =
* Note: Only executed once per request to reduce overhead.
* Can therefore be used with impunity.
*
* @since 5.19.0
* @since 5.18.1
*/
function fictioneer_clear_cached_html() {

View File

@ -137,10 +137,10 @@ function fictioneer_output_modals( $args ) {
// Formatting and suggestions
if ( ! $is_archive && $args['post_type'] == 'fcn_chapter' ) {
?><input id="modal-formatting-toggle" data-target="formatting-modal" type="checkbox" tabindex="-1" class="modal-toggle" autocomplete="off" hidden><?php
get_template_part( 'partials/_modal-formatting' );
fictioneer_get_static_template_part( 'partials/_modal-formatting' );
?><input id="modal-tts-settings-toggle" data-target="tts-settings-modal" type="checkbox" tabindex="-1" class="modal-toggle" autocomplete="off" hidden><?php
get_template_part( 'partials/_modal-tts-settings' );
fictioneer_get_static_template_part( 'partials/_modal-tts-settings' );
if (
get_option( 'fictioneer_enable_suggestions' ) &&
@ -148,7 +148,7 @@ function fictioneer_output_modals( $args ) {
comments_open()
) {
?><input id="suggestions-modal-toggle" data-target="suggestions-modal" type="checkbox" tabindex="-1" class="modal-toggle" autocomplete="off" hidden><?php
get_template_part( 'partials/_modal-suggestions' );
fictioneer_get_static_template_part( 'partials/_modal-suggestions' );
}
}
@ -164,7 +164,7 @@ function fictioneer_output_modals( $args ) {
// Site settings
?><input id="modal-site-settings-toggle" data-target="site-settings-modal" type="checkbox" tabindex="-1" class="modal-toggle" autocomplete="off" hidden><?php
get_template_part( 'partials/_modal-site-settings' );
fictioneer_get_static_template_part( 'partials/_modal-site-settings' );
// BBCodes tutorial
if (
@ -174,7 +174,7 @@ function fictioneer_output_modals( $args ) {
! fictioneer_is_commenting_disabled( $args['post_id'] )
) {
?><input id="modal-bbcodes-toggle" data-target="bbcodes-modal" type="checkbox" tabindex="-1" class="modal-toggle" autocomplete="off" hidden><?php
get_template_part( 'partials/_modal-bbcodes' );
fictioneer_get_static_template_part( 'partials/_modal-bbcodes' );
}
// Story chapter changelog

View File

@ -192,7 +192,7 @@ if ( get_option( 'fictioneer_enable_follows' ) ) {
*/
function fictioneer_mobile_bookmarks_frame() {
get_template_part( 'partials/_template_mobile_bookmark' );
fictioneer_get_static_template_part( 'partials/_template_mobile_bookmark' );
// Start HTML ---> ?>
<div class="mobile-menu__frame" data-frame="bookmarks">

View File

@ -170,6 +170,9 @@ function fictioneer_settings_checkbox_added( $option, $value ) {
return;
}
// Clear cached files
fictioneer_clear_cached_html();
// Relay
fictioneer_log_checkbox_update(
fictioneer_get_option_label( $option ),
@ -195,6 +198,9 @@ function fictioneer_settings_checkbox_updated( $option, $old_value, $value ) {
return;
}
// Clear cached files
fictioneer_clear_cached_html();
// Relay
fictioneer_log_checkbox_update(
fictioneer_get_option_label( $option ),
@ -365,6 +371,9 @@ function fictioneer_settings_phrase_added( $option, $value ) {
return;
}
// Clear cached files
fictioneer_clear_cached_html();
// Relay
fictioneer_log_phrase_update(
fictioneer_get_option_label( $option ),
@ -390,6 +399,9 @@ function fictioneer_settings_phrase_updated( $option, $old_value, $value ) {
return;
}
// Clear cached files
fictioneer_clear_cached_html();
// Replay
fictioneer_log_phrase_update(
fictioneer_get_option_label( $option ),

View File

@ -22,7 +22,7 @@ defined( 'ABSPATH' ) OR exit;
$show_empty = isset( $args['show_empty'] ) && $args['show_empty'];
$count = isset( $args['count'] ) ? intval( $args['count'] ) : -1;
get_template_part( 'partials/_template_bookmark', null, $args );
fictioneer_get_static_template_part( 'partials/_template_bookmark', null, null, $args );
?>