Extension:MyVariables

This extension allows the addition of new built in variables. It currently adds three variables,,  and  , which serve as examples to follow when adding others for your own use.

This code is based on the method described in Manual:Magic words. To add a new magic word, add its name into the array on the first line, and add a case for it in the last function (wfGetCustomVariable) to calculate and return its value when it's requested.

Installation
Download the code and move it to your extensions directory. Then include it in your LocalSettings.php file as in the following example.

Testing

 * It works on all 1.6.x's
 * Works fine on 1.8.4 --Nad 05:14, 6 April 2007 (UTC)
 * Tested and working on 1.9.3 --Nad 05:08, 6 April 2007 (UTC)
 * Tested and working on 1.11.1 --DavidBiesack 16:18, 30 October 2008 (UTC)
 * Tested and working on 1.13.x --80.81.171.49 10:12, 19 November 2008 (UTC)
 * Tested and working on 1.14.0 --Subfader 20:17, 26 February 2009 (UTC)
 * Tested and working on 1.15.0 --Gregra 17:33, 6 August 2009 (UTC)
 * Tested and working on 1.16alpha --Subfader 23:20, 6 August 2009 (UTC)
 * Tested and working on 1.16.2 Leksey 16:26, 6 March 2011 (UTC)
 * Tested and working on 1.16.4 --Netsu 14:35, 19 April 2011 (UTC)
 * Tested and working on 1.16.5 --198.236.58.30 23:55, 1 June 2011 (UTC)
 * Tested and working on 1.17.0 --&#91;&#91;kgh&#93;&#93; 14:51, 23 June 2011 (UTC)
 * Tested and working on 1.18.0 --Badon (talk) 05:16, 4 March 2012 (UTC)
 * Tested and working on 1.18.1 --Ckong3309 12:24, 26 February 2012 (PST)
 * Tested and working on 1.18.2 --Dg.de (talk) 21:01, 14 April 2012 (UTC)
 * Tested, Not working on 1.19.0 (Remove "constant" at line "foreach($GLOBALS['wgCustomVariables'] as $var) $variables[] = constant("MAG_$var");" and it will work again ) --Albert Ke (talk) 18:13, 8 May 2012 (UTC)
 * Tested and working on 1.19.1 ("constant" was already removed from source code above - Thanks for the hint!) --Stefahn (talk) 21:49, 15 June 2012 (UTC)