<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mwiki.costasano.club/index.php?action=history&amp;feed=atom&amp;title=ICT%3AHooks_%E2%80%93_How_Hooks_Work_in_MediaWiki</id>
	<title>ICT:Hooks – How Hooks Work in MediaWiki - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mwiki.costasano.club/index.php?action=history&amp;feed=atom&amp;title=ICT%3AHooks_%E2%80%93_How_Hooks_Work_in_MediaWiki"/>
	<link rel="alternate" type="text/html" href="https://mwiki.costasano.club/index.php?title=ICT:Hooks_%E2%80%93_How_Hooks_Work_in_MediaWiki&amp;action=history"/>
	<updated>2026-07-23T01:07:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://mwiki.costasano.club/index.php?title=ICT:Hooks_%E2%80%93_How_Hooks_Work_in_MediaWiki&amp;diff=560&amp;oldid=prev</id>
		<title>Mngr: Created page with &quot;= ICT:Hooks – How Hooks Work in MediaWiki = This page explains how MediaWiki’s hook system works, where hook parameters such as &lt;code&gt;$skin&lt;/code&gt;, &lt;code&gt;$bar&lt;/code&gt;, and &lt;code&gt;$links&lt;/code&gt; come from, and how administrators can look up the official documentation for each hook.  This page is intended for future stewards of the archive infrastructure.  ----  == 1. What a Hook Is == A &#039;&#039;&#039;hook&#039;&#039;&#039; is a point inside MediaWiki’s execution flow where custom PHP code can r...&quot;</title>
		<link rel="alternate" type="text/html" href="https://mwiki.costasano.club/index.php?title=ICT:Hooks_%E2%80%93_How_Hooks_Work_in_MediaWiki&amp;diff=560&amp;oldid=prev"/>
		<updated>2026-02-11T18:30:19Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;= ICT:Hooks – How Hooks Work in MediaWiki = This page explains how MediaWiki’s hook system works, where hook parameters such as &amp;lt;code&amp;gt;$skin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;$bar&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;$links&amp;lt;/code&amp;gt; come from, and how administrators can look up the official documentation for each hook.  This page is intended for future stewards of the archive infrastructure.  ----  == 1. What a Hook Is == A &amp;#039;&amp;#039;&amp;#039;hook&amp;#039;&amp;#039;&amp;#039; is a point inside MediaWiki’s execution flow where custom PHP code can r...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= ICT:Hooks – How Hooks Work in MediaWiki =&lt;br /&gt;
