Change "global $wgParser" to "$GLOBALS['wgParser']" (1 line).