A WordPress plugin that automatically enhances the accessibility of generic links by adding descriptive aria-labels and visually hidden text.
This plugin improves web accessibility by identifying generic link text (such as "Learn more", "Click here", "Read more") and automatically enhancing them with contextual information. This helps screen reader users understand where links will take them without needing surrounding context.
Generic link text like "Click here" or "Learn more" creates accessibility barriers because:
- Screen reader users often navigate by jumping between links
- Without context, generic links are meaningless when read in isolation
- This violates WCAG 2.1 Success Criterion 2.4.4 (Link Purpose in Context)
- Content Scanning: The plugin scans WordPress content during rendering
- Pattern Detection: Identifies common generic link patterns in multiple languages
- Context Extraction: Analyzes surrounding text to understand link context
- Enhancement: Adds two accessibility improvements:
- aria-label: Provides descriptive label for screen readers
- Visually hidden text: Adds context visible only to assistive technologies
Before:
<p>Want to know more about our services? <a href="/services">Click here</a></p>After:
<p>
Want to know more about our services?
<a href="/services" aria-label="Click here to learn about our services">
Click here
<span class="wplaf-sr-only"> to learn about our services</span>
</a>
</p>- ✅ Automatic detection of generic links
- ✅ Multi-language support (English, Spanish, French, German, Italian, Portuguese)
- ✅ Smart context extraction from surrounding text
- ✅ Non-intrusive (doesn't change visual appearance)
- ✅ WCAG 2.1 compliant
- ✅ Lightweight and performant
- ✅ No configuration needed (works out of the box)
The plugin recognizes various generic link texts including:
- Click here / Clic aquí / Cliquez ici
- Read more / Leer más / Lire la suite
- Learn more / Más información / En savoir plus
- More info / Más info / Plus d'infos
- View details / Ver detalles / Voir les détails
- And many more...
- Log in to your WordPress admin panel
- Navigate to Plugins > Add New
- Search for "Link Accessibility Fix"
- Click Install Now and then Activate
- Download the plugin files
- Upload to
/wp-content/plugins/wp-link-accessibility/ - Activate through the WordPress 'Plugins' menu
- The plugin works automatically - no configuration required
- WordPress 5.0 or higher
- PHP 7.2 or higher
wp-link-accessibility/
├── accessibility-link-prefix.php # Main plugin file & bootstrapper
├── readme.txt # WordPress.org readme
├── README.md # GitHub documentation
├── license.txt # GPL v2 license (full text)
├── uninstall.php # Cleanup script for plugin deletion
└── src/ # Source code directory
├── includes/ # Core plugin classes
│ ├── class-autoloader.php # PSR-4 autoloader
│ ├── class-plugin.php # Main plugin controller
│ ├── class-link-processor.php # Link detection & enhancement
│ └── class-settings.php # Settings API & options
├── admin/ # Admin interface
│ ├── class-assets.php # Asset management
│ └── settings-page.php # Settings page template
└── config/ # Configuration
└── default-texts.php # Default generic patterns
- Purpose: Main plugin controller
- Responsibilities:
- Initializes all plugin components
- Manages hooks and filters
- Coordinates between classes
- Singleton pattern: Ensures single instance
- Purpose: Core link processing engine
- Responsibilities:
- Scans content for generic links
- Extracts contextual information
- Generates aria-labels
- Adds visually hidden text
- Methods:
process_content()- Main processing entry pointgenerate_aria_label()- Creates descriptive labelsget_parent_heading_context()- Extracts context from headings
- Purpose: Settings management
- Responsibilities:
- Admin menu registration
- Settings page rendering
- Options sanitization
- Default patterns management
- Singleton pattern: Single settings instance
- Purpose: Asset management
- Responsibilities:
- Enqueues CSS for screen-reader-only text
- Manages frontend styles
- Admin panel styling
- Purpose: PSR-4 compliant autoloader
- Responsibilities:
- Automatic class loading
- Namespace to file path conversion
The plugin uses a multi-layered approach to extract context:
- Parent Heading Analysis: Searches up to 5 levels up for
<h1>-<h6>tags - URL Path Parsing: Extracts meaningful text from URL segments
- Anchor Detection: Generates labels from internal anchors (#links)
- Fallback Strategy: Uses generic but descriptive text if no context found
Context extraction algorithm:
// 1. Check parent headings (most specific)
if (heading_found) {
return "about [heading text]";
}
// 2. Check for anchor links
if (href starts with '#') {
return "about [anchor name]";
}
// 3. Parse URL path
if (url_path_exists) {
return "about [last segment]";
}
// 4. Generic fallback
return "about this content";The plugin processes content through WordPress filters:
// Content filters (priority 20)
add_filter('the_content', [$this->link_processor, 'process_content'], 20);
add_filter('widget_text', [$this->link_processor, 'process_content'], 20);
add_filter('comment_text', [$this->link_processor, 'process_content'], 20);Custom Filters Available:
// Add custom generic patterns
add_filter('wplaf_generic_patterns', function($patterns) {
$patterns['custom'] = '/your pattern/i';
return $patterns;
});- ✅ WordPress Coding Standards
- ✅ PSR-4 autoloading
- ✅ Object-oriented architecture
- ✅ Fully documented (PHPDoc)
- ✅ Security best practices (nonce, sanitization, escaping)
Test the plugin with:
- Manual testing: Create posts with generic links
- Screen readers: Test with NVDA, JAWS, or VoiceOver
- Browser DevTools: Inspect aria-labels in HTML
- WordPress Plugin Check: Validate standards compliance
add_filter('wplaf_generic_patterns', function($patterns) {
$patterns['custom_read'] = '/read this/i';
$patterns['custom_view'] = '/view now/i';
return $patterns;
});add_filter('wplaf_should_process', function($should_process) {
if (is_page('contact')) {
return false; // Don't process on contact page
}
return $should_process;
});Works with all modern browsers and assistive technologies:
- Screen Readers: JAWS, NVDA, VoiceOver, TalkBack, Narrator
- Browsers: Chrome, Firefox, Safari, Edge
- Mobile: iOS Safari, Chrome Mobile, Samsung Internet
- Minimal overhead: Only processes content when rendered
- Smart caching: Uses WordPress object cache
- No database queries: Settings cached in memory
- Lightweight: < 50KB total size
Helps meet:
- WCAG 2.1 Level A: Success Criterion 2.4.4 (Link Purpose in Context)
- Section 508: Equivalent standards
- EN 301 549: European accessibility standard
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Clone the repository
git clone https://github.com/cafalco96/wp-link-accessibility.git
# Install in WordPress plugins directory
cd /path/to/wordpress/wp-content/plugins/
ln -s /path/to/wp-link-accessibility wp-link-accessibility
# Activate in WordPress admin- ✅ Automatic detection of generic links
- ✅ Multi-language support (EN, ES, FR, DE, IT, PT)
- ✅ Smart context extraction algorithm
- ✅ WCAG 2.1 compliance
- ✅ PSR-4 autoloading architecture
- ✅ Lightweight and performant
- Add visual admin dashboard with statistics
- Support for custom post types configuration
- Pattern exclusion list (whitelist specific generic links)
- Integration with popular page builders
- Advanced context extraction using AI/ML
- Export/import settings
Carlos Falconi
- Website: https://cafalco96.github.io/
- GitHub: @cafalco96
This plugin is licensed under the GPL v2 or later.
Copyright (C) 2024 Carlos Falconi
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
See license.txt for full license text.
- Issues: GitHub Issues
- WordPress.org: Support Forum
- Documentation: Plugin Wiki
This plugin does not:
- ❌ Collect any user data
- ❌ Make external API calls
- ❌ Store cookies
- ❌ Track users
All processing happens locally on your server.
Note: This plugin enhances accessibility but should be used alongside other accessibility best practices. Writing descriptive link text from the start is always the best approach.
Made with ❤️ for a more accessible web.