-
-
Save bewho/1c915255c8cee6c90728043931e82917 to your computer and use it in GitHub Desktop.
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
<?php | |
add_filter('wp_list_categories', 'esc_wp_rel_nofollow'); | |
add_filter('wp_tag_cloud', 'esc_wp_rel_nofollow'); | |
function esc_wp_rel_nofollow($output) | |
{ | |
if (is_single() || is_category() || is_tag()) | |
return stripslashes(wp_rel_nofollow($output)); | |
return $output; | |
} | |
/*==================================================*/ | |
add_filter('wp_list_categories', 'esc_wp_rel_nofollow'); | |
add_filter('wp_tag_cloud', 'esc_wp_rel_nofollow'); | |
function esc_wp_rel_nofollow($output) | |
{ | |
//wp_reset_query(); #Вставить если не срабатывает is_single() | |
if (is_single() || is_category() || is_tag()) | |
return preg_replace('#<a[^>+](.*)<\/a>#isU', '<a rel=\'nofollow\' $1</a>', $output); | |
return $output; | |
} | |
/*==================================================*/ | |
add_filter('the_tags', function ($tags) { | |
if (!is_single()) | |
$tags = preg_replace('#<a[^>+](.*)<\/a>#isU', '<a rel=\'nofollow\' $1</a>', $tags); | |
return str_replace(' rel="tag"', '', preg_replace('#<a[^>+](.*)>(.*)<\/a>#isU', '<a $1 title="$2">$2</a>', $tags)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment