forked from jimiejosh/monnify-wordpress-plugin
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmonnify-official.php
More file actions
executable file
·133 lines (93 loc) · 4.31 KB
/
monnify-official.php
File metadata and controls
executable file
·133 lines (93 loc) · 4.31 KB
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
120
121
122
123
124
125
126
<?php
/**
* Plugin Name: Monnify Official WooCommerce Payment Gateway
* Plugin URI: https://github.com/Monnify/monnify-wordpress-plugin
* Description: Monnify Official WooCommerce Payment Gateway allows you to integrate Monnify Payment to your WordPress Website. Supports various Monnify payment method options such as Pay with Transfer, Pay with Card, Pay with USSD, Pay with Phone Number.
* Author: Monnify Integrations Team
* Author URI: https://monnify.com
* Version: 1.0.3
* Text Domain: monnify-official
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Monnify Official WooCommerce Payment Gateway provides a seamless payment experience for your customers on your WordPress website.
*/
if (!defined('ABSPATH') ) {
exit;
}
define("WC_MONNIFY_VERSION", "1.0.3");
define('WC_MONNIFY_MAIN_FILE', __FILE__);
define('WC_MONNIFY_URL', untrailingslashit(plugins_url('/', __FILE__)));
add_action( 'admin_init', 'monnify_validate_installed_woocommerce' );
/*
* This action hook registers our PHP class as a WooCommerce payment gateway
*/
add_filter('woocommerce_payment_gateways', 'monnify_add_gateway_class');
function monnify_add_gateway_class($gateways)
{
$gateways[] = "WC_Monnify_Gateway";
return $gateways;
}
function monnify_woocommerce_notice()
{
echo '<div class="error"><p><strong>Monnify WooCommerce Payment Gateway requires WooCommerce to be installed and active.</strong></p></div>';
$plugin_config = get_option('woocommerce_monnify_settings');
if ( isset($plugin_config['testmode']) ? (($plugin_config['testmode'] === 'yes')? true: false) : false ) {
echo '<div class="error"><p>' .
sprintf(
// translators: %1$s is the link to the plugin settings page.
esc_html__(
'Monnify Woocommerce is on Test mode, go to %1$s to disable Test mode and start accepting live payments on your website.',
'monnify-official'
),
'<strong><a href="' . esc_url(admin_url('admin.php?page=wc-settings&tab=checkout§ion=monnify')) . '">' . esc_html__('Plugin Setting', 'monnify-official') . '</a></strong>'
) .
'</p></div>';
}
}
function monnify_validate_installed_woocommerce()
{
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
if (
class_exists( 'WooCommerce' )
|| ( function_exists( 'is_plugin_active' ) && is_plugin_active( 'woocommerce/woocommerce.php' ) )
|| ( function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) )
) {
return;
}
add_action( 'admin_notices', 'monnify_woocommerce_notice' );
}
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'monnify_add_links_to_plugin_page');
/*
* The class itself
*/
function woo_monnify_init_gateway_class()
{
if (!class_exists('WC_Payment_Gateway')) {
return;
}
add_action('admin_init', 'monnify_validate_installed_woocommerce');
require_once dirname( __FILE__ ) . '/includes/class-monnify-official.php';
}
add_action('plugins_loaded', 'woo_monnify_init_gateway_class');
function monnify_add_links_to_plugin_page($links)
{
$settings_link = '<a href="' . esc_url(get_admin_url(null, 'admin.php?page=wc-settings&tab=checkout§ion=monnify')) . '">' . __('Settings', 'monnify-official') . '</a>';
$documentation_link = '<a href="https://developers.monnify.com" target="_blank">' . __('Documentation', 'monnify-official') . '</a>';
array_push($links, $settings_link, $documentation_link);
return $links;
}
// Register Monnify Blocks Support
add_action('woocommerce_blocks_loaded', 'monnify_register_blocks_support');
function monnify_register_blocks_support() {
if (class_exists('Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType')) {
require_once dirname(__FILE__) . '/includes/class-monnify-blocks-support.php';
add_action(
'woocommerce_blocks_payment_method_type_registration',
function(Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry) {
$payment_method_registry->register(new WC_Monnify_Blocks_Support());
}
);
}
}