Skip to content

Instantly share code, notes, and snippets.

View spectodesign's full-sized avatar

spectodesign

View GitHub Profile
@spectodesign
spectodesign / gist:bfc8dd42fa170dac00b9bb2f9ffad58c
Created March 16, 2017 20:20
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 );
function sd_logger( $debug = false, $message = '', $error_log_path = '' ){
if( $debug ){
if( empty($error_log_path) ){
error_log($message);
} else {
error_log($message, 0, $error_log_path);
}
}