3 # Guard against direct invocation from the web, print a friendly help message
5 if ( !defined( 'MEDIAWIKI' ) ) {
8 <p>This is the Parser_function example extension. To enable it, put the
9 following in your LocalSettings.php:</p>
11 require_once( "\$IP/extensions/examples/Parser_function.php" );
17 # Define a setup function
18 $wgExtensionFunctions[] = 'wfExampleParserFunction_Setup';
19 # Add a hook to initialise the magic word
20 $wgHooks['LanguageGetMagic'][] = 'wfExampleParserFunction_Magic';
22 function wfExampleParserFunction_Setup() {
24 # Set a function hook associating the "example" magic word with our function
25 $wgParser->setFunctionHook( 'example', 'wfExampleParserFunction_Render' );
28 function wfExampleParserFunction_Magic( &$magicWords, $langCode ) {
30 # The first array element is case sensitivity, in this case it is not case sensitive
31 # All remaining elements are synonyms for our parser function
32 $magicWords['example'] = array( 0, 'example' );
36 function wfExampleParserFunction_Render( &$parser, $param1 = '', $param2 = '' ) {
37 # The parser function itself
38 # The input parameters are wikitext with templates expanded
39 # The output should be wikitext too
40 return "param1 is $param1 and param2 is $param2";