=== WP External Links (nofollow new tab seo) === Contributors: freelancephp Tags: links, new window, new tab, external links, nofollow, follow, seo, noopener, noreferrer, internal links, link icon, link target, _blank, wpmu Requires at least: 4.2.0 Tested up to: 4.5.2 Stable tag: 2.0.2 Open external links in a new tab / window, add "nofollow", "noopener" and font icons, SEO and more. Also for internal links. == Description == Configure settings for all internal and external links on your site. > === NEW: Version 2 ===
> WPEL plugin was rebuilt completely and has lots of new features, like "noopener", font icons, internal links options and WPMU settings. = Features = * Open links in new window or tab * Add "follow" or "nofollow" * Add "noopener" and "noreferrer" (for security) * Add link icons (font icons: font awesome, dashicons) * Set other attributes like title and CSS classes * Scan posts, comments, widgets or the whole page * Better SEO = And more... = * Network Settings (WPMU support) * Use template tag to apply plugin settings on specific contents * Set data-attribute to change how individual links will be treated * Use action and filters to implement your specific needs = Easy to use = After activating you can set all options for external and internal links on the plugins admin page. = On the fly = The plugin filters the output and changes the links on the fly. The real contents (posts, pages, widget etcetera) will not be changed in the database. When deactivating the plugin, all contents will be the same as it was before. = Requirements = * PHP version 5.3 or up * WordPress version 4.2 or up If you want support for older versions of PHP or WordPress then download and install [version 1.81](https://downloads.wordpress.org/plugin/wp-external-links.1.81.zip) of this plugin. = Sources = * [Documentation](http://wordpress.org/extend/plugins/wp-external-links/other_notes/) * [FAQ](http://wordpress.org/extend/plugins/wp-external-links/faq/) * [Github](https://github.com/freelancephp/WP-External-Links) > Like this plugin?
> [Rate it](http://wordpress.org/support/view/plugin-reviews/wp-external-links) to support the development of this plugin. == Installation == 1. Go to `Plugins` in the Admin menu 1. Click on the button `Add new` 1. Search for `WP External Links` and click 'Install Now' OR click on the `upload` link to upload `wp-external-links.zip` 1. Click on `Activate plugin` == Frequently Asked Questions == = I want certain posts or pages to be ignored by the plugin. How? = `add_action( 'wpel_apply_settings', function () { global $post; $excluded_post_ids = array( 1, 2, 4 ); if ( in_array( $post->ID, $excluded_post_ids ) ) { return false; } return true; }, 10 );` = How to create a redirect for external links? (f.e. affiliate links) = Create redirect by using the `wpel_link` action. Add some code to functions.php of your theme, like: `add_action( 'wpel_link', function ( $link_object ) { // check if link is an external links if ( $link_object->isExternal() ) { // get current url $url = $link_object->getAttribute( 'href' ); // set redirect url $redirect_url = '//somedom.com?url='. urlencode( $url ); $link_object->setAttribute( 'href', $redirect_url ); } }, 10, 1 );` = How to open external links in a new popup window? = By adding this JavaScript code to your site: `jQuery(function ($) { $('a[data-wpel-link="external"]').click(function (e) { // open link in popup window window.open($(this).attr('href'), '_blank', 'width=800, height=600'); // stop default and other behaviour e.preventDefault(); e.stopImmediatePropagation(); }); });` See more information on the [window.open() method](http://www.w3schools.com/jsref/met_win_open.asp). = How to add an confirm (or alert) when opening external links? = Add this JavaScript code to your site: `jQuery(function ($) { $('a[data-wpel-link="external"]').click(function (e) { if (!confirm('Are you sure you want to open this link?')) { // cancelled e.preventDefault(); e.stopImmediatePropagation(); } }); });` [Do you have a question? Please ask me](http://www.finewebdev.comcontact/) == Screenshots == 1. Link Icons 1. Admin Settings Page 1. WPMU Network Settings Page == Documentation == After activating you can set all options for external and internal links. = Data attribute "data-wpel-link" = It's possible to add a special data attribute to individual links, so they will be marked (and treated) as external link, internal link, excluded link or completely ignored. `Go to somedomain` Possible values are `external`, `internal`, `exclude` or `ignore`. All links filtered by the plugin will contain this data attribute and the value on how they were treated. = Action "wpel_link" = Use this action to change the link object after all plugin settings have been applied. `add_action( 'wpel_link', ( $link_object ) { if ( $link_object->isExternal() ) { // get current url $url = $link_object->getAttribute( 'href' ); // set redirect url $redirect_url = '//somedom.com?url='. urlencode( $url ); $link_object->setAttribute( 'href', $redirect_url ); } }, 10, 1 )` The link object is an instance of WPEL_Link class (a subclass of [DOMElement](http://php.net/manual/en/class.domelement.php)). = Filter hook "wpel_apply_settings" = When filter returns false the plugin settings will not be applied. Can be used when f.e. certain posts or pages should be ignored by this plugin. `add_filter( 'wpel_apply_settings', '__return_false' );` = Filter hook "wpel_before_filter" = Filter the content before searching for links and apply setttings. `add_filter( 'wpel_before_filter', function ( $content ) { // some code.. return $changed_content; }, 10 );` = Filter hook "wpel_after_filter" = Filter the content after applying link setttings. `add_filter( 'wpel_after_filter', function ( $content ) { // some code.. return $changed_content; }, 10 );` = Filter hook "wpel_regexp_link" = A filter for changing the regular expression for links. Should only be used to solve bugs on your site. `add_filter( 'wpel_regexp_link', function ( $regexp_link ) { $custom_regexp_link = '/(.*?)<\/a>/is'; return $custom_regexp_link; }, 10 );` See [FAQ](https://wordpress.org/plugins/wp-external-links/faq/) for more info. == Changelog == = 2.0.2 = * Fixed bug parsing empty attributess * Changed mailto links wil be completely ignored = 2.0.1 = * Fixed mark mailto links as excluded * Fixed include / exclude url's = 2.0.0 = * REQUIREMENTS: PHP 5.3+ * Complete rebuilt * Added `noopener` and `noreferrer` * Added font icons (font awesome and dashicons) * Added options for internal links * Added Network settings (WPMU support) * Contribution: David Page solving bug `home_url()` = 1.81 = * Security update (reported by Vulnerability Lab) * Some small changes = 1.80 = * Added filter hook wpel_external_link_attrs to change attributes before creating the link * Added filter hook wpel_ignored_external_links * Removed phpQuery option * Moved ignore selectors option = 1.70 = * Added option to ignore all subdomains = 1.62 = * Fixed php error when using phpQuery option = 1.61 = * Fixed deprecated split() function * Fixed deprecated $wp_version = 1.60 = * Added option to replace "follow" values of external links with "nofollow" * Updated FAQ with custom solutions = 1.56 = * Fixed bug jQuery as dependency for js scripts * Fixed bug "no-icon class in same window" working with javascript * Fixed bug setting defaults on installation = 1.55 = * Fixed bug JS error: Uncaught TypeError: undefined is not a function * Fixed bug PHP error for links without href attribute ("undefined index href") * Replaced deprecated jQuery .live() to .on() (contribution by Alonbilu) = 1.54 = * Fixed bug opening links containing html tags (like ) = 1.53 = * Fixed bug also opening ignored URL's on other tab/window when using javascript * Changed javascript open method (data-attribute) = 1.52 = * Added filter hook wpel_internal_link * Fixed use_js option bug * Fixed bug loading non-existing stylesheet * Minified javascripts = 1.51 = * Fixed also check url's starting with // * Fixed wpel_external_link also applied on ignored links = 1.50 = * Removed stylesheet file to save extra request * Added option for loading js file in wp_footer * Fixed bug with data-* attributes * Fixed bug url's with hash at the end * Fixed PHP errors = 1.41 = * Fixed Bug: wpmel_external_link filter hook was not working correctly = 1.40 = * Added action hook wpel_ready * Added filter hook wpel_external_link * Added output flush on wp_footer * Fixed Bug: spaces before url in href-attribute not recognized as external link * Fixed Bug: external links not processed (regexpr tag conflict starting with an a, like