I wrote the following code to address ADDING tag attributes, but here is a version to help you locate, and remove nofollow
:
add_filter( 'the_content', 'ex1_the_content_filter' );
function ex1_the_content_filter($content) {
// finds all links in your content with a nofollow
preg_match_all('/\<a .*?"nofollow".*?a>/',$content,$matches, PREG_SET_ORDER);
// loop through all matches
foreach($matches as $m){
// potential link to be replaced...
$toReplace = $m[0];
// You can add whatever additional "IF" conditions you require to this one
if (preg_match('/.*?\/pluto.*?/',$toReplace)){
// removes rel="nofollow" from the current link
$replacement = preg_replace('/(<a.*?)(rel="nofollow")(.*?a\>)/','$1$3',$toReplace);
// replaces the current link with the $replacement string
$content = str_ireplace($toReplace,$replacement,$content);
}
}
return $content;
}