Manual:Hooks/OutputPageBeforeHTML

From MediaWiki.org
Jump to navigation Jump to search
OutputPageBeforeHTML
Available from version 1.6.0
Called every time wikitext is added to the OutputPage, after it is parsed but before it is added.
Define function:
public static function onOutputPageBeforeHTML( OutputPage &$out, &$text ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"OutputPageBeforeHTML": "MyExtensionHooks::onOutputPageBeforeHTML"
	}
}

For MediaWiki ≤1.25:

$wgHooks['OutputPageBeforeHTML'][] = 'MyExtensionHooks::onOutputPageBeforeHTML';
Called from:File(s): OutputPage.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:OutputPageBeforeHTML extensions.

Warning[edit]

Use this hook at your own risk.

  • Not used for edit previews (bug 7050) until 1.11.0 (r25341).
  • Can cause infinite loops (see talk)
  • May fail under certain caching systems
  • Runs on every page load and page view, so increases overhead

Details[edit]

  • $out: the OutputPage (object) to which wikitext is added
  • $text: the HTML text (string) that is being added