Skip to content

Instantly share code, notes, and snippets.

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 spectodesign/bfc8dd42fa170dac00b9bb2f9ffad58c to your computer and use it in GitHub Desktop.
Save spectodesign/bfc8dd42fa170dac00b9bb2f9ffad58c to your computer and use it in GitHub Desktop.
Feedzy filter to add nofollow to links
function tifdtwo_feedzy_remove_link_matches( $matches ) {
return '<a href="' . $matches[1] .'" rel="nofollow">' . $matches[2]. '</a>';
}
function tifdtwo_feedzy_remove_link( $content, $feedURL ) {
// old, bad pattern
// $pattern= '/<a.*href=\"(https?:\/\/.*)\".*>(.*)<\/a>/iU';
$pattern= '/<a\s+href\s*=\s*"([^"]+)"[^>]*>([^<]+)<\/a>/iU';
$content= preg_replace_callback( $pattern, 'tifdtwo_feedzy_remove_link_matches', $content );
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment