From ae50532c0f8ed5b4f8b4e31100e69f58327747b9 Mon Sep 17 00:00:00 2001 From: Brian DiChiara Date: Mon, 13 Jan 2025 12:59:27 -0600 Subject: [PATCH] [N/A] Fix an issue when embedding GTM --- .../src/classes/Admin/CustomScripts.php | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/wp-content/mu-plugins/viget-wp/src/classes/Admin/CustomScripts.php b/wp-content/mu-plugins/viget-wp/src/classes/Admin/CustomScripts.php index 79d7f842..ef303d79 100644 --- a/wp-content/mu-plugins/viget-wp/src/classes/Admin/CustomScripts.php +++ b/wp-content/mu-plugins/viget-wp/src/classes/Admin/CustomScripts.php @@ -190,27 +190,37 @@ function() { $scripts = ! empty( $_POST[ self::OPTION_NAME ] ) ? $_POST[ self::OPTION_NAME ] : $this->scripts; $allowed = [ - 'script' => [ - 'type' => [], - 'src' => [], + 'script' => [ + 'type' => [], + 'src' => [], 'async' => [], 'defer' => [], ], 'noscript' => [], - 'iframe' => [ - 'src' => [], - 'width' => [], + 'iframe' => [ + 'src' => [], + 'width' => [], 'height' => [], - 'style' => [], + 'style' => [], ], - '#text' => [], // Allow inline script content + '#text' => [], // Allow inline script content ]; + $style_filter = function( array $styles ): array { + $styles[] = 'display'; + $styles[] = 'visibility'; + return $styles; + }; + + add_filter( 'safe_style_css', $style_filter ); + foreach ( $scripts as $key => $script ) { $script = wp_kses( wp_unslash( $script ), $allowed ); $scripts[ $key ] = html_entity_decode( $script, ENT_QUOTES | ENT_HTML5 ); } + remove_filter( 'safe_style_css', $style_filter ); + update_option( self::OPTION_NAME, $scripts ); $this->scripts = $scripts;