From 6a416edb7e03696922407301f8cf07c109fe5a27 Mon Sep 17 00:00:00 2001 From: hongweipeng Date: Wed, 3 Feb 2021 11:14:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8E=E6=9F=90=E4=BA=9B?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E7=9A=84=E5=86=B2=E7=AA=81=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Plugin.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Plugin.php b/Plugin.php index 97ded40..b598f1b 100644 --- a/Plugin.php +++ b/Plugin.php @@ -174,10 +174,12 @@ class MenuTree_Plugin implements Typecho_Plugin_Interface { /** * 判断是否是内容页,避免主页加载插件 */ - public static function is_content() { + public static function is_content($widget = null) { static $is_content = null; - if($is_content === null) { + if (!$widget) { $widget = Typecho_Widget::widget('Widget_Archive'); + } + if($is_content === null) { $is_content = !($widget->is('index') || $widget->is('search') || $widget->is('date') || $widget->is('category') || $widget->is('author')); } return $is_content; @@ -190,7 +192,7 @@ class MenuTree_Plugin implements Typecho_Plugin_Interface { */ public static function parse( $html, $widget, $lastResult ) { $html = empty( $lastResult ) ? $html : $lastResult; - if (!self::is_content()) { + if (!self::is_content($widget)) { return $html; } $html = preg_replace_callback( '/]*>.*?<\/h\1>/s', array( 'MenuTree_Plugin', 'parseCallback' ), $html );