本教程与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.开启即可
本站同款维护代码:
满满的都是干货,感谢分享!
满满的都是干货,感谢分享!