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