This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored.
Release status: unmaintained
|Description||Adds scripts just before </head> of the wiki that are defined in LocalSettings.php|
|Latest version||1.0 (2015-08-06)|
|License||GNU General Public License 2.0|
|Translate the HeadScript extension if it is available at translatewiki.net|
|Check usage and version matrix.|
The HeadScript extension allows scripts to easily be added just before
</head> of the wiki.
The code for the head script is defined in "LocalSettings.php" and is controlled by variables. This implementation makes it easy for inexperienced users to implement head scripts just before
</head> of the wiki. It also makes it possible to add head scripts that cannot be changed or removed, such as would be possible by wiki administrators if the head script were added to the site notice. This makes the extension particularly useful for placing Cookie Consent plugin or CSS style links, as such content cannot be removed by abusive or rogue administrators.
- Download and extract and place the file(s) in a directory called
- Add the following code at the bottom of your LocalSettings.php:
- Configure as required.
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
To configure the head script, add the following to "LocalSettings.php" after the installation line:
$wgHeadScriptCode = <<<'START_END_MARKER' <script></script> START_END_MARKER;
Leave untouched the first and last line with START_END_MARKER stuff, this is a special syntax of PHP (without it, it would be tricky to deal with apostrophes inside the script). Don’t add whitespaces around the last line’s marker, it would break it (more details about this syntax). Do add new line after.
To add additional scripts, simply include them between the markers:
$wgHeadScriptCode = <<<'START_END_MARKER' <script></script> <script></script> <script></script> START_END_MARKER;
You may specify a name for the script too if needed, add the following after the installation line:
$wgHeadScriptName = 'my-wonderful-script';
You may see a warning when you execute this extension, something like
PHP Notice: Undefined variable: type in /mediawiki/extensions/HeadScript/HeadScript.php on line 3, this is a small bug. You can fix it by editing HeadScript.php and changing the line
$wgExtensionCredits[$type] = array(
by the following line ($type is replaced by 'other')
$wgExtensionCredits['other'] = array(