diff --git a/gdpr-content-blocker/assets/frontend.js b/gdpr-content-blocker/assets/frontend.js index e7a6185..dd01202 100644 --- a/gdpr-content-blocker/assets/frontend.js +++ b/gdpr-content-blocker/assets/frontend.js @@ -415,28 +415,35 @@ } if ( ! svc ) return; - if ( hasConsent( svc.id ) ) return; // consented → let Elementor build it - - // Neutralise Elementor so it won't build the player / load the overlay. - widget.removeAttribute( 'data-settings' ); - - // With an embed URL we build the iframe ourselves on consent (reliable, - // independent of Elementor/iframe_api). The iframe gets a responsive - // 16:9 aspect so it loads full-width at its original proportions. - // Without a URL we fall back to reloading so Elementor renders it. - const placeholder = buildPlaceholder( svc, embed, {} ); if ( embed ) { - placeholder.dataset.cbAspect = '16 / 9'; - } else { - placeholder.setAttribute( 'data-cb-reload', '1' ); - const remember = placeholder.querySelector( '.cb-blocker__remember' ); - if ( remember ) remember.remove(); + // We fully manage this widget — independent of Elementor's own JS + // build (which is unreliable and needs the blocked iframe_api). + // This also means it works the same on a fresh load AND after a + // reload when consent is already stored. + widget.removeAttribute( 'data-settings' ); + container.innerHTML = ''; + const placeholder = buildPlaceholder( svc, embed, {} ); + placeholder.dataset.cbAspect = '16 / 9'; // responsive, original proportions + container.appendChild( placeholder ); + if ( hasConsent( svc.id ) ) { + loadContent( placeholder ); // already consented → show the video now + } else { + collapseAncestors( placeholder ); // no whitespace while blocked + } + return; } + // No URL found in the DOM → we can't build the iframe ourselves. Fall + // back to a reload so Elementor renders the player. If already + // consented, leave the widget untouched for Elementor. + if ( hasConsent( svc.id ) ) return; + widget.removeAttribute( 'data-settings' ); container.innerHTML = ''; + const placeholder = buildPlaceholder( svc, embed, {} ); + placeholder.setAttribute( 'data-cb-reload', '1' ); + const remember = placeholder.querySelector( '.cb-blocker__remember' ); + if ( remember ) remember.remove(); container.appendChild( placeholder ); - // Collapse the wrapper's reserved aspect height so there is no - // whitespace while the (small) placeholder is shown. collapseAncestors( placeholder ); } ); } diff --git a/gdpr-content-blocker/gdpr-content-blocker.php b/gdpr-content-blocker/gdpr-content-blocker.php index 8561d9b..7b11713 100644 --- a/gdpr-content-blocker/gdpr-content-blocker.php +++ b/gdpr-content-blocker/gdpr-content-blocker.php @@ -3,7 +3,7 @@ * Plugin Name: GDPR Content Blocker * Plugin URI: https://lucas-orth.de * Description: DSGVO-konformer Consent-Blocker für externe iframes. Lädt Drittinhalte erst nach aktiver Einwilligung. - * Version: 1.4.6 + * Version: 1.4.7 * Author: Lucas Orth * Author URI: https://lucas-orth.de * Text Domain: gdpr-content-blocker @@ -15,7 +15,7 @@ defined( 'ABSPATH' ) || exit; -define( 'CB_VERSION', '1.4.6' ); +define( 'CB_VERSION', '1.4.7' ); define( 'CB_FILE', __FILE__ ); define( 'CB_DIR', plugin_dir_path( __FILE__ ) ); define( 'CB_URL', plugin_dir_url( __FILE__ ) );