Created
March 14, 2014 09:46
-
-
Save j4ckielord/9544917 to your computer and use it in GitHub Desktop.
W Post Content Link Replacement
This file contains 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 | |
/** | |
* Plugin Name: DW Post Content Link Replacement | |
* Description: Add target="_blank" and rel="nofollow" to links. | |
* Version: 1.0 | |
* Author: DesignWall | |
* Author URI: http://www.designwall.com/ | |
* License: GPLv3 or later | |
**/ | |
function dw_link_replace_target($text) { | |
$new_text = str_replace('<a', '<a target="_blank"', $text); | |
return $new_text; | |
} | |
add_filter('the_content', 'dw_link_replace_target'); | |
function dw_link_replace_rel ($text) { | |
$new_text = str_replace('<a', '<a rel="nofollow"', $text); | |
return $new_text; | |
} | |
add_filter('the_content', 'dw_link_replace_rel'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment