Manual:Hooks/LinkBegin

From MediaWiki.org

Jump to: navigation, search
LinkBegin
Available from version 1.14.0
Used when generating internal and interwiki links in Linker::link(), before processing starts.

*Define function:
function fnMyHook( $skin, $target, &$text, &$customAttribs, &$query, &$options, &$ret ) { ... }

*Attach hook:
$wgHooks['LinkBegin'][] = 'fnMyHook';
Called from: Linker.php

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


[edit] Details

Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters.

  • $skin: the Skin object
  • $target: the Title that the link is pointing to
  • &$text: the contents that the <a> tag should have (raw HTML); null means "default"
  • &$customAttribs: the HTML attributes that the <a> tag should have, in associative array form, with keys and values unescaped. Should be merged with default values, with a value of false meaning to suppress the attribute.
  • &$query: the query string to add to the generated URL (the bit after the "?"), in associative array form, with keys and values unescaped.
  • &$options: the options. Can include 'known', 'broken', 'noclasses'.
  • &$ret: the value to return if your hook returns false.