fix Plugins active

This commit is contained in:
2025-08-04 10:23:35 -04:00
parent 77d1c59cd0
commit 24e1100a1b

View File

@@ -3,21 +3,27 @@
* 页面黑白显示插件(支持时间段、指定日期、每月/每年循环)
*
* @package GrayModePlugin
* @author Your
* @version 1.1.0
* @author DylanWu
* @version 1.1.1
* @link https://your.site
*/
class GrayModePlugin implements Typecho_Plugin_Interface
class GrayMode_Plugin implements Typecho_Plugin_Interface
{
public static function activate()
{
Typecho_Plugin::factory('Widget_Archive')->header = [__CLASS__, 'changeheader'];
}
public static function activate()
{
Typecho_Plugin::factory('Widget_Archive')->header = __CLASS__ . '::render';
}
public static function deactivate() {}
public static function config(Typecho_Widget_Helper_Form $form)
{
try {
$options = Typecho_Widget::widget('Widget_Options')->plugin('GrayModePlugin');
// 可选:读取配置值
} catch (Exception $e) {
// 不处理配置读取错误
}
$start = new Typecho_Widget_Helper_Form_Element_Text(
'startTime', NULL, '00:00', '开始时间', '格式如 08:00'
);
@@ -42,13 +48,13 @@ class GrayModePlugin implements Typecho_Plugin_Interface
public static function personalConfig(Typecho_Widget_Helper_Form $form) {}
public static function changeheader()
public static function render($archive)
{
$options = Typecho_Widget::widget('Widget_Options')->plugin('GrayModePlugin');
$start = $options->startTime;
$end = $options->endTime;
$dates = trim($options->specialDates);
$start = $options->startTime ?? '00:00';
$end = $options->endTime ?? '23:59';
$dates = isset($options->specialDates) ? trim($options->specialDates) : '';
$now = date('H:i');
// 判断是否在时间区间内