Loest die YouTube/Vimeo-API-Luecke: viele dienste laden ueber <script> (z. B. youtube.com/iframe_api, www-widgetapi.js, analytics) statt iframes - oft per JavaScript nachgeladen, daher fuer den scanner unsichtbar. - Pro dienst aktivierbar ueber das (umbenannte) feld "Zugehoerige Skripte blockieren (z. B. YouTube-/Vimeo-API)" = das vorhandene loads_script-flag. Presets (YouTube, Vimeo, Maps) haben es bereits an. - Server-seitig: passende <script src> werden zu type="text/plain" (src -> data-cb-src) neutralisiert, laden also nicht. - Client-seitig: winziger guard ganz frueh im <head> patcht appendChild/insertBefore/replaceChild und neutralisiert dynamisch injizierte scripts VOR dem einfuegen -> kein request. Faengt damit auch die per JS nachgeladene iframe_api ab. - Einwilligung (per-dienst-consent, z. B. ueber den video-platzhalter) schaltet die scripts via cbActivateScripts frei und laedt sie nach. - Neuer shortcode [content_blocker_consent id="…"] als einwilligungs-button fuer reine skript-dienste ohne sichtbaren platzhalter. - guard-logik mit DOM-mock getestet (block + reinject), server-regex isoliert geprueft. i18n DE/EN ergaenzt (127 strings). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
67 lines
2.4 KiB
PHP
67 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* 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
|
|
* Author: Lucas Orth
|
|
* Author URI: https://lucas-orth.de
|
|
* Text Domain: gdpr-content-blocker
|
|
* Domain Path: /languages
|
|
* Requires PHP: 8.1
|
|
* Requires at least: 6.0
|
|
* License: GPL-2.0-or-later
|
|
*/
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
define( 'CB_VERSION', '1.3.0' );
|
|
define( 'CB_FILE', __FILE__ );
|
|
define( 'CB_DIR', plugin_dir_path( __FILE__ ) );
|
|
define( 'CB_URL', plugin_dir_url( __FILE__ ) );
|
|
define( 'CB_OPTION', 'cb_services' );
|
|
define( 'CB_STYLE_OPTION', 'cb_style' );
|
|
define( 'CB_LICENSE_OPTION', 'cb_license' );
|
|
|
|
// Product slug used by the license backend (extensible: one slug per plugin).
|
|
define( 'CB_PRODUCT_SLUG', 'gdpr-content-blocker' );
|
|
|
|
// License backend base URL. Override via the cb_license_api_url filter or by
|
|
// defining CB_LICENSE_API_URL in wp-config.php before this file loads.
|
|
if ( ! defined( 'CB_LICENSE_API_URL' ) ) {
|
|
define( 'CB_LICENSE_API_URL', 'https://hub.lucas-orth.de' );
|
|
}
|
|
|
|
require_once CB_DIR . 'includes/class-settings.php';
|
|
require_once CB_DIR . 'includes/class-renderer.php';
|
|
require_once CB_DIR . 'includes/class-autodetect.php';
|
|
require_once CB_DIR . 'includes/class-license.php';
|
|
require_once CB_DIR . 'includes/class-updater.php';
|
|
|
|
// Language policy: German source strings for any German locale (de_*), English
|
|
// for everything else. We map the plugin's locale accordingly and ship an
|
|
// en_US translation. Applies to admin and frontend (filter runs for both).
|
|
add_filter( 'plugin_locale', 'cb_plugin_locale', 10, 2 );
|
|
function cb_plugin_locale( $locale, $domain ) {
|
|
if ( $domain !== 'gdpr-content-blocker' ) {
|
|
return $locale;
|
|
}
|
|
return str_starts_with( (string) $locale, 'de' ) ? 'de_DE' : 'en_US';
|
|
}
|
|
|
|
add_action( 'plugins_loaded', 'cb_init' );
|
|
|
|
function cb_init(): void {
|
|
load_plugin_textdomain( 'gdpr-content-blocker', false, dirname( plugin_basename( CB_FILE ) ) . '/languages' );
|
|
|
|
CB_Settings::init();
|
|
CB_Renderer::init();
|
|
CB_Autodetect::init();
|
|
CB_License::init();
|
|
CB_Updater::init();
|
|
}
|
|
|
|
// Schedule / clear the daily license re-check.
|
|
register_activation_hook( __FILE__, [ 'CB_License', 'on_activation' ] );
|
|
register_deactivation_hook( __FILE__, [ 'CB_License', 'on_deactivation' ] );
|