diff --git a/inc/theme-article.php b/inc/theme-article.php index 43f767a..8a5300d 100644 --- a/inc/theme-article.php +++ b/inc/theme-article.php @@ -3,13 +3,13 @@ * 文章相关函数 * @author Seaton Jiang * @license MIT License - * @version 2021.01.06 + * @version 2021.02.18 */ // 文章链接添加 target 和 rel -function imgnofollow($content) +function content_nofollow($content) { - $regexp = "]*href=(\"??)([^\" >]*?)\\1[^>]*>"; + $regexp = "]*href=['\"][^#]([^'\"]*?)\\1[^>]*>"; if (preg_match_all("/$regexp/siU", $content, $matches, PREG_SET_ORDER)) { if (!empty($matches)) { $srcUrl = get_option('siteurl'); @@ -42,7 +42,7 @@ function imgnofollow($content) $content = str_replace(']]>', ']]>', $content); return $content; } -add_filter('the_content', 'imgnofollow'); +add_filter('the_content', 'content_nofollow'); // 文章点赞 function love()