diff --git a/gdpr-content-blocker/assets/admin.js b/gdpr-content-blocker/assets/admin.js index c19b9ff..73a3c26 100644 --- a/gdpr-content-blocker/assets/admin.js +++ b/gdpr-content-blocker/assets/admin.js @@ -250,6 +250,40 @@ $out.append( $table ); } + /* ── Local Google Fonts: download & embed ── */ + $( '#cb-fonts-fetch' ).on( 'click', function () { + const i18n = cbAdmin.i18n || {}; + const $btn = $( this ).prop( 'disabled', true ); + const $st = $( '#cb-fonts-status' ).text( i18n.fontsFetching || 'Downloading…' ); + + $.post( cbAdmin.ajaxUrl, { action: 'cb_fonts_fetch', nonce: cbAdmin.fontsNonce } ) + .done( function ( resp ) { + if ( ! resp || ! resp.success ) { + const msg = resp && resp.data && resp.data.message ? resp.data.message : 'Error'; + $st.text( ( i18n.fontsError || 'Error:' ) + ' ' + msg ); + return; + } + $st.text( resp.data.message || 'OK' ); + setTimeout( function () { window.location.reload(); }, 900 ); + } ) + .fail( function ( xhr ) { + $st.text( ( i18n.fontsError || 'Error:' ) + ' ' + xhr.status ); + } ) + .always( function () { + $btn.prop( 'disabled', false ); + } ); + } ); + + $( '#cb-fonts-clear' ).on( 'click', function () { + const i18n = cbAdmin.i18n || {}; + if ( ! window.confirm( i18n.fontsClearConfirm || 'Delete local fonts?' ) ) { + return; + } + $( this ).prop( 'disabled', true ); + $.post( cbAdmin.ajaxUrl, { action: 'cb_fonts_clear', nonce: cbAdmin.fontsNonce } ) + .always( function () { window.location.reload(); } ); + } ); + /* ── Activate a tab by key ── */ function activateTab( tab ) { $( '.cb-tab-content' ).hide(); diff --git a/gdpr-content-blocker/gdpr-content-blocker.php b/gdpr-content-blocker/gdpr-content-blocker.php index f42cba5..016514a 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.2.0 + * Version: 1.3.0 * 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.2.0' ); +define( 'CB_VERSION', '1.3.0' ); define( 'CB_FILE', __FILE__ ); define( 'CB_DIR', plugin_dir_path( __FILE__ ) ); define( 'CB_URL', plugin_dir_url( __FILE__ ) ); @@ -37,6 +37,7 @@ 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'; +require_once CB_DIR . 'includes/class-fonts.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 @@ -59,6 +60,7 @@ function cb_init(): void { CB_Autodetect::init(); CB_License::init(); CB_Updater::init(); + CB_Fonts::init(); } // Schedule / clear the daily license re-check. diff --git a/gdpr-content-blocker/includes/class-fonts.php b/gdpr-content-blocker/includes/class-fonts.php new file mode 100644 index 0000000..77aaf74 --- /dev/null +++ b/gdpr-content-blocker/includes/class-fonts.php @@ -0,0 +1,529 @@ + (also protocol-relative) + * - @import / direct gstatic URLs inside inline