feat: kein interner-name-feld mehr - ID automatisch aus anbietername
- Dienst-Zeile zeigt/erfordert nur noch den Anbietername. - Interne ID wird beim Speichern aus dem Namen abgeleitet (sanitize_title), bestehende IDs bleiben via Hidden-Field stabil; Eindeutigkeit erzwungen. - Shortcode-Hilfe erklaert: ID = Anbietername in Kleinbuchstaben mit Bindestrichen. - EN-Uebersetzung (120) aktualisiert. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -11,15 +11,13 @@
|
|||||||
$( '.cb-color-picker', ctx ).wpColorPicker();
|
$( '.cb-color-picker', ctx ).wpColorPicker();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Live header update: "interner-name — Anbietername" ── */
|
/* ── Live header update: provider name ── */
|
||||||
function syncTitle( box ) {
|
function syncTitle( box ) {
|
||||||
const id = ( $( '.cb-input-id', box ).val() || '' ).trim();
|
|
||||||
const name = ( $( '.cb-input-name', box ).val() || '' ).trim();
|
const name = ( $( '.cb-input-name', box ).val() || '' ).trim();
|
||||||
const head = ( id || ( cbAdmin.newServiceLbl || 'neu' ) ) + ( name ? ' — ' + name : '' );
|
$( '.cb-service-title', box ).first().text( name || ( cbAdmin.newServiceLbl || 'Neuer Dienst' ) );
|
||||||
$( '.cb-service-title', box ).first().text( head );
|
|
||||||
}
|
}
|
||||||
function bindNameSync( box ) {
|
function bindNameSync( box ) {
|
||||||
$( '.cb-input-name, .cb-input-id', box ).on( 'input', function () {
|
$( '.cb-input-name', box ).on( 'input', function () {
|
||||||
syncTitle( box );
|
syncTitle( box );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
@@ -239,7 +237,7 @@
|
|||||||
const $box = addServiceRow( data );
|
const $box = addServiceRow( data );
|
||||||
if ( $box && $box.length ) {
|
if ( $box && $box.length ) {
|
||||||
$box[ 0 ].scrollIntoView( { behavior: 'smooth', block: 'center' } );
|
$box[ 0 ].scrollIntoView( { behavior: 'smooth', block: 'center' } );
|
||||||
$box.find( '.cb-input-id' ).trigger( 'focus' );
|
$box.find( '.cb-input-name' ).trigger( 'focus' );
|
||||||
}
|
}
|
||||||
} )
|
} )
|
||||||
.appendTo( $act );
|
.appendTo( $act );
|
||||||
|
|||||||
@@ -104,17 +104,36 @@ class CB_Settings {
|
|||||||
: [];
|
: [];
|
||||||
|
|
||||||
$services = [];
|
$services = [];
|
||||||
|
$used_ids = [];
|
||||||
foreach ( $raw_services as $item ) {
|
foreach ( $raw_services as $item ) {
|
||||||
if ( ! is_array( $item ) ) {
|
if ( ! is_array( $item ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$name = sanitize_text_field( $item['name'] ?? '' );
|
||||||
|
if ( $name === '' ) {
|
||||||
|
continue; // a service needs at least a provider name
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep the existing id stable (hidden field); derive from the name
|
||||||
|
// for new services. Ensure uniqueness.
|
||||||
$id = sanitize_key( $item['id'] ?? '' );
|
$id = sanitize_key( $item['id'] ?? '' );
|
||||||
if ( $id === '' ) {
|
if ( $id === '' ) {
|
||||||
continue;
|
$id = sanitize_title( $name );
|
||||||
}
|
}
|
||||||
|
if ( $id === '' ) {
|
||||||
|
$id = 'dienst';
|
||||||
|
}
|
||||||
|
$base_id = $id;
|
||||||
|
$n = 2;
|
||||||
|
while ( in_array( $id, $used_ids, true ) ) {
|
||||||
|
$id = $base_id . '-' . $n;
|
||||||
|
$n++;
|
||||||
|
}
|
||||||
|
$used_ids[] = $id;
|
||||||
|
|
||||||
$services[] = [
|
$services[] = [
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'name' => sanitize_text_field( $item['name'] ?? '' ),
|
'name' => $name,
|
||||||
'enabled' => ! empty( $item['enabled'] ),
|
'enabled' => ! empty( $item['enabled'] ),
|
||||||
'match_pattern' => sanitize_text_field( $item['match_pattern'] ?? '' ),
|
'match_pattern' => sanitize_text_field( $item['match_pattern'] ?? '' ),
|
||||||
'recipient' => sanitize_text_field( $item['recipient'] ?? '' ),
|
'recipient' => sanitize_text_field( $item['recipient'] ?? '' ),
|
||||||
@@ -530,8 +549,8 @@ class CB_Settings {
|
|||||||
$name = $svc['name'] ?? '';
|
$name = $svc['name'] ?? '';
|
||||||
$id = $svc['id'] ?? '';
|
$id = $svc['id'] ?? '';
|
||||||
$enabled = $svc['enabled'] ?? true; // default ON (new + legacy services)
|
$enabled = $svc['enabled'] ?? true; // default ON (new + legacy services)
|
||||||
// Header label: "interner-name — Anbietername"
|
// Header shows just the provider name (internal id is auto-derived).
|
||||||
$headname = trim( ( $id !== '' ? $id : __( 'neu', 'gdpr-content-blocker' ) ) . ( $name !== '' ? ' — ' . $name : '' ) );
|
$headname = $name !== '' ? $name : __( 'Neuer Dienst', 'gdpr-content-blocker' );
|
||||||
?>
|
?>
|
||||||
<div class="cb-service-box" data-cb-index="<?php echo $idx; ?>">
|
<div class="cb-service-box" data-cb-index="<?php echo $idx; ?>">
|
||||||
<div class="cb-service-head">
|
<div class="cb-service-head">
|
||||||
@@ -548,13 +567,10 @@ class CB_Settings {
|
|||||||
<span class="dashicons dashicons-trash"></span>
|
<span class="dashicons dashicons-trash"></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<?php // Internal id is kept stable for existing services and auto-derived
|
||||||
|
// from the name for new ones (no separate field). ?>
|
||||||
|
<input type="hidden" class="cb-input-id" name="cb_services[<?php echo $idx; ?>][id]" value="<?php echo $f( 'id' ); ?>">
|
||||||
<div class="cb-service-grid" style="display:none;">
|
<div class="cb-service-grid" style="display:none;">
|
||||||
<div class="cb-field">
|
|
||||||
<label><?php esc_html_e( 'Interner Name (Slug)', 'gdpr-content-blocker' ); ?> *</label>
|
|
||||||
<input type="text" name="cb_services[<?php echo $idx; ?>][id]"
|
|
||||||
value="<?php echo $f( 'id' ); ?>" required
|
|
||||||
placeholder="google-maps" pattern="[a-z0-9\-]+" class="cb-input-id">
|
|
||||||
</div>
|
|
||||||
<div class="cb-field">
|
<div class="cb-field">
|
||||||
<label><?php esc_html_e( 'Anbietername', 'gdpr-content-blocker' ); ?> *</label>
|
<label><?php esc_html_e( 'Anbietername', 'gdpr-content-blocker' ); ?> *</label>
|
||||||
<input type="text" name="cb_services[<?php echo $idx; ?>][name]"
|
<input type="text" name="cb_services[<?php echo $idx; ?>][name]"
|
||||||
@@ -650,7 +666,7 @@ class CB_Settings {
|
|||||||
<tr>
|
<tr>
|
||||||
<td style="vertical-align:top;"><strong><?php esc_html_e( 'Inhalt manuell blockieren', 'gdpr-content-blocker' ); ?></strong><br>
|
<td style="vertical-align:top;"><strong><?php esc_html_e( 'Inhalt manuell blockieren', 'gdpr-content-blocker' ); ?></strong><br>
|
||||||
<?php echo $code( '[content_blocker id="google-maps"]…iframe…[/content_blocker]' ); ?></td>
|
<?php echo $code( '[content_blocker id="google-maps"]…iframe…[/content_blocker]' ); ?></td>
|
||||||
<td><?php esc_html_e( 'Umschließt ein iframe und ersetzt es durch den Platzhalter des angegebenen Dienstes. Verwenden Sie den internen Namen aus dem Tab „Dienste".', 'gdpr-content-blocker' ); ?></td>
|
<td><?php esc_html_e( 'Umschließt ein iframe und ersetzt es durch den Platzhalter des angegebenen Dienstes. Die ID ist der Anbietername in Kleinbuchstaben mit Bindestrichen (z. B. „Google Maps" → google-maps).', 'gdpr-content-blocker' ); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="vertical-align:top;"><strong><?php esc_html_e( 'Dienste-Übersicht (Datenschutzerklärung)', 'gdpr-content-blocker' ); ?></strong><br>
|
<td style="vertical-align:top;"><strong><?php esc_html_e( 'Dienste-Übersicht (Datenschutzerklärung)', 'gdpr-content-blocker' ); ?></strong><br>
|
||||||
|
|||||||
Binary file not shown.
@@ -243,9 +243,6 @@ msgstr "Scan website"
|
|||||||
msgid "Darstellung speichern"
|
msgid "Darstellung speichern"
|
||||||
msgstr "Save appearance"
|
msgstr "Save appearance"
|
||||||
|
|
||||||
msgid "neu"
|
|
||||||
msgstr "new"
|
|
||||||
|
|
||||||
msgid "Details anzeigen/ausblenden"
|
msgid "Details anzeigen/ausblenden"
|
||||||
msgstr "Show/hide details"
|
msgstr "Show/hide details"
|
||||||
|
|
||||||
@@ -255,9 +252,6 @@ msgstr "Blocker on/off"
|
|||||||
msgid "Dienst entfernen"
|
msgid "Dienst entfernen"
|
||||||
msgstr "Remove service"
|
msgstr "Remove service"
|
||||||
|
|
||||||
msgid "Interner Name (Slug)"
|
|
||||||
msgstr "Internal name (slug)"
|
|
||||||
|
|
||||||
msgid "Anbietername"
|
msgid "Anbietername"
|
||||||
msgstr "Provider name"
|
msgstr "Provider name"
|
||||||
|
|
||||||
@@ -318,8 +312,8 @@ msgstr "Renders a clearly visible link that withdraws consent for external embed
|
|||||||
msgid "Inhalt manuell blockieren"
|
msgid "Inhalt manuell blockieren"
|
||||||
msgstr "Block content manually"
|
msgstr "Block content manually"
|
||||||
|
|
||||||
msgid "Umschließt ein iframe und ersetzt es durch den Platzhalter des angegebenen Dienstes. Verwenden Sie den internen Namen aus dem Tab „Dienste\"."
|
msgid "Umschließt ein iframe und ersetzt es durch den Platzhalter des angegebenen Dienstes. Die ID ist der Anbietername in Kleinbuchstaben mit Bindestrichen (z. B. „Google Maps\" → google-maps)."
|
||||||
msgstr "Wraps an iframe and replaces it with the placeholder of the given service. Use the internal name from the \"Services\" tab."
|
msgstr "Wraps an iframe and replaces it with the placeholder of the given service. The ID is the provider name in lowercase with hyphens (e.g. \"Google Maps\" → google-maps)."
|
||||||
|
|
||||||
msgid "Dienste-Übersicht (Datenschutzerklärung)"
|
msgid "Dienste-Übersicht (Datenschutzerklärung)"
|
||||||
msgstr "Services overview (privacy policy)"
|
msgstr "Services overview (privacy policy)"
|
||||||
|
|||||||
@@ -84,11 +84,9 @@ EN = [
|
|||||||
"The license server visits your website and lists all embedded third-party resources (iframes, scripts, fonts, images, …). This shows at a glance which external services you should block. Requires an active license.",
|
"The license server visits your website and lists all embedded third-party resources (iframes, scripts, fonts, images, …). This shows at a glance which external services you should block. Requires an active license.",
|
||||||
"Scan website",
|
"Scan website",
|
||||||
"Save appearance",
|
"Save appearance",
|
||||||
"new",
|
|
||||||
"Show/hide details",
|
"Show/hide details",
|
||||||
"Blocker on/off",
|
"Blocker on/off",
|
||||||
"Remove service",
|
"Remove service",
|
||||||
"Internal name (slug)",
|
|
||||||
"Provider name",
|
"Provider name",
|
||||||
"Detection pattern (domain/path)",
|
"Detection pattern (domain/path)",
|
||||||
"Recipient (incl. country)",
|
"Recipient (incl. country)",
|
||||||
@@ -109,7 +107,7 @@ EN = [
|
|||||||
"Withdrawal (privacy policy)",
|
"Withdrawal (privacy policy)",
|
||||||
"Renders a clearly visible link that withdraws consent for external embeds and reloads the page (Art. 7(3) GDPR). Does NOT affect the cookie consent of a separate cookie plugin. Options: text=\"…\", style=\"link|button\", note=\"yes|no\".",
|
"Renders a clearly visible link that withdraws consent for external embeds and reloads the page (Art. 7(3) GDPR). Does NOT affect the cookie consent of a separate cookie plugin. Options: text=\"…\", style=\"link|button\", note=\"yes|no\".",
|
||||||
"Block content manually",
|
"Block content manually",
|
||||||
"Wraps an iframe and replaces it with the placeholder of the given service. Use the internal name from the \"Services\" tab.",
|
"Wraps an iframe and replaces it with the placeholder of the given service. The ID is the provider name in lowercase with hyphens (e.g. \"Google Maps\" → google-maps).",
|
||||||
"Services overview (privacy policy)",
|
"Services overview (privacy policy)",
|
||||||
"Lists all configured services with recipient, third-country note, purpose and privacy link. Ideal for inclusion in your privacy policy (Art. 13 GDPR).",
|
"Lists all configured services with recipient, third-country note, purpose and privacy link. Ideal for inclusion in your privacy policy (Art. 13 GDPR).",
|
||||||
"Version %s",
|
"Version %s",
|
||||||
|
|||||||
Reference in New Issue
Block a user