这是一款子比主题评论链接直接跳转的功能,作用就是用户在我们的评论区评论了网站的链接,那么会自动转成超链接,腾飞博客做了两款样式,一个是默认跟主题色,一个是链接下固定下划线,当然你如果有自己的样式也可以写进去!
![图片[1] - 子比主题 – 评论链接直链跳转功能(共两款) - 狐狸资源网](https://s1.img.fenx.top/s/68c589cdc8dae.webp)
代码部署
定位:/wp-content/themes/zibll/inc/functions/zib-comments-list.php
文件,我们搜下面代码!
然后我们看上面的图片喜欢哪个一款直接替换我的整个函数代码,如下图我圈住的替换即可!
![图片[3] - 子比主题 – 评论链接直链跳转功能(共两款) - 狐狸资源网](https://s1.img.fenx.top/s/68c58a150c339.webp)
第一款
第一款没有样式,是直接跳转的,直接替换整个函数代码即可!
function zib_comment_filters($cont, $type = '', $lazy = true)
{
$cont = preg_replace_callback('/https?:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/', function($matches) {
return '<a href="' . $matches[0] . '" class="comment-link" target="_blank">' . $matches[0] . '</a>';
}, $cont);
$cont = convert_smilies($cont);
$cont = preg_replace('/\[img=(.*?)\]/', '<img class="box-img lazyload" src="$1" alt="评论图片' . zib_get_delimiter_blog_name() . '">', $cont);
if ('noimg' == $type) {
$cont = preg_replace('/\<img(.*?)\>/', '[图片]', $cont);
$cont = preg_replace('/\[code]([\s\S]*)\[\/code]/', '[代码]', $cont);
} else {
$cont = str_replace('[code]', '<pre><code>', $cont);
$cont = str_replace('[/code]', '</code></pre>', $cont);
}
$cont = preg_replace('/\[g=(.*?)\]/', '<img class="smilie-icon" src="' . ZIB_TEMPLATE_DIRECTORY_URI . '/img/smilies/$1.gif" alt="表情[$1]' . zib_get_delimiter_blog_name() . '">', $cont);
if (zib_is_lazy('lazy_comment') && $lazy) {
$cont = str_replace(' src=', ' src="' . zib_get_lazy_thumb() . '" data-src=', $cont);
}
$cont = wp_kses_post($cont);
return $cont;
}
第二款
第二款是带有固定波浪的样式,不是动态的,一共两个代码,首先还是替换整个函数代码即可!
function zib_comment_filters($cont, $type = '', $lazy = true) {
$cont = convert_smilies($cont);
$cont = preg_replace('/\[img=(.*?)\]/', '<img class="box-img lazyload" src="$1" alt="评论图片' . zib_get_delimiter_blog_name() . '">', $cont);
$pattern = '/(https?:\/\/[^\s]+)/i';
$replacement = '<a href="$1" target="_blank" class="comment-link" style="color: var(--focus-color);">$1</a>';
$cont = preg_replace($pattern, $replacement, $cont);
if ('noimg' == $type) {
$cont = preg_replace('/\<img(.*?)\>/', '[图片]', $cont);
$cont = preg_replace('/\[code]([\s\S]*)\[\/code]/', '[代码]', $cont);
} else {
$cont = str_replace('[code]', '<pre><code>', $cont);
$cont = str_replace('[/code]', '</code></pre>', $cont);
}
$cont = preg_replace('/\[g=(.*?)\]/', '<img class="smilie-icon" src="' . ZIB_TEMPLATE_DIRECTORY_URI . '/img/smilies/$1.gif" alt="表情[$1]' . zib_get_delimiter_blog_name() . '">', $cont);
if (zib_is_lazy('lazy_comment') && $lazy) {
$cont = str_replace(' src=', ' src="' . zib_get_lazy_thumb() . '" data-src=', $cont);
}
$cont = wp_kses_post($cont);
return $cont;
}
然后第二个代码放到:子比主题–>>自定义CSS样式
即可!
宇凌云界温馨提示:本文地址 https://www.yulll.com/2391.html
Ctrl+D收藏我们
免费下载资源不会提供任何帮助除非给钱
部分内容来自于网络 如有不妥联系站长删除
本站代码模板仅供学习交流使用请勿商业运营,严禁从事违法,侵权等任何非法活动,否则后果自负!
温馨提示:
本文最后更新于
2025-09-14 09:35:20
© 版权声明
THE END
暂无评论内容