Manual:Hooks/LinkerMakeExternalLink

From MediaWiki.org
Jump to: navigation, search
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 ) { ... }

Attach hook:
$wgHooks['LinkerMakeExternalLink'][] = 'MyExtensionHooks::onLinkerMakeExternalLink';
Called from: File(s): Linker.php

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


Details[edit | edit source]

  • &$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)

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/LinkEnd.