Typecho外链接使用新窗口打开

Typecho默认支持Markdown语法,但是Markdown的a标签默认是在当前页跳转链接,如果想要属于本站的链接不要打开新窗口,只有外链接才新窗口打开,且不要改变a标签的当前属性,只添加新窗口跳转这个属性,且不要漏网。

function themeInit($archive) { if ($archive->is('single')) { $archive->content = preg_replace('/<a\b([^>]+?)\bhref="((?!'.addcslashes($options->index, '/._-+=#?&').'|\#).*?)"([^>]*?)>/i', '<a\1href="\2"\3 target="_blank">', $archive->content); } }

猜你喜欢

转载自www.cnblogs.com/fdfgfggh/p/12014307.html