Manual:Extensions

Installing an extension
At the end of the LocalSettings.php file, (above the "?>"), the following code is added:

require_once "$IP/extensions/extension_name/extension_name.setup.php";

or alternatively, instead of "require_once": "require", "include", or "include_once".

"require" and "include" are identical except that in the case of failure, "include" produces a warning while "require" produces a fatal error.

"include_once" and "require_once" are used in cases where the same file might be included and evaluated more than once in one run, to avoid repeated inclusion, which may e.g. give problems with function redefinitions.

While an extension can be a single file, it is recommended that for each extension a separate subdirectory extension_name of the extensions directory is created with three files:
 * a small setup file extension_name.setup.php
 * an internationalisation file extension_name.i18n.php
 * a file extension_name.body.php with the bulk of the code

The setup file adds an element to the array $wgAutoloadClasses of files to be loaded:

$wgAutoloadClasses[extension_name] = dirname(__FILE__). '/extension_name.body.php';

Special:Version
Special:Version, defined in SpecialVersion.php, categorizes extensions as follows (and lists them in this order):


 * Special pages
 * Parser hooks - the name in the list is one that is separately specified in the extension, in the array $wgExtensionCredits, so not necessarily exactly the name of a tag, parser function, or PHP function.
 * Variables
 * Other
 * Extension functions - These are the setup functions called before any specific action takes place (such as parsing a page for viewing), to define various functions in preparation of using them. For example, it connects parser function IDs to PHP functions.
 * Parser extension tags - XML-style tags  some text
 * Parser function hooks -
 * Skin extension functions

There is a separate section Hooks. The first column shows the hook name, e.g. LanguageGetMagic, and the second column list the functions which subscribe to this hook; in the case of hook LanguageGetMagic the function name is usually of the form "wf...LanguageGetMagic". These functions define for each language and each extension function ID all magic words that can be used in the wikitext to refer to the function.

Some extensios call $wgParser->setHook without adding anything to array $wgHooks. They are not listed here.