Created
March 16, 2017 20:20
-
-
Save spectodesign/bfc8dd42fa170dac00b9bb2f9ffad58c to your computer and use it in GitHub Desktop.
Feedzy filter to add nofollow to links
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
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