' . sprintf( '8Pay requires WooCommerce to be installed and active. You can download %s here.', 'WooCommerce' ) . '

'; } /** * WooCommerce not supported fallback notice. */ function woocommerce_8pay_wc_not_supported() { echo '

' . sprintf( '8Pay requires WooCommerce %s or greater to be installed and active.', WC_8PAY_MIN_WC_VERSION ) . '

'; } function woocommerce_gateway_8pay() { static $plugin; if ( ! isset( $plugin ) ) { class WC_8Pay { /** * The *Singleton* instance of this class * * @var Singleton */ private static $instance; /** * Returns the *Singleton* instance of this class. * * @return Singleton The *Singleton* instance. */ public static function get_instance() { if ( ! self::$instance ) { self::$instance = new self(); } return self::$instance; } /** * Private clone method to prevent cloning of the instance of the * *Singleton* instance. * * @return void */ public function __clone() {} /** * Private unserialize method to prevent unserializing of the *Singleton* * instance. * * @return void */ public function __wakeup() {} /** * Protected constructor to prevent creating a new instance of the * *Singleton* via the `new` operator from outside of this class. */ public function __construct() { $this->init(); } /** * Init the plugin after plugins_loaded so environment variables are set. */ public function init() { require_once dirname( __FILE__ ) . '/includes/8pay-api/class-wc-8pay-api.php'; require_once dirname( __FILE__ ) . '/includes/8pay-api/class-wc-8pay-auth.php'; require_once dirname( __FILE__ ) . '/includes/exceptions/class-wc-8pay-bad-request-exception.php'; require_once dirname( __FILE__ ) . '/includes/exceptions/class-wc-8pay-invalid-access-token-exception.php'; require_once dirname( __FILE__ ) . '/includes/exceptions/class-wc-8pay-not-found-exception.php'; require_once dirname( __FILE__ ) . '/includes/utils/class-wc-8pay-billing-model.php'; require_once dirname( __FILE__ ) . '/includes/utils/class-wc-8pay-chain.php'; require_once dirname( __FILE__ ) . '/includes/utils/class-wc-8pay-token.php'; require_once dirname( __FILE__ ) . '/includes/utils/class-wc-8pay-webhook-notification-type.php'; require_once dirname( __FILE__ ) . '/includes/class-wc-8pay-helper.php'; require_once dirname( __FILE__ ) . '/includes/class-wc-8pay-logger.php'; require_once dirname( __FILE__ ) . '/includes/class-wc-8pay-rates.php'; require_once dirname( __FILE__ ) . '/includes/class-wc-8pay-webhook-handler.php'; require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-8pay.php'; if ( is_admin() ) { require_once dirname( __FILE__ ) . '/includes/admin/class-wc-8pay-admin-notices.php'; } add_filter( 'woocommerce_payment_gateways', [ $this, 'add_gateways' ] ); add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), [ $this, 'plugin_action_links' ] ); add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 ); } /** * Add the gateways to WooCommerce. */ public function add_gateways( $methods ) { $methods[] = 'WC_Gateway_8Pay'; return $methods; } /** * Add plugin action links. */ public function plugin_action_links( $links ) { $plugin_links = [ 'Settings', ]; return array_merge( $plugin_links, $links ); } /** * Add plugin row meta. */ public function plugin_row_meta( $links, $file ) { if ( plugin_basename( __FILE__ ) === $file ) { $row_meta = [ 'docs' => 'Docs', ]; return array_merge( $links, $row_meta ); } return (array) $links; } } $plugin = WC_8Pay::get_instance(); } return $plugin; } add_action( 'plugins_loaded', 'woocommerce_gateway_8pay_init' ); function woocommerce_gateway_8pay_init() { if ( ! class_exists( 'WooCommerce' ) ) { add_action( 'admin_notices', 'woocommerce_8pay_missing_wc_notice' ); return; } if ( version_compare( WC_VERSION, WC_8PAY_MIN_WC_VERSION, '<' ) ) { add_action( 'admin_notices', 'woocommerce_8pay_wc_not_supported' ); return; } woocommerce_gateway_8pay(); }