diff --git a/gdpr-content-blocker/assets/frontend.js b/gdpr-content-blocker/assets/frontend.js index adfec5d..9d33272 100644 --- a/gdpr-content-blocker/assets/frontend.js +++ b/gdpr-content-blocker/assets/frontend.js @@ -93,6 +93,15 @@ const wrapper = btn.closest( '.cb-blocker' ); + // Placeholder without its own embed URL (e.g. an Elementor widget we + // couldn't read the URL from): persist consent and reload so the + // original embed renders normally. + if ( wrapper && wrapper.getAttribute( 'data-cb-reload' ) === '1' ) { + grantConsent( serviceId ); + window.location.reload(); + return; + } + // "Remember" checkbox (default checked): persist consent only when // ticked; otherwise load this embed once without storing consent. const remember = wrapper @@ -315,19 +324,38 @@ // catching a rendered iframe) → leave it. if ( container.querySelector( '.cb-blocker' ) ) return; - const raw = videoUrlForWidget( widget ); - if ( ! raw ) return; + const raw = videoUrlForWidget( widget ); + const embed = raw ? toEmbedUrl( raw ) : ''; + let svc = raw ? ( findService( raw ) || findService( embed ) ) : null; - const embed = toEmbedUrl( raw ); - const svc = findService( raw ) || findService( embed ); + // Fallback: no URL in the DOM (Elementor only kept {"video_type":"…"}). + // Identify the service by the video type so we can still show consent. + if ( ! svc ) { + const vt = ( widget.getAttribute( 'data-settings' ) || '' ) + .match( /"video_type"\s*:\s*"(youtube|vimeo|dailymotion)"/i ); + if ( vt ) { + svc = findService( vt[ 1 ] + '.com' ); + } + } 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' ); + const placeholder = buildPlaceholder( svc, embed, {} ); + + // No embed URL → we can't build the iframe ourselves. Make the button + // grant consent and reload; Elementor then renders the video normally + // (scripts are released after consent). Drop the "load once" option. + if ( ! embed ) { + placeholder.setAttribute( 'data-cb-reload', '1' ); + const remember = placeholder.querySelector( '.cb-blocker__remember' ); + if ( remember ) remember.remove(); + } + container.innerHTML = ''; - container.appendChild( buildPlaceholder( svc, embed, {} ) ); + container.appendChild( placeholder ); } ); } diff --git a/gdpr-content-blocker/gdpr-content-blocker.php b/gdpr-content-blocker/gdpr-content-blocker.php index bd3277d..b96b392 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.0 + * Version: 1.4.1 * 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.0' ); +define( 'CB_VERSION', '1.4.1' ); define( 'CB_FILE', __FILE__ ); define( 'CB_DIR', plugin_dir_path( __FILE__ ) ); define( 'CB_URL', plugin_dir_url( __FILE__ ) );