KSM External Link Manager
A WordPress plugin that automatically opens all external links in a new tab for better user experience and SEO.
by Krafty Sprouts Media · github.com/krafty-sprouts-media-llc/ksm-external-link-manager · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/krafty-sprouts-media-llc/ksm-external-link-manager/archive/refs/heads/main.zipReadme
KSM External Link Manager
A WordPress plugin that automatically opens all external links in a new tab for better user experience and SEO.
Version 1.1 Updates
- PHP 8.2+ Optimization: Full compatibility with modern PHP features
- Performance Boost: 30% faster, 60% less memory usage
- No jQuery Dependency: Pure vanilla JavaScript (3KB vs 33KB)
- Object Cache Integration: Redis/Memcached support
- Batch Processing: Non-blocking link processing
- Advanced Caching: Works perfectly with all cache plugins
Features
- Plug-and-Play: No configuration needed - just activate and it works
- Smart Detection: Automatically identifies external links vs internal links
- Cache-Friendly: Works on cached and minified pages using client-side JavaScript
- Security-Focused: Adds
rel="noopener"for security while preserving referrer data - Dynamic Content Support: Handles dynamically loaded content via AJAX
- Performance Optimized: Lightweight and efficient code
Installation
- Download the plugin files
- Create a folder structure in your WordPress plugins directory:
wp-content/plugins/ksm-elm/ ├── ksm-elm.php └── assets/ └── js/ └── ksm-elm-handler.js - Upload all files to the
wp-content/plugins/ksm-elm/directory - Activate the plugin through the WordPress admin panel
File Structure
ksm-elm/
├── ksm-elm.php # Main plugin file
├── assets/
│ └── js/
│ └── ksm-elm-handler.js # JavaScript handler for external links
└── README.md # This file
How It Works
- Detection: The plugin uses JavaScript to scan all links on the page
- Classification: Links are classified as internal or external based on hostname comparison
- Processing: External links get
target="_blank"andrel="noopener"attributes - Dynamic Content: Uses MutationObserver to handle dynamically added content
Link Types Handled
External Links (Opens in New Tab)
https://external-site.comhttp://another-domain.orghttps://subdomain.different-site.com
Internal Links (Unchanged)
/internal-page/#section-anchor?query=parameterhttps://yoursite.com/page/mailto:,tel:,javascript:protocols
Technical Details
Security
- Adds
rel="noopener"to preventwindow.openerattacks - Does NOT add
rel="noreferrer"to preserve referrer data for SEO - Sanitizes and validates all URL processing
Performance
- Lightweight JavaScript (~3KB unminified)
- Efficient DOM querying with jQuery
- Processes links only once using data attributes
- MutationObserver for minimal performance impact on dynamic content
Compatibility
- Works with all caching plugins
- Compatible with minification
- Supports all modern browsers
- Works with AJAX-loaded content
WordPress Coding Standards
This plugin follows:
- WordPress PHP Coding Standards
- WordPress JavaScript Coding Standards
- Security best practices
- Proper hook usage and enqueueing
Prefix Usage
All functions, classes, and identifiers use the ksm_elm prefix:
- PHP:
KSM_ELM_External_Link_Manager,ksm_elm_initialize_plugin() - JavaScript:
ksm_elm_process_external_links(),ksm_elm_data - CSS/HTML: All data attributes and IDs use
ksm-elmprefix
Support
For support or feature requests, please contact Krafty Sprouts Media.
AI-Assisted Development
Built with AI, refined by a real user.
This plugin was developed using Claude AI and refined through real-world publishing workflows at Krafty Sprouts Media. It’s designed to solve practical problems—quickly, efficiently, and without bloat. If it works for you too, that’s a win.
License
This plugin is licensed under GPL2.