-
Notifications
You must be signed in to change notification settings - Fork 0
/
gateway-irandargah.php
80 lines (70 loc) · 2.64 KB
/
gateway-irandargah.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
<?php
/**
* Plugin Name: IranDargah Payment Gateway for WooCommerce
* Plugin URI: https://irandargah.com
* Description: IPG for woocommerce with IranDargah
* Author: IranDargah
* Version: 2.0.11
* Requires at least: 4.4
* Tested up to: 5.9
* Text Domain: irandargah-woocommerce-ipg
*
*/
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
defined('ABSPATH') || exit;
define('WC_GATEWAY_IRANDARGAH_VERSION', '2.0.11');
define('WC_GATEWAY_IRANDARGAH_URL', untrailingslashit(plugins_url(basename(plugin_dir_path(__FILE__)), basename(__FILE__))));
define('WC_GATEWAY_IRANDARGAH_PATH', untrailingslashit(plugin_dir_path(__FILE__)));
/**
* Initialize the gateway.
* @since 2.0.0
*/
function woocommerce_irandargah_init()
{
if (!class_exists('WC_Payment_Gateway')) {
return;
}
require_once plugin_basename('includes/class-wc-gateway-irandargah.php');
load_plugin_textdomain('irandargah-woocommerce-ipg', false, dirname(plugin_basename(__FILE__)) . '/languages/');
add_filter('woocommerce_payment_gateways', 'woocommerce_irandargah_add_gateway');
}
add_action('plugins_loaded', 'woocommerce_irandargah_init', 0);
function woocommerce_irandargah_plugin_links($links)
{
$settings_url = add_query_arg(
array(
'page' => 'wc-settings',
'tab' => 'checkout',
'section' => 'wc_gateway_irandargah',
),
admin_url('admin.php')
);
$plugin_links = array(
'<a href="' . esc_url($settings_url) . '">' . __('Settings', 'irandargah-woocommerce-ipg') . '</a>',
'<a href="https://docs.irandargah.com">' . __('Docs', 'irandargah-woocommerce-ipg') . '</a>',
);
return array_merge($plugin_links, $links);
}
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'woocommerce_irandargah_plugin_links');
/**
* Add the gateway to WooCommerce
* @since 2.0.0
*/
function woocommerce_irandargah_add_gateway($methods)
{
$methods[] = 'WC_Gateway_IranDargah';
return $methods;
}
add_action('woocommerce_blocks_loaded', 'woocommerce_irandargah_woocommerce_blocks_support');
function woocommerce_irandargah_woocommerce_blocks_support()
{
if (class_exists('Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType')) {
require_once dirname(__FILE__) . '/includes/class-wc-gateway-irandargah-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_IranDargah_Blocks_Support);
}
);
}
}