Manual:Hooks/LinkerMakeExternalLink

Category:MediaWiki hooks#LinkerMakeExternalLink Category:Hooks added in MediaWiki 1.13.0#LinkerMakeExternalLink
LinkerMakeExternalLink
Available from version 1.13.0
Called before the HTML for external links is returned, used for modifying external link HTML
Define function:
public static function onLinkerMakeExternalLink( &$url, &$text, &$link, &$attribs, $linktype ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"LinkerMakeExternalLink": "MediaWiki\\Extension\\MyExtension\\Hooks::onLinkerMakeExternalLink"
	}
}
Called from: File(s): Linker.phpCategory:MediaWiki hooks included in Linker.php#LinkerMakeExternalLink
Interface: LinkerMakeExternalLinkHook.php

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

Details

  • &$url: The URL of the external link
  • &$text: The link text that would normally be displayed on the page
  • &$link: The link HTML if you choose to override the default.
  • &$attribs: Link attributes (added in MediaWiki 1.15, r48223)
  • $linktype: Type of external link, e.g. 'free', 'text', 'autonumber'. Gets added to the css classes. (added in MediaWiki 1.15, r48226)

You need to return false if you want to modify the HTML of external links, returning true will produce the normal external link HTML, regardless of if $link is set to something. Please note that you will need to include all parts of the HTML in $link, including the <a> tag, if you choose to return false.

To modify interwiki external links, see Manual:Hooks/HtmlPageLinkRendererEnd.

Category:Hooks added in MediaWiki 1.13.0 Category:MediaWiki hooks Category:MediaWiki hooks included in Linker.php