Extension:HeaderExtension/dtp

Category:MIT licensed extensions/dtp
MediaWiki extensions manual
HeaderExtension
Release status: stableCategory:Stable extensions/dtp
Implementation Hook Category:Hook extensions/dtp, MyWiki Category:Personalization extensions/dtp
Description Adds Scripts and Meta data just before the </head> tag of the wiki
Author(s)
Latest version 2.1.1 (2023-11-22)
MediaWiki 1.29+Category:Extensions with manual MediaWiki version/dtp
PHP 5.4+
Database changes No
License MIT License
Download Category:Extensions in GitHub version control/dtp
  • $wgHeadMetaName
  • $wgHeadMetaCode
  • $wgHeadScriptName
  • $wgHeadScriptCode
Category:All extensions/dtpCategory:Extensions not in ExtensionJson/dtp

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 Administrators 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.

Papadakat

  • Download and place the file(s) in a directory called HeaderExtension in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'HeaderExtension' );
    
  • Konfigurasi miagal di pinikionuon.
  • Yes DoneNavigate to Special:Version on your wiki to verify that the extension is successfully installed.

konfigurasi

One or more head scripts can be added to the wiki. The head scripts can consist of any HTML and/or JavaScript.

Skrip

Skim

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). Do not add whitespaces around the last line’s marker, it would break it (more details about this syntax). Tambaan nimungan wagu kalapas.

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 = 'add_your_script_name_here';

Pomitanan

Pomitanan (mantad Extension:Google Analytics Integration):

$wgHeadScriptCode = <<<'START_END_MARKER'
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-xxxxxxxx-xx', 'auto');
  ga('set', 'anonymizeIp', true);
  ga('send', 'pageview');
</script>
START_END_MARKER;
$wgHeadScriptName = 'googleanalytics';

Data model

Skim

To configure the head meta data, add the following to LocalSettings.php after the installation line:

$wgHeadMetaName = 'add_your_meta_data_name_here';
$wgHeadMetaCode = 'add_your_meta_data_code_here';

Pomitanan

Pomitanan (mantad Extension:AgeClassification):

$wgHeadMetaName = 'age-de-meta-label';
$wgHeadMetaCode = 'age=0 hash: yourdigitalcode v=1.0 kind=sl protocol=all';

Intangai po

Lolombus dii HeaderExtension kopiiso kogunoon mantad

Category:HTML head extensions/dtp
Category:All extensions/dtp Category:BeforePageDisplay extensions/dtp Category:Extensions in GitHub version control/dtp Category:Extensions not in ExtensionJson/dtp Category:Extensions with manual MediaWiki version/dtp Category:HTML head extensions/dtp Category:Hook extensions/dtp Category:MIT licensed extensions/dtp Category:Personalization extensions/dtp Category:Stable extensions/dtp