Created
August 5, 2013 07:30
-
-
Save purzlbaum/6154066 to your computer and use it in GitHub Desktop.
Attaches a external class to all links outside the domain. I got the code from: http://codegrad.hub.ph/marking-external-links-icon-wordpress/ and I extended it through line 14. The only thing you have to do: search a external link icon. You can find a good one on genericon.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* external links | |
a.external | |
background: url('../images/external_link.png') no-repeat right 0px |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Displays external link icon for WordPress | |
* | |
* Code from: http://codegrad.hub.ph/marking-external-links-icon-wordpress/ | |
* | |
* @package TWWC Bootstrap | |
* @author Claudio Schwarz | |
* @since twwc-bootstrap 0.1 | |
*/ | |
function twwc_bootstrap_external_link($text) { | |
$wpUrl = get_bloginfo('url'); | |
$return = str_replace('href=', 'class="external" href=', $text); | |
$return = str_replace('class="external" href="' . $wpUrl . '', 'href="' . $wpUrl . '', $return); | |
$return = str_replace('class="external" href="#', 'href="#', $return); | |
return $return; | |
} | |
add_filter('the_content', 'twwc_bootstrap_external_link'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment