From: Jack Phoenix Date: Sat, 14 Jul 2018 22:54:40 +0000 (+0300) Subject: New 'OutputPageAfterGetHeadLinksArray' hook, allowing extensions to modify the return... X-Git-Tag: 1.34.0-rc.0~4755^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%20%22id_auteur=%24id%22%29%20.%20%22?a=commitdiff_plain;h=0ed71cb0e051eb673e3418667428c5cfddc929cf;p=lhc%2Fweb%2Fwiklou.git New 'OutputPageAfterGetHeadLinksArray' hook, allowing extensions to modify the return value of OutputPage#getHeadLinksArray Code from wikiHow codebase, where this hook is used by the following extensions: * AlternateDomain -- used to remove certain links altogether and change the contents of other elements (e.g. ) * hooks (PageHooks) -- used to hide certain links for anons on noindexed pages to avoid leaking article info to Googlebot * QADomain -- used to remove certain elements and correct tags not to mention "wikiHow" if that string is present * search (LSearch) -- used to remove canonical URL on Special:LSearch for SEO Change-Id: I4a9ceb343bb5c0b4eb79e4589d36c3790938f8a9 --- diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index 5110e5190d..da317de8c1 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -53,6 +53,9 @@ production. pages. * The array of hidden options ($opts) passed to the 'SpecialSearchPowerBox' hook is now passed by reference, allowing extensions to modify or even unset it. +* Added new 'OutputPageAfterGetHeadLinksArray' hook, allowing extensions to + modify the return value of OutputPage#getHeadLinksArray in order to add, + remove or otherwise alter the elements to be output in the page . === External library changes in 1.32 === * … diff --git a/docs/hooks.txt b/docs/hooks.txt index c7874c33af..fff5b240d0 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2439,6 +2439,12 @@ users and/or IP addresses too. &$otherBlockLink: An array with links to other block logs $ip: The requested IP address or username +'OutputPageAfterGetHeadLinksArray': Called in OutputPage#getHeadLinksArray right +before returning the result. +&$tags: array containing all links generated so far. The array format is +"link name or number => 'link HTML'". +$out: the OutputPage object + 'OutputPageBeforeHTML': A page has been processed by the parser and the resulting HTML is about to be displayed. &$parserOutput: the parserOutput (object) that corresponds to the page diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 34de7c6584..5965cbe7c2 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -3530,6 +3530,13 @@ class OutputPage extends ContextSource { ] ); } + // Allow extensions to add, remove and/or otherwise manipulate these links + // If you want only to *add* links, please use the addHeadItem() + // (or addHeadItems() for multiple items) method instead. + // This hook is provided as a last resort for extensions to modify these + // links before the output is sent to client. + Hooks::run( 'OutputPageAfterGetHeadLinksArray', [ &$tags, $this ] ); + return $tags; }