From 4ca920f729875874add32f0086097aea5eaf8353 Mon Sep 17 00:00:00 2001 From: vv221 Date: Fri, 3 Apr 2020 00:04:45 +0200 Subject: [PATCH] Only take action during the generation of the page menu --- action.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/action.php b/action.php index 88d04bc..6b9a909 100644 --- a/action.php +++ b/action.php @@ -17,7 +17,7 @@ class action_plugin_tabpage extends DokuWiki_Action_Plugin { * * @param Doku_Event_Handler $controller */ - public function register(Doku_Event_Handler $controller) { + public function register(Doku_Event_Handler $controller) : void { $controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addMenuItem'); } @@ -26,7 +26,7 @@ class action_plugin_tabpage extends DokuWiki_Action_Plugin { * * @param Doku_Event $event */ - public function addMenuItem(Doku_Event $event) { + public function addMenuItem(Doku_Event $event) : void { // Check that this method has been called in the expected context if ( $event->name !== 'MENU_ITEMS_ASSEMBLY' ) { $message = "Tabpage plugin error:"; @@ -34,6 +34,10 @@ class action_plugin_tabpage extends DokuWiki_Action_Plugin { $message .= ", but it has been called by \"$event->name\"."; throw new Exception($message); } + // Only add content to the page menu + if ( $event->data['view'] !== 'page' ) { + return; + } trigger_error('addMenuItem() not implemented in '.get_class($this), E_USER_WARNING); } }