register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handle_metaheader'); // ADD THIS NEW HOOK: Intercepts custom AJAX signals globally $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax_call'); } public function handle_metaheader(Doku_Event $event, $param) { $plugin_url = DOKU_BASE . 'lib/plugins/pgpblock/'; $event->data['script'][] = array( 'type' => 'text/javascript', 'src' => $plugin_url . 'utils.js', 'defer' => 'defer', '_inline' => false ); $event->data['script'][] = array( 'type' => 'text/javascript', 'src' => $plugin_url . 'view.js', 'defer' => 'defer', '_inline' => false ); $event->data['script'][] = array( 'type' => 'text/javascript', 'src' => $plugin_url . 'editor.js', 'defer' => 'defer', '_inline' => false ); } // New function that processes the text rendering completely bypasses remote.php public function handle_ajax_call(Doku_Event $event, $param) { if ($event->data !== 'plugin_pgpblock_parsePlaintext') return; // Stop DokuWiki from throwing an "unknown call" error $event->preventDefault(); $event->stopPropagation(); // Security check: Ensure user has basic read access to the wiki if (auth_quickaclcheck(getID()) < AUTH_READ) { http_response_code(403); echo "Access Denied"; return; } // Pull incoming raw text array safely from the jQuery POST request $args = $_POST['args'] ?? []; $text = $args[0] ?? ''; // Run through full Dokuwiki parser pipeline into XHTML format $info = array(); $html_output = p_render('xhtml', p_get_instructions($text), $info); // Print the data out cleanly to the AJAX response channel echo $html_output; } }