Manual:Hooks/LanguageLinks

LanguageLinks
Available from version 1.22.0
Manipulate a page's language links.

This is called in various places to allow extensions to define the effective language links for a page.

Define function:
public static function onLanguageLinks( $title, &$links, &$linkFlags ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"LanguageLinks": "MediaWiki\\Extension\\MyExtension\\Hooks::onLanguageLinks"
	}
}
Called from: File(s): api/ApiParse.php, OutputPage.php
Interface: LanguageLinksHook.php

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

Example

edit
$wgHooks['LanguageLinks'][] = function ( $title, &$links, &$linkFlags ) {
        // add Esperanto easter egg to all egg-related topics
        if ( stripos( $title->getText(), 'egg' ) !== false ) {
            $links[] = 'eo:Paska_ovo';
        }
        return true;
};