diff --git a/action.php b/action.php index 92a20c6..1092ef0 100644 --- a/action.php +++ b/action.php @@ -33,6 +33,12 @@ class action_plugin_luxtools extends ActionPlugin $this, "addScripts", ); + $controller->register_hook( + "DOKUWIKI_STARTED", + "AFTER", + $this, + "provideJsInfo", + ); $controller->register_hook( "RENDERER_CONTENT_POSTPROCESS", "BEFORE", @@ -132,8 +138,20 @@ class action_plugin_luxtools extends ActionPlugin "src" => $base . $script, ]; } + } - // Pass OMDb API key to client-side JavaScript. + /** + * Pass plugin data to client-side JavaScript via JSINFO. + * + * Must run before TPL_METAHEADER_OUTPUT because JSINFO is serialized + * during tpl_metaheaders() before that event fires. + * + * @param Event $event + * @param mixed $param + * @return void + */ + public function provideJsInfo(Event $event, $param) + { // Intentional: the key is exposed to the browser for direct OMDb lookups. global $JSINFO; $JSINFO['luxtools_omdb_apikey'] = (string)$this->getConf('omdb_apikey');