Plugin.php
86 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Returns information about the package and handles init. |
| 4 | */ |
| 5 | |
| 6 | namespace GlobalPayments\WooCommercePaymentGatewayProvider; |
| 7 | |
| 8 | use GlobalPayments\WooCommercePaymentGatewayProvider\Gateways\HeartlandGateway; |
| 9 | use GlobalPayments\WooCommercePaymentGatewayProvider\Gateways\HeartlandGiftCards\HeartlandGiftGateway; |
| 10 | use GlobalPayments\WooCommercePaymentGatewayProvider\Gateways\HeartlandGiftCards\HeartlandGiftCardOrder; |
| 11 | |
| 12 | defined( 'ABSPATH' ) || exit; |
| 13 | |
| 14 | /** |
| 15 | * Main plugin class. |
| 16 | */ |
| 17 | class Plugin { |
| 18 | /** |
| 19 | * Version. |
| 20 | * |
| 21 | * @var string |
| 22 | */ |
| 23 | const VERSION = '1.1.0'; |
| 24 | |
| 25 | /** |
| 26 | * Init the package. |
| 27 | */ |
| 28 | public static function init() { |
| 29 | load_plugin_textdomain( 'globalpayments-gateway-provider-for-woocommerce', false, self::get_path() . '/languages' ); |
| 30 | |
| 31 | if ( ! class_exists( 'WC_Payment_Gateway' ) ) { |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | add_filter( 'woocommerce_payment_gateways', array( self::class, 'add_gateways' ) ); |
| 36 | add_action( 'woocommerce_order_actions', array( Gateways\AbstractGateway::class, 'addCaptureOrderAction' ) ); |
| 37 | add_action( 'woocommerce_order_action_capture_credit_card_authorization', array( Gateways\AbstractGateway::class, 'capture_credit_card_authorization' ) ); |
| 38 | |
| 39 | add_filter( 'admin_enqueue_scripts', array( Gateways\AbstractGateway::class, 'admin_enqueue_scripts' ) ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Appends our payment gateways to WooCommerce's known list |
| 44 | * |
| 45 | * @param string[] $methods |
| 46 | * |
| 47 | * @return string[] |
| 48 | */ |
| 49 | public static function add_gateways( $methods ) { |
| 50 | $gateways = array( |
| 51 | Gateways\HeartlandGateway::class, |
| 52 | Gateways\GeniusGateway::class, |
| 53 | Gateways\TransitGateway::class, |
| 54 | Gateways\GpApiGateway::class, |
| 55 | ); |
| 56 | |
| 57 | foreach ( $gateways as $gateway ) { |
| 58 | $methods[] = $gateway; |
| 59 | } |
| 60 | |
| 61 | return $methods; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Return the version of the package. |
| 66 | * |
| 67 | * @return string |
| 68 | */ |
| 69 | public static function get_version() { |
| 70 | return self::VERSION; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Return the path to the package. |
| 75 | * |
| 76 | * @return string |
| 77 | */ |
| 78 | public static function get_path() { |
| 79 | return dirname( __DIR__ ); |
| 80 | } |
| 81 | |
| 82 | public static function get_url( $path ) { |
| 83 | return plugins_url( $path, dirname( __FILE__ ) ); |
| 84 | } |
| 85 | } |
| 86 |