【Joe】一键开启全站维护
侧边栏壁纸
  • 累计撰写 75 篇文章
  • 累计收到 21 条评论

【Joe】一键开启全站维护

逍遥博客
2021-11-11 / 4 评论 / 5 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2023年09月22日,已超过308天没有更新,若内容或图片失效,请留言反馈。

本教程与2022.5.21更新了部分内容

1.先在自定义页面的文件里面添加开关按钮

放在}?> 上面
位置:usr/themes/Joe-master/public/custom.php

$weihu = new Typecho_Widget_Helper_Form_Element_Select(
    'weihu',
    array(
        'off' => '关闭(默认)',
        'on' => '开启',
    ),
    'on',
    '是否启用全站维护',
    '介绍:开启后,全站进入维护状态'
);
$weihu->setAttribute('class', 'joe_content joe_custom'); // 如果没有custom这个文件  就将joe_custom修改为joe_other  把这个代码放在usr/themes/Joe-master/functions.php里面
$form->addInput($weihu->multiMode());
2.创建维护页面

在usr/themes/Joe-master添加Maintain.html文件

3.添加跳转维护页面的代码
<!--  直接在 public/header.php顶部添加以下代码 (第一格  不用在什么代码下面 就第一格) -->
<!-- 如果你只想某些页面跳转,比如只想跳转首页,你可以在index.php添加下面的代码  -->

<!-- 维护跳转 -->
<?php 
if(Helper::options()->weihu === 'on') {
    header("Location: usr/themes/Joe-master/Maintain.html"); // 如果觉得这个路径太长可以直接改为 Maintain.html 去掉前缀
    exit;
}
?>
4.开启即可

本站同款维护代码:

0

评论 (4)

取消
  1. 头像
    咔咔
    Windows 10 · Google Chrome

    满满的都是干货,感谢分享!

    回复
  2. 头像
    joinliu
    Windows 10 · Google Chrome

    画图

    回复
  3. 头像
    AK
    Windows 10 · Google Chrome

    画图

    回复
  4. 头像
    咳咳
    Windows 10 · Google Chrome

    满满的都是干货,感谢分享!

    回复
Blog逍遥阁博客