Manual:Hooks/BrokenLink

From MediaWiki.org
Jump to navigation Jump to search
BrokenLink
Available from version 1.13.0
Removed in version 1.14.0
Before the HTML is created for a broken (i.e. red) link
Define function:
public static function onBrokenLink( &$linker, $nt, $query, &$u, &$style, &$prefix, &$text, &$inside, &$trail ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"BrokenLink": "MyExtensionHooks::onBrokenLink"
	}
}

For MediaWiki ≤1.25:

$wgHooks['BrokenLink'][] = 'MyExtensionHooks::onBrokenLink';
Called from:File(s): Linker.php

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

Details[edit]

  • &$linker: Linker instance
  • $nt: the page title
  • $query: the URL query string passed in
  • &$u: the URL of this link
  • &$style: the inline CSS style
  • &$prefix: a prefix prepended to the linked text
  • &$text: the text placed by the user in the wiki-link
  • &$inside: any additional alphanumeric characters placed after the wiki-link, that are made part of the link text
  • &$trail: text placed immediately after the HTML link