fix: leerer elementor-video-platzhalter wenn URL nicht auslesbar (v1.4.1)
Wenn ein Elementor-video per JS gebaut wird und im DOM weder URL noch
Thumbnail steht (nur {"video_type":"youtube"}), konnte mein handler keinen
platzhalter bauen -> Elementor baut nichts (API blockiert) -> leere box.
Fallback: dienst ueber den video_type erkennen und trotzdem einen
einwilligungs-platzhalter zeigen. Da keine embed-URL bekannt ist, gibt dessen
button die einwilligung und laedt die seite neu - danach rendert Elementor das
video normal (scripts sind dann freigegeben). "Einmal laden" entfaellt dort.
+ version 1.4.1 (assets cache-busting fuer die JS-aenderung).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -93,6 +93,15 @@
|
|||||||
|
|
||||||
const wrapper = btn.closest( '.cb-blocker' );
|
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
|
// "Remember" checkbox (default checked): persist consent only when
|
||||||
// ticked; otherwise load this embed once without storing consent.
|
// ticked; otherwise load this embed once without storing consent.
|
||||||
const remember = wrapper
|
const remember = wrapper
|
||||||
@@ -315,19 +324,38 @@
|
|||||||
// catching a rendered iframe) → leave it.
|
// catching a rendered iframe) → leave it.
|
||||||
if ( container.querySelector( '.cb-blocker' ) ) return;
|
if ( container.querySelector( '.cb-blocker' ) ) return;
|
||||||
|
|
||||||
const raw = videoUrlForWidget( widget );
|
const raw = videoUrlForWidget( widget );
|
||||||
if ( ! raw ) return;
|
const embed = raw ? toEmbedUrl( raw ) : '';
|
||||||
|
let svc = raw ? ( findService( raw ) || findService( embed ) ) : null;
|
||||||
|
|
||||||
const embed = toEmbedUrl( raw );
|
// Fallback: no URL in the DOM (Elementor only kept {"video_type":"…"}).
|
||||||
const svc = findService( raw ) || findService( embed );
|
// 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 ( ! svc ) return;
|
||||||
|
|
||||||
if ( hasConsent( svc.id ) ) return; // consented → let Elementor build it
|
if ( hasConsent( svc.id ) ) return; // consented → let Elementor build it
|
||||||
|
|
||||||
// Neutralise Elementor so it won't build the player / load the overlay.
|
// Neutralise Elementor so it won't build the player / load the overlay.
|
||||||
widget.removeAttribute( 'data-settings' );
|
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.innerHTML = '';
|
||||||
container.appendChild( buildPlaceholder( svc, embed, {} ) );
|
container.appendChild( placeholder );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* Plugin Name: GDPR Content Blocker
|
* Plugin Name: GDPR Content Blocker
|
||||||
* Plugin URI: https://lucas-orth.de
|
* Plugin URI: https://lucas-orth.de
|
||||||
* Description: DSGVO-konformer Consent-Blocker für externe iframes. Lädt Drittinhalte erst nach aktiver Einwilligung.
|
* 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: Lucas Orth
|
||||||
* Author URI: https://lucas-orth.de
|
* Author URI: https://lucas-orth.de
|
||||||
* Text Domain: gdpr-content-blocker
|
* Text Domain: gdpr-content-blocker
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
defined( 'ABSPATH' ) || exit;
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
define( 'CB_VERSION', '1.4.0' );
|
define( 'CB_VERSION', '1.4.1' );
|
||||||
define( 'CB_FILE', __FILE__ );
|
define( 'CB_FILE', __FILE__ );
|
||||||
define( 'CB_DIR', plugin_dir_path( __FILE__ ) );
|
define( 'CB_DIR', plugin_dir_path( __FILE__ ) );
|
||||||
define( 'CB_URL', plugin_dir_url( __FILE__ ) );
|
define( 'CB_URL', plugin_dir_url( __FILE__ ) );
|
||||||
|
|||||||
Reference in New Issue
Block a user