Skip to content

feat: strip new tab notice from excerpts / make new tab notice config…#57

Merged
Yannicvanveen merged 3 commits into
mainfrom
feat/strip-new-tab-notice-from-excerpts
Apr 3, 2026
Merged

feat: strip new tab notice from excerpts / make new tab notice config…#57
Yannicvanveen merged 3 commits into
mainfrom
feat/strip-new-tab-notice-from-excerpts

Conversation

@Yannicvanveen
Copy link
Copy Markdown
Contributor

Momenteel verschijnt de tekst '(opent in nieuw tablad)' die we toevoegen aan links met een target="_blank" in automatisch gegenereerde excerpts. Deze PR maakt deze tekst configureerbaar en haalt hem uit de excerpt.

Voor:
Screenshot 2026-04-01 at 11 51 52

Na:
Screenshot 2026-04-01 at 11 51 25

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the “opens in new tab” accessibility notice configurable and prevents it from appearing in automatically generated WordPress excerpts.

Changes:

  • Introduces a configurable $newTabNotice value (via theme.a11y_new_tab_notice with a translated default).
  • Uses the configured notice when appending an sr-only span to target="_blank" links.
  • Adds a get_the_excerpt filter to strip the notice from auto-generated excerpts.
Comments suppressed due to low confidence (1)

src/Theme.php:213

  • createElement('span', ' ' . $this->newTabNotice) always prefixes a space even if the configured notice already contains leading whitespace. This can introduce unintended double-spacing in the rendered output. Prefer normalizing the configured notice once (e.g., trim leading whitespace in the constructor) and then add a single separator space here, or only add the separator when needed.
			try {
				$srOnlySpan = $doc->createElement('span', ' ' . $this->newTabNotice);
			} catch (\DOMException $e) {
				continue;
			}
			$srOnlySpan->setAttribute('class', 'sr-only');
			$link->appendChild($srOnlySpan);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Theme.php Outdated
Comment thread src/Theme.php Outdated
@Yannicvanveen Yannicvanveen merged commit bd94fb6 into main Apr 3, 2026
2 checks passed
@Yannicvanveen Yannicvanveen deleted the feat/strip-new-tab-notice-from-excerpts branch April 3, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants