diff --git a/includes/functions/_helpers-templates.php b/includes/functions/_helpers-templates.php index f6ec33a5..208fb12d 100644 --- a/includes/functions/_helpers-templates.php +++ b/includes/functions/_helpers-templates.php @@ -2805,7 +2805,21 @@ function fictioneer_render_skin_interface() {
- + 'fictioneer-skin-translations', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1', + ) + ); + + ?>
diff --git a/includes/functions/_module-schemas.php b/includes/functions/_module-schemas.php index 3e38ceff..f8e57693 100644 --- a/includes/functions/_module-schemas.php +++ b/includes/functions/_module-schemas.php @@ -366,7 +366,17 @@ function fictioneer_output_schemas( $post_id = null ) { // If schema has been found, echo for selected post types if ( $schema ) { - echo $schema ? '' : ''; + wp_print_inline_script_tag( + $schema, + array( + 'id' => 'fictioneer-schema-json', + 'type' => 'application/ld+json', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1' + ) + ); } } diff --git a/includes/functions/_setup-roles.php b/includes/functions/_setup-roles.php index 3e5635fc..fdebb232 100644 --- a/includes/functions/_setup-roles.php +++ b/includes/functions/_setup-roles.php @@ -1282,6 +1282,7 @@ if ( ! current_user_can( 'manage_options' ) ) { * Hide subscriber profile blocks in admin panel * * @since 5.6.0 + * @since 5.26.1 - Use wp_print_inline_script_tag(). */ function fictioneer_remove_profile_blocks() { @@ -1290,9 +1291,17 @@ if ( ! current_user_can( 'manage_options' ) ) { // Remove password options if ( ! get_option( 'fictioneer_show_wp_login_link' ) ) { - echo ''; - - echo ''; + wp_print_inline_script_tag( + 'document.addEventListener("DOMContentLoaded", () => {document.querySelectorAll(".user-pass1-wrap, .user-pass2-wrap, .pw-weak, .user-generate-reset-link-wrap").forEach(element => {element.remove();});});', + array( + 'id' => 'fictioneer-iife-remove-admin-profile-blocks', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1' + ) + ); } } @@ -1511,10 +1520,22 @@ if ( ! current_user_can( 'manage_options' ) ) { * Hide the permalink field with JS * * @since 5.6.2 + * @since 5.26.1 - Use wp_print_inline_script_tag(). + * */ function fictioneer_hide_permalink_with_js() { - echo ''; + wp_print_inline_script_tag( + 'document.querySelectorAll("#edit-slug-buttons").forEach(element => {element.remove();});', + array( + 'id' => 'fictioneer-iife-hide-permalink-in-editor', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1' + ) + ); } if ( ! current_user_can( 'fcn_edit_permalink' ) ) { @@ -1577,10 +1598,21 @@ if ( ! current_user_can( 'manage_options' ) ) { * Inject javascript for the classic editor * * @since 5.6.2 + * @since 5.26.1 - Use wp_print_inline_script_tag(). */ function fictioneer_classic_editor_js_restrictions() { - echo ''; + wp_print_inline_script_tag( + 'document.querySelectorAll(".selectit[for=ping_status], #add-new-comment").forEach(element => {element.remove();});', + array( + 'id' => 'fictioneer-iife-classic-editor-restrictions', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1' + ) + ); } /** diff --git a/includes/functions/_setup-shortcodes.php b/includes/functions/_setup-shortcodes.php index b1432d50..1f977aac 100644 --- a/includes/functions/_setup-shortcodes.php +++ b/includes/functions/_setup-shortcodes.php @@ -370,6 +370,7 @@ function fictioneer_get_shortcode_tax_query( $args ) { * are active since only one is needed. * * @since 5.25.0 + * @since 5.26.1 - Use wp_print_inline_script_tag(). * * @return string The inline script. */ @@ -383,7 +384,18 @@ function fictioneer_get_splide_inline_init() { $done = true; - return ''; + return wp_get_inline_script_tag( + 'document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".splide:not(.no-auto-splide, .is-initialized)").forEach(e=>{e.querySelector(".splide__list")&&"undefined"!=typeof Splide&&(e.classList.remove("_splide-placeholder"),new Splide(e).mount())})});', + array( + 'id' => 'fictioneer-iife-splide', + 'class' => 'temp-script', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1' + ) + ); } // ============================================================================= diff --git a/includes/functions/_setup-theme.php b/includes/functions/_setup-theme.php index 32ec5e4b..57fbcd75 100644 --- a/includes/functions/_setup-theme.php +++ b/includes/functions/_setup-theme.php @@ -1597,11 +1597,22 @@ add_filter( 'customize_refresh_nonces', 'fictioneer_add_customizer_refresh_nonce * Print scripts to the wp-login-php * * @since 5.7.3 + * @since 5.26.1 - Use wp_print_inline_script_tag(). */ function fictioneer_wp_login_scripts() { // Clear web storage in preparation of login - echo ""; + wp_print_inline_script_tag( + 'localStorage.removeItem("fcnUserData"); localStorage.removeItem("fcnAuth");', + array( + 'id' => 'fictioneer-login-scripts', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1' + ) + ); } add_action( 'login_head', 'fictioneer_wp_login_scripts' ); @@ -1801,6 +1812,7 @@ add_action( 'elementor/editor/after_enqueue_scripts', 'fictioneer_output_head_fo * Outputs script to prevent flickering of layout on page load * * @since 5.22.1 + * @since 5.26.1 - Use wp_print_inline_script_tag(). */ function fictioneer_output_head_anti_flicker() { @@ -1809,8 +1821,19 @@ function fictioneer_output_head_anti_flicker() { - {if (document.readyState === "interactive") document.body.style.visibility = "visible";});console.log("foo");', + array( + 'id' => 'fictioneer-anti-flicker', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1' + ) + ); } if ( get_option( 'fictioneer_enable_anti_flicker' ) ) { @@ -1832,12 +1855,21 @@ if ( get_option( 'fictioneer_enable_anti_flicker' ) ) { * * @since 5.0.0 * @since 5.18.1 - No longer pluggable, hooked into wp_head + * @since 5.26.1 - Use wp_print_inline_script_tag(). */ function fictioneer_output_head_critical_scripts() { - // Start HTML ---> ?> - - {switch(e){case"minimal":t.classList.toggle("minimal",s);break;case"taxonomies":t.classList.toggle("no-taxonomies",!s);break;case"darken":a=s>=0?1+s**2:1-s**2,t.style.setProperty("--darken",`(${a} + var(--lightness-offset))`);break;case"saturation":case"font-lightness":case"font-saturation":a=s>=0?1+s**2:1-s**2,t.style.setProperty(`--${e}`,`(${a} + var(--${e}-offset))`);break;case"hue-rotate":a=Number.isInteger(o["hue-rotate"])?o["hue-rotate"]:0,t.style.setProperty("--hue-rotate",`(${a}deg + var(--hue-offset))`);break;default:t.classList.toggle(`no-${e}`,!s)}})),t.dataset.fontWeight=o["font-weight"]?o["font-weight"]:"default",t.dataset.theme=o["site-theme"]&&!t.dataset.forceChildTheme?o["site-theme"]:"default";let e=getComputedStyle(document.documentElement).getPropertyValue("--theme-color-base").trim().split(" ");const s=o.darken?o.darken:0,r=o.saturation?o.saturation:0,n=o["hue-rotate"]?o["hue-rotate"]:0,l=s>=0?1+s**2:1-s**2;o=r>=0?1+r**2:1-r**2,e=`hsl(${(parseInt(e[0])+n)%360}deg ${(parseInt(e[1])*o).toFixed(2)}% ${(parseInt(e[2])*l).toFixed(2)}%)`,document.querySelector("meta[name=theme-color]").setAttribute("content",e)}e&&(t.dataset.mode="true"==e?"light":"dark")}}(),document.documentElement.classList.remove("no-js");', + array( + 'id' => 'fictioneer-critical-scripts', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1' + ) + ); } add_action( 'wp_head', 'fictioneer_output_head_critical_scripts', 9999 ); @@ -1845,12 +1877,21 @@ add_action( 'wp_head', 'fictioneer_output_head_critical_scripts', 9999 ); * Outputs critical skin scripts in the * * @since 5.26.0 + * @since 5.26.1 - Use wp_print_inline_script_tag(). */ function fictioneer_output_critical_skin_scripts() { - // Start HTML ---> ?> - - 'fictioneer-skin-scripts', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1' + ) + ); } if ( get_option( 'fictioneer_enable_css_skins' ) ) { @@ -1987,10 +2028,21 @@ function fictioneer_get_js_translations() { * Outputs JSON with translation into the * * @since 5.12.2 + * @since 5.26.1 - Use wp_print_inline_script_tag(). */ function fictioneer_output_head_translations() { - echo ""; + wp_print_inline_script_tag( + 'const fictioneer_tl = ' . json_encode( fictioneer_get_js_translations() ) . ';', + array( + 'id' => 'fictioneer-translations', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1' + ) + ); } add_action( 'wp_head', 'fictioneer_output_head_translations' ); diff --git a/includes/functions/_setup-wordpress.php b/includes/functions/_setup-wordpress.php index 104117de..47754528 100644 --- a/includes/functions/_setup-wordpress.php +++ b/includes/functions/_setup-wordpress.php @@ -256,18 +256,21 @@ if ( ! function_exists( 'fictioneer_get_logout_url' ) ) { * Make sure local storage is cleared on logout * * @since 5.0.0 + * @since 5.26.1 - Use wp_print_inline_script_tag(). */ function fictioneer_after_logout_cleanup() { - // Start HTML ---> ?> - - 'fictioneer-logout-cleanup', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1', + ) + ); } add_action( 'login_form', 'fictioneer_after_logout_cleanup' ); diff --git a/includes/functions/users/_admin-profile.php b/includes/functions/users/_admin-profile.php index 71d0e920..a2935bda 100644 --- a/includes/functions/users/_admin-profile.php +++ b/includes/functions/users/_admin-profile.php @@ -1295,7 +1295,19 @@ function fictioneer_admin_profile_fields_skins( $profile_user ) { ); ?>

- + 'fictioneer-skin-translations', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1', + ) + ); + ?>
@@ -1368,7 +1380,17 @@ function fictioneer_admin_profile_fields_data_nodes( $profile_user ) { // Clear local bookmarks if ( $success && $success === 'admin-profile-cleared-data-node-bookmarks' ) { - echo ""; + wp_print_inline_script_tag( + 'localStorage.removeItem("fcnChapterBookmarks");', + array( + 'id' => 'fictioneer-iife-clear-bookmarks', + 'type' => 'text/javascript', + 'data-jetpack-boost' => 'ignore', + 'data-no-optimize' => '1', + 'data-no-defer' => '1', + 'data-no-minify' => '1' + ) + ); } // Comment subscriptions?