forked from corvuspay/corvuspay-woocommerce-integration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorvuspay-woocommerce-integration.php
94 lines (80 loc) · 2.81 KB
/
corvuspay-woocommerce-integration.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
<?php
/**
* Plugin Name: CorvusPay WooCommerce Payment Gateway
* Plugin URI: https://www.corvuspay.com/
* Description: Extends WooCommerce with CorvusPay Credit Card payments.
* Version: 2.5.7
* Author: Corvus Pay d.o.o.
* Author URI: https://www.corvuspay.com/
* Copyright: © 2024 Corvus Pay
* License: GNU General Public License v2.0 (or later)
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Requires at least: 4.0
* Tested up to: 6.4.3
* WC requires at least: 3.0
* WC tested up to: 8.6.1
* Text Domain: corvuspay-woocommerce-integration
* Domain Path: /languages/
*
* @package corvuspay-woocommerce-integration
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'plugins_loaded', 'woocommerce_corvuspay_init', 0 );
/**
* Echo WooCommerce not installed or not active notice.
*/
function woocommerce_corvuspay_notice_missing_wc() {
?>
<div class="notice notice-error">
<p><?php esc_html_e( 'CorvusPay requires WooCommerce to be installed and active.', 'corvuspay-woocommerce-integration' ); ?></p>
</div>
<?php
}
/**
* Init CorvusPay WooCommerce gateway plugin.
*/
function woocommerce_corvuspay_init() {
define( 'WC_CORVUSPAY_SETTINGS_VERSION', 4 );
define( 'WC_CORVUSPAY_FILE', __FILE__ );
define( 'WC_CORVUSPAY_PATH', dirname( __FILE__ ) );
$domain = 'corvuspay-woocommerce-integration';
$locale = apply_filters( 'plugin_locale', determine_locale(), $domain );
$mofile = WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) . '/languages/' . $domain . '-' . $locale . '.mo';
unload_textdomain( $domain );
load_textdomain( $domain, $mofile );
load_plugin_textdomain( $domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
add_action( 'admin_notices', 'woocommerce_corvuspay_notice_missing_wc' );
return;
}
require_once WC_CORVUSPAY_PATH . '/includes/class-wc-gateway-corvuspay.php';
/**
* Add Settings link to plugin page.
*
* @param array $links List of existing plugin action links.
*
* @return array List of modified plugin action links.
*/
function corvuspay_action_links( $links ) {
$settings = array(
'<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=corvuspay' ) ) . '">' . esc_html__( 'Settings', 'corvuspay-woocommerce-integration' ) . '</a>',
);
return array_merge( $settings, $links );
}
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'corvuspay_action_links' );
/**
* Add CorvusPay Gateway.
*
* @param array $methods Methods.
*
* @return array
*/
function woocommerce_add_corvuspay_gateway( $methods ) {
$methods[] = 'WC_Gateway_CorvusPay';
return $methods;
}
add_filter( 'woocommerce_payment_gateways', 'woocommerce_add_corvuspay_gateway' );
WC_Gateway_CorvusPay::get_instance()->init_hooks();
}