From 868be75a509e6ce4211e8cb4a1ba015136ce7afb Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Fri, 19 Aug 2022 20:58:34 +0000 Subject: [PATCH] Permalinks: Fix aria-live text when removing custom structure. Change the notification announced when a custom structure is removed. Previously, the notification incorrectly indicated that the structure was added for both actions. This changes the notification to correctly announce removals when structures are removed. Props joedolson, kebbet, SergeyBiryukov. Fixes #56230. git-svn-id: https://develop.svn.wordpress.org/trunk@53911 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/admin/common.js | 8 +++++++- src/wp-admin/options-permalink.php | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js index 5e15893d1f..8ea548e642 100644 --- a/src/js/_enqueues/admin/common.js +++ b/src/js/_enqueues/admin/common.js @@ -751,9 +751,15 @@ $availableStructureTags.on( 'click', function() { selectionStart = $permalinkStructure[ 0 ].selectionStart, selectionEnd = $permalinkStructure[ 0 ].selectionEnd, textToAppend = $( this ).text().trim(), - textToAnnounce = $( this ).attr( 'data-added' ), + textToAnnounce, newSelectionStart; + if ( $( this ).hasClass( 'active' ) ) { + textToAnnounce = $( this ).attr( 'data-removed' ); + } else { + textToAnnounce = $( this ).attr( 'data-added' ); + } + // Remove structure tag if already part of the structure. if ( -1 !== permalinkStructureValue.indexOf( textToAppend ) ) { permalinkStructureValue = permalinkStructureValue.replace( textToAppend + '/', '' ); diff --git a/src/wp-admin/options-permalink.php b/src/wp-admin/options-permalink.php index 2d91d9fffe..63749233ff 100644 --- a/src/wp-admin/options-permalink.php +++ b/src/wp-admin/options-permalink.php @@ -309,7 +309,8 @@ $available_tags = apply_filters( 'available_permalink_structure_tags', $availabl /* translators: %s: Permalink structure tag. */ $tag_added = __( '%s added to permalink structure' ); - +/* translators: %s: Permalink structure tag. */ +$tag_removed = __( '%s removed from permalink structure' ); /* translators: %s: Permalink structure tag. */ $tag_already_used = __( '%s (already used in permalink structure)' ); ?> @@ -378,6 +379,7 @@ printf( class="button button-secondary" aria-label="" data-added="" + data-removed="" data-used="">