1<?php 2 3declare(strict_types=1); 4 5use dokuwiki\Extension\ActionPlugin; 6use dokuwiki\Extension\Event; 7use dokuwiki\Extension\EventHandler; 8 9final class action_plugin_today extends ActionPlugin 10{ 11 public function register(EventHandler $controller): void 12 { 13 $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'redirectToTodayPage'); 14 } 15 16 public function redirectToTodayPage(Event $event, ?array $param): void 17 { 18 if ($event->data === 'today') { 19 global $INPUT; 20 $namespace = $INPUT->has('namespace') ? $INPUT->str('namespace') : ''; 21 $format = $INPUT->has('format') ? $INPUT->str('format') : 'Y-m-d'; 22 $today = date($format); 23 send_redirect(wl("{$namespace}:{$today}")); 24 } 25 } 26} 27