themeInit 不常用的代码

972天前1699

Typecho中 functions 文件 themeInit 自定义:

function themeInit($archive)
{
 Helper::options()->commentsMaxNestingLevels = 99;//评论回复最高 99 层,设置里最高只有 7 层
 Helper::options()->commentsAntiSpam = false;//评论关闭反垃圾保护
if ($archive->is('author')) {
       $archive->parameter->pageSize = 20; // 作者页面每 20 篇文章分页
}
 if ($archive->is('category','life')) {
 $archive->parameter->pageSize = 10; // 分类缩略名为 life 的分类,每 10 篇文章分页
}
 $archive->content = a_class_replace($archive->content);//文章内容,让 a_class_replace 函数处理
}
function a_class_replace($content)
{
  $content = preg_replace('#<a(.*?) href="([^"]*/)?(([^"/]*)\.[^"]*)"(.*?)>#',
        '<a$1 href="$2$3"$5 target="_blank">', $content);//给文章每个超链接点击后新窗口打开
}

* 若非特殊说明,本站文章均为博主原创,码字不易,如需转载,请注明出处!有疑问可留言交流,谢谢。

Typecho0 

themeInit 不常用的代码 - Jdeal | Life is like a Design.