Manual:Hooks/SkinAddFooterLinks

From Linux Web Expert

SkinAddFooterLinks
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
Add items to the footer for skins using SkinAddFooterLinks.

By design this hook cannot be used to disable existing links. To disable existing links please consult the documentation for the extension which adds the link you want to disable or disable the associated message key.

<translate> Define function:</translate>
public static function onSkinAddFooterLinks( Skin $skin, string $key, array &$footerlinks ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"SkinAddFooterLinks": "MediaWiki\\Extension\\MyExtension\\Hooks::onSkinAddFooterLinks"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> SkinTemplate.php
<translate> Interface:</translate> SkinAddFooterLinksHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:SkinAddFooterLinks extensions</tvar>.</translate>


Details

This hook allows alteration of the footer.

Parameters:

  • $skin: the Skin object
  • $key: the current key for the current group (row) of footer links. Currently either info or places.
  • &$footerItems: the array of links that can be changed. Keys will be used for generating the ID of the footer item; values should be HTML strings.

Default footer items

Setting a text-generating message for one of the places items to - removes that item from the footer. For instance to disable the "Disclaimers" link, you should edit MediaWiki:Disclaimers and set its content to "-" or set it to be blank.

Examples

// Add a link to the page "Test Page" with the text "Test", allowing modification by wiki administrators
// test-desc and test-page are i18n messages with the text of the link and the name of the page, respectively
public static function onSkinAddFooterLinks( Skin $skin, string $key, array &$footerlinks  ) {
    if ( $key === 'places' ) {
        $footerlinks['test'] = $skin->footerLink( 'test-desc', 'test-page' );
    }
}
// Add a link to this page (https://www.mediawiki.org/wiki/?curid=6031)
// test-desc is an i18n message of the text
public static function onSkinAddFooterLinks( Skin $skin, string $key, array &$footerlinks  ) {
    if ( $key === 'places' ) {
        $footerlinks['test'] = Html::rawElement( 'a',
            [
                'href' => 'https://www.mediawiki.org/wiki/?curid=6031',
                'rel' => 'noreferrer noopener' // not required, but recommended for security reasons
            ],
        $skin->msg( 'test-desc' )->text()
    }
}

See also