Jump to content

Extension talk:HeadScript/Flow

About this board

Slight changes need to support PHP 8.x

1
Harborsparrow (talkcontribs)

I just upgraded Citizendium to PHP 8.x and MediaWiki 1.39.x . The developer had to make some slight changes to the code for this extension in order to make it work with PHP 8.x. Is there someone here who could update this extension for others so that it will be available when other sites need it? I can be reached at manager A T citizendium.org

Reply to "Slight changes need to support PHP 8.x"

Maintenance of this extension

6
Seb35 (talkcontribs)

Given the number of comments on this talk page and on WikiApiary, it seems this extension is quite useful, the problem is that it is not really maintained and there will be probably more bugs over the years.

I’m wondering if it worth to put it in the common Wikimedia platform (Git+Gerrit+Phabricator), where maintenance will be easier. I will wait still a bit if the original author answers, else I will perhaps do the transfer. Any thought?

80.110.121.222 (talkcontribs)

I think it's a good idea!

Kghbln (talkcontribs)

I just changed the status to unmaintained. I guess it is time to transfer since the original author has not replied yet.

Cory (talkcontribs)

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;
 }
SamiWey (talkcontribs)

Muchas gracias puedo tener tu correo electronico?


StarHeartHunt (talkcontribs)

Since there are lots of work should be done to adapt new version of MediaWiki, I think it is necessary to do the transfer now.

Reply to "Maintenance of this extension"
Nicole Sharp (talkcontribs)
Reply to "license"

Can This Print <meta> Tags?

2
Z929669 (talkcontribs)

Will this print meta tags for SEO? I am using MW 1.21, and there don't seem to be any compatible extensions for that; however, this extension works fine for my GA script ... so was thinking I might be able to piggyback my meta tags as well.

Nicole Sharp (talkcontribs)

No. This is only for JavaScript (SCRIPT elements). I recommend WikiSEO or any number of similar MediaWiki extensions for adding META elements to HEAD. Nicole Sharp (talk) 07:55, 3 June 2019 (UTC)

Reply to "Can This Print <meta> Tags?"
Gryllida (talkcontribs)
Stefán Örvar Sigmundsson (talkcontribs)

I created a pull request half a month ago. Are you actively monitoring these extension repositories?

Nicole Sharp (talkcontribs)

Thanks for porting this to GitHub. It doesn't look like the original version from jingames.net by @JinRyuuNagy: has had any updates since November 2016, but the JinGames version still works on MediaWiki 1.31.1 LTS. Nicole Sharp (talk) 07:47, 3 June 2019 (UTC)

Reply to "git"

Instead of installing this extension...

3
WikiTeq (talkcontribs)

... which might be easier but also might cause problems, you could just add this to your LocalSettings.php:

$wgHooks['BeforePageDisplay'][] = function( OutputPage &$out, Skin &$skin ) {
     $code = <<<'START_END_MARKER'
<script></script>
<script></script>
<script></script>
START_END_MARKER;

     $out->addHeadItem( 'my-wonderful-script', $code );
     return true;
};

It does exactly the same thing as this extension.

104.142.125.214 (talkcontribs)

This grays out everything afterwards in LocalSettings.php in MediaWiki 32. Any idea how to fix?

104.142.125.214 (talkcontribs)
Reply to "Instead of installing this extension..."

different scripts for different pages

2
2001:16B8:305B:D400:12:F418:643D:B236 (talkcontribs)

i want to add different scripts to different pages, example the "mainpage" should have script A and all other sites should have script B. Is this possible?

0xMaker (talkcontribs)

jeah i want to do exactly the same thing. Would be nice if someone could help.

Reply to "different scripts for different pages"

Can I use the extension to place Fb's pixel on my wiki?

4
ZielonaMrowka (talkcontribs)

Hello! I wanted to add a Facebook's pixel to my wiki. It has to be placed in <head> of the website so I installed this extension and tried to add their script between <script></script> in LocalSettings.php. It does not work (I suppose that I'm placing the script in incorrect file :P) - probably "of course". The code after the </script> becomes grayed out (I use Notepad++) and colorizes back when I remove Fb's <script></script> body. The FB code looks as follows:

<script>
  !function(f,b,e,v,n,t,s)
  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
  n.callMethod.apply(n,arguments):n.queue.push(arguments)};
  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
  n.queue=[];t=b.createElement(e);t.async=!0;
  t.src=v;s=b.getElementsByTagName(e)[0];
  s.parentNode.insertBefore(t,s)}(window, document,'script',
  'https://connect.facebook.net/en_US/fbevents.js');
  fbq('init', 'I_probaby_shouldn't_share_the_number_that_was_here');
  fbq('track', 'PageView');
</script>

Is there a way to include it with this extension and no knowledge in php?

109.192.67.232 (talkcontribs)

Same Problem with Google AdWords Conversion Tracking Script

109.192.67.232 (talkcontribs)

The problem seems to be: If the script uses apostrophes, the extension doesn't work.

Seb35 (talkcontribs)

PHP has a special syntax to deal easily with this issue about apostrophes inside strings, it’s called Heredoc or Nowdoc syntax. I’ve added some instructions in the Configuration section. For your initial question, you can use it that way:

$wgHeadScriptCode = <<<'START_END_MARKER'
<script>
  !function(f,b,e,v,n,t,s)
  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
  n.callMethod.apply(n,arguments):n.queue.push(arguments)};
  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
  n.queue=[];t=b.createElement(e);t.async=!0;
  t.src=v;s=b.getElementsByTagName(e)[0];
  s.parentNode.insertBefore(t,s)}(window, document,'script',
  'https://connect.facebook.net/en_US/fbevents.js');
  fbq('init', 'I_probaby_shouldn't_share_the_number_that_was_here');
  fbq('track', 'PageView');
</script>
START_END_MARKER;
Reply to "Can I use the extension to place Fb's pixel on my wiki?"
Summary by Seb35

Was resolved, currently works.

Tapi0 (talkcontribs)

Link is not working.

Stefahn (talkcontribs)

Link still not working :/

Undefined variable

4
Summary by Seb35

Fix inside this discussion; added a section on the main page to help users facing this bug; message let to the author to fix it in the zip file.

Huwmanbeing (talkcontribs)

When I try to run maintenance/runJobs.php, I'm getting the following error:

PHP Notice:  Undefined variable: type in /var/www/eamon.wiki/public_html/mediawiki-1.30.0/extensions/HeadScript/HeadScript.php on line 3

I'm on MediaWiki 1.30.0 and have the latest HeadScript extension installed. Any idea what might be causing this problem? Huwmanbeing (talk) 18:04, 22 January 2018 (UTC)

John p new (talkcontribs)

HeadScript.php uses a (deprecated) array that adds the extension's information to the wiki's Special:Version page.

To fix the PHP error, in /path/to/mediawiki/extensions/HeadScript/HeadScript.php, change the following line (line 3):

$wgExtensionCredits[$type][] = array(

to

$wgExtensionCredits['specialpage'][] = array(

The developer simply forgot to replace $type with the proper value.

For a complete explanation of $wgExtensionCredits, see Manual:$wgExtensionCredits.

Huwmanbeing (talkcontribs)

That solved it. Thank you!

Djruess (talkcontribs)

That solved it for me too! I'm going to try and submit a change in the github repository.

Reply to "Undefined variable"
There are no older topics