This page explains how MediaWiki’s hook system works, where hook parameters such as &amp;lt;code&amp;gt;$skin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;$bar&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;$links&amp;lt;/code&amp;gt; come from, and how administrators can look up the official documentation for each hook.&lt;br /&gt;
&lt;br /&gt;
This page is intended for future stewards of the archive infrastructure.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 1. What a Hook Is ==&lt;br /&gt;
A &amp;#039;&amp;#039;&amp;#039;hook&amp;#039;&amp;#039;&amp;#039; is a point inside MediaWiki’s execution flow where custom PHP code can run.&lt;br /&gt;
&lt;br /&gt;
MediaWiki internally calls:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
Hooks::run( &amp;#039;HookName&amp;#039;, [ $param1, $param2, ... ] );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Your code registers a function to be executed at that moment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$wgHooks[&amp;#039;HookName&amp;#039;][] = function ( $param1, $param2 ) {&lt;br /&gt;
    # custom logic&lt;br /&gt;
    return true;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returning &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; tells MediaWiki to continue normal processing.  &lt;br /&gt;
Returning &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; stops further handlers.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 2. Where Do Parameters Like &amp;lt;code&amp;gt;$skin&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;$bar&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;$links&amp;lt;/code&amp;gt; Come From ==&lt;br /&gt;
Each hook defines:&lt;br /&gt;
&lt;br /&gt;
* how many parameters it passes  &lt;br /&gt;
* what type each parameter is  &lt;br /&gt;
* whether parameters are passed by reference  &lt;br /&gt;
* what you are allowed to modify  &lt;br /&gt;
&lt;br /&gt;
This information is published in the official MediaWiki hook documentation.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
=== SkinBuildSidebar ===&lt;br /&gt;
* Documentation: https://www.mediawiki.org/wiki/Manual:Hooks/SkinBuildSidebar&lt;br /&gt;
* Parameters:&lt;br /&gt;
  * &amp;lt;code&amp;gt;$skin&amp;lt;/code&amp;gt; — instance of &amp;lt;code&amp;gt;Skin&amp;lt;/code&amp;gt; or a subclass (e.g., &amp;lt;code&amp;gt;SkinVector&amp;lt;/code&amp;gt;)&lt;br /&gt;
  * &amp;lt;code&amp;gt;&amp;amp;$bar&amp;lt;/code&amp;gt; — associative array representing the sidebar sections&lt;br /&gt;
&lt;br /&gt;
=== SkinTemplateNavigation::Universal ===&lt;br /&gt;
* Documentation: https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateNavigation::Universal&lt;br /&gt;
* Parameters:&lt;br /&gt;
  * &amp;lt;code&amp;gt;$skin&amp;lt;/code&amp;gt; — instance of &amp;lt;code&amp;gt;SkinTemplate&amp;lt;/code&amp;gt;&lt;br /&gt;
  * &amp;lt;code&amp;gt;&amp;amp;$links&amp;lt;/code&amp;gt; — nested array containing the action tabs (views, actions, variants)&lt;br /&gt;
&lt;br /&gt;
These pages define exactly what the objects contain and how they may be modified.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 3. How to Read Hook Documentation ==&lt;br /&gt;
Every hook page on mediawiki.org includes:&lt;br /&gt;
&lt;br /&gt;
* a description of when the hook fires  &lt;br /&gt;
* a list of parameters  &lt;br /&gt;
* the PHP types of each parameter  &lt;br /&gt;
* examples of usage  &lt;br /&gt;
* notes about return values  &lt;br /&gt;
&lt;br /&gt;
Example from the documentation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * @param Skin $skin&lt;br /&gt;
 * @param array &amp;amp;$bar&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This tells you:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;$skin&amp;lt;/code&amp;gt; is a &amp;lt;code&amp;gt;Skin&amp;lt;/code&amp;gt; object  &lt;br /&gt;
* &amp;lt;code&amp;gt;$bar&amp;lt;/code&amp;gt; is an array passed by reference  &lt;br /&gt;
* modifying &amp;lt;code&amp;gt;$bar&amp;lt;/code&amp;gt; changes the sidebar  &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 4. Why Hooks Are Used in LocalSettings.php ==&lt;br /&gt;
Hooks allow you to:&lt;br /&gt;
&lt;br /&gt;
* hide or modify UI elements  &lt;br /&gt;
* enforce role‑based behavior  &lt;br /&gt;
* override default navigation  &lt;br /&gt;
* add or remove actions  &lt;br /&gt;
* customize rendering without modifying core files  &lt;br /&gt;
&lt;br /&gt;
They are the official, stable way to extend MediaWiki.&lt;br /&gt;
&lt;br /&gt;
All hook code in &amp;lt;code&amp;gt;LocalSettings.php&amp;lt;/code&amp;gt; is standard PHP.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 5. Example: Understanding the Parameters ==&lt;br /&gt;
=== Example 1: SkinBuildSidebar ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
function ( $skin, &amp;amp;$bar ) { ... }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;$skin&amp;lt;/code&amp;gt; → gives access to:&lt;br /&gt;
  * &amp;lt;code&amp;gt;$skin-&amp;gt;getUser()&amp;lt;/code&amp;gt;&lt;br /&gt;
  * &amp;lt;code&amp;gt;$skin-&amp;gt;getTitle()&amp;lt;/code&amp;gt;&lt;br /&gt;
  * &amp;lt;code&amp;gt;$skin-&amp;gt;getSkinName()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;$bar&amp;lt;/code&amp;gt; → the sidebar structure:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$bar = [&lt;br /&gt;
    &amp;#039;navigation&amp;#039; =&amp;gt; [&lt;br /&gt;
        [ &amp;#039;text&amp;#039; =&amp;gt; &amp;#039;Main Page&amp;#039;, &amp;#039;href&amp;#039; =&amp;gt; &amp;#039;/wiki/Main_Page&amp;#039; ],&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;#039;tools&amp;#039; =&amp;gt; [ ... ],&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Example 2: SkinTemplateNavigation::Universal ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
function ( $skin, &amp;amp;$links ) { ... }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;$links&amp;lt;/code&amp;gt; contains the action tabs:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$links = [&lt;br /&gt;
    &amp;#039;views&amp;#039; =&amp;gt; [&lt;br /&gt;
        &amp;#039;edit&amp;#039; =&amp;gt; [ &amp;#039;text&amp;#039; =&amp;gt; &amp;#039;Edit&amp;#039;, &amp;#039;href&amp;#039; =&amp;gt; ... ],&lt;br /&gt;
        &amp;#039;history&amp;#039; =&amp;gt; [ ... ],&lt;br /&gt;
    ],&lt;br /&gt;
    &amp;#039;actions&amp;#039; =&amp;gt; [&lt;br /&gt;
        &amp;#039;delete&amp;#039; =&amp;gt; [ ... ],&lt;br /&gt;
        &amp;#039;move&amp;#039; =&amp;gt; [ ... ],&lt;br /&gt;
    ],&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 6. How to Find Any Hook ==&lt;br /&gt;
All hooks are listed here:&lt;br /&gt;
&lt;br /&gt;
* https://www.mediawiki.org/wiki/Manual:Hooks&lt;br /&gt;
&lt;br /&gt;
Each hook page includes:&lt;br /&gt;
&lt;br /&gt;
* purpose  &lt;br /&gt;
* parameters  &lt;br /&gt;
* examples  &lt;br /&gt;
* version notes  &lt;br /&gt;
&lt;br /&gt;
This is the authoritative reference for understanding hook parameters.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== 7. Why This Matters for Successors ==&lt;br /&gt;
Understanding hooks ensures that future stewards can:&lt;br /&gt;
&lt;br /&gt;
* safely modify UI behavior  &lt;br /&gt;
* understand why certain elements are hidden  &lt;br /&gt;
* maintain or extend the decluttered interface  &lt;br /&gt;
* avoid modifying core files or skins  &lt;br /&gt;
* keep the system stable and upgrade‑friendly  &lt;br /&gt;
&lt;br /&gt;
This page provides the conceptual foundation needed to understand the hook‑based customizations used in the archive infrastructure.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;This page is part of the ICT documentation set for the archive infrastructure.&amp;#039;&amp;#039;&lt;/div&gt;</summary>
		<author><name>Mngr</name></author>
	</entry>
</feed>