diff --git a/functions.php b/functions.php index fd88d98..846b2e2 100644 --- a/functions.php +++ b/functions.php @@ -70,15 +70,14 @@ function img_postthumb($cid) { return ""; // 没有匹配到图片URL,返回空字符串 } } -//文章目录功能-给文章内标题加上id -function addHeaderLinks($text) -{ +//文章目录功能-给文章内标题加上id+超链接新窗口打开 +function addHeaderLinks($text) { return preg_replace_callback('/(.*?)<\/h\1>/', function ($matches) { $level = $matches[1]; $title = $matches[2]; $id = htmlspecialchars(strip_tags($title), ENT_QUOTES, 'UTF-8'); return sprintf('%s', $level, $id, $id, $title, $title, $level); - }, $text); + }, preg_replace('/', $text)); } //文章最后修改时间 function get_last_modified_time($postId) {