I make a pache of it with MediaWiki 1.34.1 and PHP 7.4.6 on FreeBSD.
Have fun!
--- HeadScript.php.org 2015-08-06 22:13:56.000000000 +0900
+++ HeadScript.php 2020-06-07 04:13:36.000000000 +0900
@@ -1,28 +1,31 @@
<?php
-$wgExtensionCredits[$type][] = array(
+if( !defined( 'MEDIAWIKI' ) ) {
+ echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
+ die( 1 );
+}
+
+$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => "HeadScript",
'description' => "Allows Scripts to be added just before </head> to the wiki as configured in the LocalSettings.php file.",
// 'descriptionmsg' => "",
- 'version' => 1.0,
+ 'version' => '1.0.1',
'author' => "JinRyuu",
'url' => "http://www.mediawiki.org/wiki/Extension:HeadScript",
+ 'license-name' => 'MIT'
);
-//Explicitly defining global variables
-
-$wgHeadScriptCode = '<!-- No Head Script -->';
-$wgHeadScriptName = '<!-- No Script Name -->';
-
//Code for adding the head script to the wiki
-
$wgHooks['BeforePageDisplay'][] = 'HeadScript';
+
function HeadScript( OutputPage &$out, Skin &$skin ) {
- global $wgHeadScriptCode, $wgHeadScriptName;
-
- $out->addHeadItem($wgHeadScriptName, $wgHeadScriptCode );
+ global $wgHeadScriptCode;
+
+ if( !empty( $wgHeadScriptCode ) ) {
+ $out->addHeadItem('HeadScript', $wgHeadScriptCode );
+ }
return TRUE;
}