Move from function globals to a class
authorPlatonides <platonides@gmail.com>
Sun, 7 Jan 2018 21:11:49 +0000 (22:11 +0100)
committerPlatonides <platonides@gmail.com>
Sun, 7 Jan 2018 21:31:51 +0000 (22:31 +0100)
Paypal-wmes.php [changed mode: 0755->0644]
Paypal-wmes_body.php [new file with mode: 0755]

old mode 100755 (executable)
new mode 100644 (file)
index 38e4f6d..495b3c4
@@ -1,19 +1,4 @@
 <?php
 
-$wgHooks['ParserFirstCallInit'][] = 'efSetupPaypalWMES';
-
-function efSetupPaypalWMES(&$parser) {
-  $parser->setHook( 'paypal wm-es', 'efHookPaypalWMES' );
-  return true;
-}
-
-function efHookPaypalWMES( $input, array $args, Parser $parser, PPFrame $frame ) {
-  global $wgExtensionAssetsPath;
-  return '
-<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
-<input name="cmd" type="hidden" value="_s-xclick" />
-<input name="hosted_button_id" type="hidden" value="G5QN39QKQGMNE" />
-<input alt="PayPal. La forma rápida y segura de pagar en Internet." name="submit"
-src="' . htmlspecialchars( "$wgExtensionAssetsPath/Paypal-wmes/PayPal_button.gif" ) . '" type="image" />
-</form>';
-}
+$wgHooks['ParserFirstCallInit'][] = 'PaypalWMES::setup';
+$wgAutoloadClasses['PaypalWMES'] = __DIR__ . "/Paypal-wmes_body.php";
diff --git a/Paypal-wmes_body.php b/Paypal-wmes_body.php
new file mode 100755 (executable)
index 0000000..df96700
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+class PaypalWMES {
+       public static function setup(&$parser) {
+               $parser->setHook( 'paypal wm-es', 'PaypalWMES::hook' );
+               return true;
+       }
+
+       public static function hook( $input, array $args, Parser $parser, PPFrame $frame ) {
+               global $wgExtensionAssetsPath;
+               return '
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
+<input name="cmd" type="hidden" value="_s-xclick" />
+<input name="hosted_button_id" type="hidden" value="G5QN39QKQGMNE" />
+<input alt="PayPal. La forma rápida y segura de pagar en Internet." name="submit"
+src="' . htmlspecialchars( "$wgExtensionAssetsPath/Paypal-wmes/PayPal_button.gif" ) . '" type="image" />
+</form>';
+       }
+}
+