游客
EMLOG无需插件实现全网站源码压缩教程

EMLOG无需插件实现全网站源码压缩教程

一言准备中...

教程介绍

在以往的Emlog优化教程中,相信都是使用的代码压缩插件,今天主要是分享插件的代码版本,也就是不使用插件,直接将代码丢在module.php中就可以!

实现教程

1、以下代码是扔在module.php里面的

function em_compress_html_main($buffer){
    $initial=strlen($buffer);
    $buffer=explode("", $buffer);
    $count=count ($buffer);
    for ($i = 0; $i 

2、以下代码是扔在footer.php最末尾(即结尾处)

3、以上的代码有一个模板设置判断语句,其代码为以下:

'compress_html' => array(
        'type' => 'radio',
        'name' => '网站源码压缩',
        'description' => '',
        'values' => array('open' => '压缩','close' => '关闭'),
        'default' => 'open'
    ),

4、如果想要内容里面的pre不被压缩可使用以下函数:

function unCompress($content){
    if(preg_match_all('/(crayon-|<\/pre>)/i', $content, $matches)) {
        $content = ' '.$content;
        $content.= ' ';
    }
    return $content;
}
5、在echo_log.php、page.php文件中的$log_content替换为如下代码

unCompress($log_content)
  • 本文作者:樊不烦Emo
  • 本文链接: https://www.fanbu.fan/?post=60
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
0
0
关于作者
69
0
0
0
内卷太严重,已躺平...

Emlog pro怎么隐藏管理后台登录页面?emlog隐藏后台管理登录页面方法教程

上一篇

Emlog Pro如何限制注册用户权限?emlog限制注册用户权限方法教程

下一篇
评论区
内容为空

这一切,似未曾拥有