From 29ee06e8fd5bb519f61d7347d0aa5146aab5f895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Tue, 20 Jan 2026 09:19:26 -0300 Subject: [PATCH 1/2] replace hardcoded script tags with core api --- .../scripts/cb_frame/cookiebot-js.php | 68 ++++++++++--------- .../scripts/common/google-consent-mode-js.php | 12 +++- .../scripts/common/google-tag-manager-js.php | 14 +++- 3 files changed, 57 insertions(+), 37 deletions(-) diff --git a/src/view/frontend/scripts/cb_frame/cookiebot-js.php b/src/view/frontend/scripts/cb_frame/cookiebot-js.php index a42cd3d0..9a4b91e6 100644 --- a/src/view/frontend/scripts/cb_frame/cookiebot-js.php +++ b/src/view/frontend/scripts/cb_frame/cookiebot-js.php @@ -7,37 +7,39 @@ * @var array $data_regions * @var string|bool $tcf */ -?> - + $script_attributes['data-georegions'] = implode( ',', $georegions ); +} + +if ( (bool) get_option( 'cookiebot-gtm' ) !== false && ! empty( get_option( 'cookiebot-data-layer' ) ) ) { + $script_attributes['data-layer-name'] = get_option( 'cookiebot-data-layer' ); +} + +if ( ! empty( $lang ) ) { + $script_attributes['data-culture'] = strtoupper( $lang ); +} + +if ( $cookie_blocking_mode === 'auto' ) { + $script_attributes['data-blockingmode'] = 'auto'; +} elseif ( ! empty( $tag_attr ) ) { + $script_attributes[ $tag_attr ] = true; +} + +wp_print_script_tag( $script_attributes ); diff --git a/src/view/frontend/scripts/common/google-consent-mode-js.php b/src/view/frontend/scripts/common/google-consent-mode-js.php index abb2f845..f646449b 100644 --- a/src/view/frontend/scripts/common/google-consent-mode-js.php +++ b/src/view/frontend/scripts/common/google-consent-mode-js.php @@ -6,8 +6,15 @@ * @var string $script_type */ +$script_attributes = array( + 'type' => $script_type, +); +if ($consent_attribute) { + $script_attributes['data-cookieconsent'] = $consent_attribute; +} + +ob_start(); ?> - + + \ No newline at end of file diff --git a/src/view/frontend/scripts/common/google-tag-manager-js.php b/src/view/frontend/scripts/common/google-tag-manager-js.php index 671c1869..c73346e5 100644 --- a/src/view/frontend/scripts/common/google-tag-manager-js.php +++ b/src/view/frontend/scripts/common/google-tag-manager-js.php @@ -6,8 +6,16 @@ * @var string $script_type * @var bool $iab */ + +$script_attributes = array( + 'type' => $script_type, +); +if ($consent_attribute) { + $attributes['data-cookieconsent'] = $consent_attribute; +} + +ob_start(); ?> - + + From 94ef5cf8834e627e547a670fb6d259579a429b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Sch=C3=B6ldstr=C3=B6m?= Date: Tue, 20 Jan 2026 10:41:48 -0300 Subject: [PATCH 2/2] fix invalid variable reference --- src/view/frontend/scripts/common/google-tag-manager-js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/frontend/scripts/common/google-tag-manager-js.php b/src/view/frontend/scripts/common/google-tag-manager-js.php index c73346e5..88ea1604 100644 --- a/src/view/frontend/scripts/common/google-tag-manager-js.php +++ b/src/view/frontend/scripts/common/google-tag-manager-js.php @@ -11,7 +11,7 @@ 'type' => $script_type, ); if ($consent_attribute) { - $attributes['data-cookieconsent'] = $consent_attribute; + $script_attributes['data-cookieconsent'] = $consent_attribute; } ob_start();