SpoilerAlert/includes/SpoilerAlertHooks.php

18 lines
666 B
PHP
Raw Permalink Normal View History

2024-03-19 22:33:58 +01:00
<?php
class SpoilerAlertHooks {
public static function onParserFirstCallInit( Parser $parser ) {
$parser->setHook( 'spoiler', [ self::class, 'renderSpoiler' ] );
return true;
}
public static function renderSpoiler( $input, array $args, Parser $parser, PPFrame $frame ) {
$output = $parser->recursiveTagParse( $input, $frame );
return "<span class='spoiler' onclick='this.classList.toggle(\"revealed\")'>" . htmlspecialchars( $output ) . "</span>";
}
public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
2024-03-20 12:53:44 +01:00
$out->addModuleStyles( ['ext.spoileralert'] );
2024-03-19 22:33:58 +01:00
return true;
}
}