PluginProbe
Paystack WooCommerce Payment Gateway / 4.0.1
Paystack WooCommerce Payment Gateway v4.0.1
5.8.5 5.8.4 trunk 1.0.0 1.1.0 2.0.0 2.0.1 2.1.0 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 5.0.0 5.0.1 5.0.2 5.1.0 5.2.0 5.2.1 5.3.0 5.3.1 5.4.0 5.4.1 5.4.2 All 42 releases
woo-paystack / woo-paystack.php

woo-paystack.php in Paystack WooCommerce Payment Gateway 4.0.1, at woo-paystack.php

94 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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: 4.0.1
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 define( 'WC_PAYSTACK_VERSION', '4.0.1' );
21
22 function tbz_wc_paystack_init() {
23
24 if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
25 return;
26 }
27
28 if ( class_exists( 'WC_Payment_Gateway_CC' ) ) {
29 require_once dirname( __FILE__ ) . '/includes/class-paystack.php';
30 } else{
31 require_once dirname( __FILE__ ) . '/includes/class-paystack-deprecated.php';
32 }
33
34 if ( class_exists( 'WC_Subscriptions_Order' ) && class_exists( 'WC_Payment_Gateway_CC' ) ) {require_once dirname( __FILE__ ) . '/includes/class-wc-subscriptions.php';
35 }
36
37 require_once dirname( __FILE__ ) . '/includes/polyfill.php';
38
39 add_filter( 'woocommerce_payment_gateways', 'tbz_wc_add_paystack_gateway' );
40
41 }
42 add_action( 'plugins_loaded', 'tbz_wc_paystack_init', 0 );
43
44
45 /**
46 * Add Settings link to the plugin entry in the plugins menu
47 **/
48 function tbz_woo_paystack_plugin_action_links( $links ) {
49
50 $settings_link = array(
51 'settings' => '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=checkout&section=paystack' ) . '" title="View Paystack WooCommerce Settings">Settings</a>'
52 );
53
54 return array_merge( $links, $settings_link );
55
56 }
57 add_filter('plugin_action_links_' . plugin_basename( __FILE__ ), 'tbz_woo_paystack_plugin_action_links' );
58
59
60 /**
61 * Add Paystack Gateway to WC
62 **/
63 function tbz_wc_add_paystack_gateway( $methods ) {
64
65 if ( class_exists( 'WC_Subscriptions_Order' ) && class_exists( 'WC_Payment_Gateway_CC' ) ) {
66 $methods[] = 'Tbz_WC_Gateway_Paystack_Subscription';
67 } else {
68 $methods[] = 'Tbz_WC_Paystack_Gateway';
69 }
70
71 return $methods;
72
73 }
74
75
76 /**
77 * Display the testmode notice
78 **/
79 function tbz_wc_paystack_testmode_notice(){
80
81 $paystack_settings = get_option( 'woocommerce_paystack_settings' );
82
83 $enabled = $paystack_settings['testmode'];
84 $test_mode = $paystack_settings['enabled'];
85
86 if ( ( 'yes' == $test_mode ) && ( 'yes' == $enabled ) ) {
87 ?>
88 <div class="update-nag">
89 Paystack testmode is still enabled, Click <a href="<?php echo get_bloginfo('wpurl') ?>/wp-admin/admin.php?page=wc-settings&tab=checkout&section=paystack">here</a> to disable it when you want to start accepting live payment on your site.
90 </div>
91 <?php
92 }
93 }
94 add_action( 'admin_notices', 'tbz_wc_paystack_testmode_notice' );