feat: dienst-ID im Dienste-tab anzeigen + shortcode-hilfe fuer text/style (v1.4.9)
- Unter jedem dienstnamen wird jetzt die auto-erzeugte ID angezeigt (z. B. "ID: eigenes-matomo") - kopierbar, fuer den consent-shortcode. Bei neuen diensten live-vorschau aus dem namen (slugify, spiegelt sanitize_title); bei gespeicherten die stabile ID. - Shortcode-tab: [content_blocker_consent] erklaert jetzt id/text/style einzeln mit beispielen (button vs. link). + i18n DE/EN ergaenzt (131 strings). version 1.4.9. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -16,9 +16,29 @@
|
||||
const name = ( $( '.cb-input-name', box ).val() || '' ).trim();
|
||||
$( '.cb-service-title', box ).first().text( name || ( cbAdmin.newServiceLbl || 'Neuer Dienst' ) );
|
||||
}
|
||||
|
||||
/* ── Slugify a name to an id (mirrors PHP sanitize_title closely enough). ── */
|
||||
function slugify( s ) {
|
||||
return ( s || '' ).toString().trim().toLowerCase()
|
||||
.replace( /ä/g, 'a' ).replace( /ö/g, 'o' ).replace( /ü/g, 'u' ).replace( /ß/g, 'ss' )
|
||||
.replace( /[^a-z0-9]+/g, '-' )
|
||||
.replace( /^-+|-+$/g, '' );
|
||||
}
|
||||
|
||||
/* ── Show the service id (stable for saved services, live preview for new). ── */
|
||||
function updateId( box ) {
|
||||
let id = ( $( '.cb-input-id', box ).val() || '' ).trim();
|
||||
if ( ! id ) {
|
||||
id = slugify( $( '.cb-input-name', box ).val() );
|
||||
}
|
||||
$( '.cb-service-id', box ).text( id );
|
||||
$( '.cb-service-idline', box ).toggle( !! id );
|
||||
}
|
||||
|
||||
function bindNameSync( box ) {
|
||||
$( '.cb-input-name', box ).on( 'input', function () {
|
||||
syncTitle( box );
|
||||
updateId( box );
|
||||
} );
|
||||
}
|
||||
|
||||
@@ -67,6 +87,7 @@
|
||||
}
|
||||
setExpanded( $box, true ); // new rows start expanded for editing
|
||||
syncTitle( $box );
|
||||
updateId( $box );
|
||||
return $box;
|
||||
}
|
||||
|
||||
@@ -274,6 +295,7 @@
|
||||
$( '#cb-services-list .cb-service-box' ).each( function () {
|
||||
bindNameSync( this );
|
||||
bindToggle( this );
|
||||
updateId( this );
|
||||
$( '.cb-remove-service', this ).on( 'click', handleRemove );
|
||||
} );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user