| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Paystack WooCommerce Payment Gateway |
| 4 |
Plugin URI: https://paystack.com |
| 5 |
Description: WooCommerce payment gateway for Paystack |
| 6 |
Version: 3.1.0 |
| 7 |
Author: Tunbosun Ayinla |
| 8 |
Author URI: http://bosun.me |
| 9 |
License: GPL-2.0+ |
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
define( 'WC_PAYSTACK_MAIN_FILE', __FILE__ ); |
| 19 |
|
| 20 |
function tbz_wc_paystack_init() { |
| 21 |
|
| 22 |
if ( ! class_exists( 'WC_Payment_Gateway' ) ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
if ( class_exists( 'WC_Payment_Gateway_CC' ) ) { |
| 27 |
require_once dirname( __FILE__ ) . '/includes/class-paystack.php'; |
| 28 |
} else{ |
| 29 |
require_once dirname( __FILE__ ) . '/includes/class-paystack-deprecated.php'; |
| 30 |
} |
| 31 |
|
| 32 |
if ( class_exists( 'WC_Subscriptions_Order' ) && class_exists( 'WC_Payment_Gateway_CC' ) ) { require_once dirname( __FILE__ ) . '/includes/class-wc-subscriptions.php'; |
| 33 |
} |
| 34 |
|
| 35 |
require_once dirname( __FILE__ ) . '/includes/polyfill.php'; |
| 36 |
|
| 37 |
add_filter( 'woocommerce_payment_gateways', 'tbz_wc_add_paystack_gateway' ); |
| 38 |
|
| 39 |
} |
| 40 |
add_action( 'plugins_loaded', 'tbz_wc_paystack_init', 0 ); |
| 41 |
|
| 42 |
|
| 43 |
/** |
| 44 |
* Add Settings link to the plugin entry in the plugins menu |
| 45 |
**/ |
| 46 |
function tbz_woo_paystack_plugin_action_links( $links ) { |
| 47 |
|
| 48 |
$settings_link = array( |
| 49 |
'settings' => '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=paystack' ) . '" title="View Paystack WooCommerce Settings">Settings</a>' |
| 50 |
); |
| 51 |
|
| 52 |
return array_merge( $links, $settings_link ); |
| 53 |
|
| 54 |
} |
| 55 |
add_filter('plugin_action_links_' . plugin_basename( __FILE__ ), 'tbz_woo_paystack_plugin_action_links' ); |
| 56 |
|
| 57 |
|
| 58 |
/** |
| 59 |
* Add Paystack Gateway to WC |
| 60 |
**/ |
| 61 |
function tbz_wc_add_paystack_gateway( $methods ) { |
| 62 |
|
| 63 |
if ( class_exists( 'WC_Subscriptions_Order' ) && class_exists( 'WC_Payment_Gateway_CC' ) ) { |
| 64 |
$methods[] = 'Tbz_WC_Gateway_Paystack_Subscription'; |
| 65 |
} else { |
| 66 |
$methods[] = 'Tbz_WC_Paystack_Gateway'; |
| 67 |
} |
| 68 |
|
| 69 |
return $methods; |
| 70 |
|
| 71 |
} |