-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathseerbit-payment.php
120 lines (104 loc) · 3.86 KB
/
seerbit-payment.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/*
Plugin Name: SeerBit payment gateway plugin For WooCommerce
Description: Start accepting payments on your WooCommerce store using SeerBit for WooCommerce plugin.
Tags: SeerBit payment, SeerBit, payment, payment gateway, online payments, pay now, buy now, e-commerce, gateway, Nigeria, Africa, Ghana
Author: SeerBit
Version: 1.4.0
Author URI: https://seerbit.com
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Requires at least:
Tested up to: 6.7.1
Stable tag: 1.4.0
*/
use Automattic\WooCommerce\Admin\Notes\Note;
use Automattic\WooCommerce\Admin\Notes\Notes;
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
if (!defined('ABSPATH')) {
exit;
}
define( 'WC_SEERBIT_FILE', __FILE__ );
define( 'WC_SEERBIT_URL', untrailingslashit( plugins_url( '/', __FILE__ ) ) );
define( 'WC_SEERBIT_VERSION', '1.4.0' );
/**
* Initialize Seerbit WooCommerce payment gateway.
*/
function seerbit_payment_init()
{
// load_plugin_textdomain('seerbit-payment', false, plugin_basename(dirname(__FILE__)) . '/languages');
if (class_exists('WC_Payment_Gateway_CC')) {
require_once dirname(__FILE__) . '/includes/class-wc-gateway-seerbit.php';
}
add_filter('woocommerce_payment_gateways', 'wc_add_seerbit_gateway', 99);
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'seerbit_payment_plugin_action_links');
}
add_action('plugins_loaded', 'seerbit_payment_init', 99);
add_action("admin_enqueue_scripts", "loadseerbitpluginstyle");
function loadseerbitpluginstyle()
{
wp_enqueue_style('seerbit_style_semantic', plugins_url('assets/css/style.css', __FILE__));
}
/**
* Add Settings link to the plugin entry in the plugins menu.
*
* @param array $links Plugin action links.
*
* @return array
**/
function seerbit_payment_plugin_action_links($links)
{
$settings_link = array(
'settings' => '<a href="' . admin_url('admin.php?page=wc-settings&tab=checkout§ion=seerbit') . '" title="' . __('View SeerBit WooCommerce Settings', 'seerbit-payment') . '">' . __('Settings', 'seerbit-payment') . '</a>',
);
return array_merge($settings_link, $links);
}
/**
* Add Seerbit Gateway to WooCommerce.
*
* @param array $methods WooCommerce payment gateways methods.
*
* @return array
*/
function wc_add_seerbit_gateway($methods)
{
if ( ! class_exists( 'WC_Payment_Gateway' ) )
{
add_action( 'admin_notices', 'seerbit_payment_wc_missing_notice' );
return;
}
if (class_exists('WC_Payment_Gateway_CC'))
{
$methods[] = 'WC_Gateway_Seerbit';
} else {
$methods[] = 'WC_Gateway_Seerbit';
}
return $methods;
}
/**
* Display a notice if WooCommerce is not installed
*/
function seerbit_payment_wc_missing_notice()
{
echo '<div class="error"><p><strong>' . sprintf(__('SeerBit requires WooCommerce to be installed and active. Click %s to install WooCommerce.', 'seerbit-payment'), '<a href="' . admin_url('plugin-install.php?tab=plugin-information&plugin=woocommerce&TB_iframe=true&width=772&height=539') . '" class="thickbox open-plugin-details-modal">here</a>') . '</strong></p></div>';
}
add_action(
'before_woocommerce_init',
function () {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
}
);
function seerbit_woocommerce_block_support() {
if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) {
require_once __DIR__ . '/includes/class-wc-gateway-seerbit-blocks-support.php';
add_action(
'woocommerce_blocks_payment_method_type_registration',
static function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) {
$payment_method_registry->register( new WC_Gateway_SeerBit_Blocks_Support() );
}
);
}
}
add_action( 'woocommerce_blocks_loaded', 'seerbit_woocommerce_block_support' );