Skip to content

Instantly share code, notes, and snippets.

@j4ckielord
Created March 14, 2014 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j4ckielord/9544917 to your computer and use it in GitHub Desktop.
Save j4ckielord/9544917 to your computer and use it in GitHub Desktop.
W Post Content Link Replacement
<?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