Extension:HeaderExtension/pl
Status wydania: stabilne |
|
|---|---|
| Realizacja | Hak, MyWiki |
| Opis | Adds Scripts and Meta data just before the </head> tag of the wiki |
| Autor(zy) |
|
| Ostatnia wersja | 3.1.0 (2026-04-22) |
| Polityka zgodności | Master utrzymuje kompatybilność wsteczną. |
| MediaWiki | 1.35+ |
| PHP | 7.3.19+ |
| Zmiany w bazie danych | Nie |
|
|
|
| Licence | Licencja MIT |
| Pobieranie | README CHANGELOG |
The HeaderExtension extension allows Scripts and Meta data to easily be added just before the </head> tag of the wiki.
The code for the head Scripts and Meta data are defined in "LocalSettings.php" and is controlled by variables.
This implementation makes it easy for inexperienced users to implement head Scripts and Meta data just before the </head> tag of the wiki.
It also makes it possible to add head Scripts and Meta data that cannot be changed or removed, such as would be possible by wiki Administratorzy if the head Scripts and Meta data were added to the Sitenotice.
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.
Instalacja
- Pobierz i umieść plik(i) w katalogu o nazwie
HeaderExtensionw folderzeextensions/. - Dodaj poniższy kod na dole twojego pliku LocalSettings.php:
wfLoadExtension( 'HeaderExtension' );
- Configure as required.
Zrobione – Przejdź do Special:Versionna twojej wiki, aby sprawdzić czy rozszerzenie zostało pomyślnie zainstalowane.
Konfiguracja
One or more head scripts can be added to the wiki. The head scripts can consist of any HTML and/or JavaScript.
Scripts
Scheme
To configure the head script, add the following to LocalSettings.php after the installation line:
(Since Version 3.1)
$wgHeaderHeadItems = [
'<script>Script example 1 here</script>',
'<script>Script example 2 here</script>'
];
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). Do not add whitespaces around the last line’s marker, it would break it (more details about this syntax). Do add new line after.
Examples
Examples:
$_GoogleAnalyticsId = 'your_code';
$wgHeaderHeadItems = [
'<script async src="https://www.googletagmanager.com/gtag/js?id=' . $_GoogleAnalyticsId . '"></script>',
'<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag("js", new Date());
gtag("config", "' . $_GoogleAnalyticsId . '");
</script>',
'<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=' . $_GoogleAnalyticsId . '" height="0" width="0" style="display:none;visibility:hidden"></iframe>'
];
$wgHeaderHeadItems = [
'<meta name="robots" content="noarchive" />'
];
Meta data
Scheme
To configure the head meta data, add the following to LocalSettings.php after the installation line:
(Since Version 3.1)
$wgHeaderMetaItems[ 'meta_key_1' ] = 'Meta example 1 here';
$wgHeaderMetaItems[ 'meta_key_2' ] = 'Meta example 2 here';
Examples
Example (from Extension:AgeClassification):
$wgHeaderMetaItems = [
[ 'age-de-meta-label', 'age=0 hash: yourdigitalcode v=1.0 kind=sl protocol=all' ],
[ 'robots', 'noarchive' ]
];
Zobacz też
The extension HeaderExtension combines functionality from
