我会尝试“wp\\u insert\\u post\\u data”过滤器。
add_filter(\'wp_insert_post_data\', \'new_content\' );
function new_content($content) {
preg_match_all(\'~<a.*>~isU\',$content["post_content"],$matches);
for ( $i = 0; $i <= sizeof($matches[0]); $i++){
if ( !preg_match( \'~nofollow~is\',$matches[0][$i]) ){
$result = trim($matches[0][$i],">");
$result .= \' rel="nofollow">\';
$content[\'post_content\'] = str_replace($matches[0][$i], $result, $content[\'post_content\']);
}
}
return $content;
}
显然需要工作,只是一个PoC。