Manual:Hooks/AfterFinalPageOutput

From MediaWiki.org
Jump to navigation Jump to search
AfterFinalPageOutput
Available from version 1.20.0
Nearly at the end of OutputPage::output().
Define function:
public static function onAfterFinalPageOutput( $output ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"AfterFinalPageOutput": "MyExtensionHooks::onAfterFinalPageOutput"
	}
}

For MediaWiki ≤1.25:

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

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

Details[edit]

Nearly at the end of OutputPage::output() but before OutputPage::sendCacheControl() and final ob_end_flush() which will send the buffered output to the client. This allows for last-minute modification of the output within the buffer by using ob_get_clean().

  • $output: The OutputPage object where output() was called

How to use[edit]

$wgHooks['AfterFinalPageOutput'][] = "fnAfterAll";
function fnAfterAll($output) {
  $out = ob_get_clean();
  // change final html in $out
  ob_start();
  echo $out;
  return true;
}