-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
128 lines (110 loc) · 3.52 KB
/
Copy pathindex.php
File metadata and controls
128 lines (110 loc) · 3.52 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
127
128
<?php
/**
* Plugin Name: WooCommerce E-Comprocessing Payment Gateway Client
* Plugin URI: https://wordpress.org/plugins/ecomprocessing-payment-page-for-woocommerce/
* Description: Extend WooCommerce's Checkout options with ecomprocessing's Genesis Gateway
* Text Domain: woocommerce-ecomprocessing
* Author: ecomprocessing
* Author URI: https://e-comprocessing.com/
* Version: 1.17.14
* Requires at least: 4.0
* Tested up to: 6.9
* WC requires at least: 3.0.0
* WC tested up to: 10.4.3
* WCS tested up to: 8.3.1
* WCB tested up to: 11.7.0
* License: GPL-2.0
* License URI: http://opensource.org/licenses/gpl-2.0.php
*
* @package index.php
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
require_once 'libraries/vendor/autoload.php';
/**
* Load the ecomprocessing plugin text domain
*/
function woocommerce_ecomprocessing_load_textdomain() {
$translation = load_plugin_textdomain(
'woocommerce-ecomprocessing',
false,
basename( __DIR__ ) . DIRECTORY_SEPARATOR . 'languages'
);
if ( ! $translation && defined( 'WP_DEBUG' ) && WP_DEBUG ) {
error_log( 'Unable to load language file for locale: ' . get_locale() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
}
}
/**
* Filter for handling ecomprocessing orders in My Account
*
* @param array $actions List of available actions
* @param WC_Order $order The order object
*
* @return array Modified actions
*/
function woocommerce_ecomprocessing_my_orders_actions( $actions, $order ) {
$is_pending = $order && $order->has_status( 'pending' );
$is_emp = ( $order instanceof WC_Order ) && in_array(
$order->get_payment_method(),
array(
WC_Ecomprocessing_Checkout::get_method_code(),
WC_Ecomprocessing_Direct::get_method_code(),
),
true
);
if ( $is_emp && $is_pending ) {
unset( $actions['pay'] );
unset( $actions['cancel'] );
}
return $actions;
}
/**
* Add E-Comprocessing Payment Gateways
*
* @param array $methods Existing payment gateways
* @return array
*/
function woocommerce_add_ecomprocessing_gateway( $methods ) {
$methods[] = 'WC_Ecomprocessing_Checkout';
$methods[] = 'WC_Ecomprocessing_Direct';
return $methods;
}
/* there is no need to load the plugin if woocommerce is not active */
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
if ( ! function_exists( 'woocommerce_ecomprocessing_init' ) ) {
/**
* Init woocommerce ecomprocessing plugin.
*/
/**
* Init woocommerce ecomprocessing plugin.
*/
function woocommerce_ecomprocessing_init() {
if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
return;
}
woocommerce_ecomprocessing_load_textdomain();
add_filter( 'woocommerce_payment_gateways', 'woocommerce_add_ecomprocessing_gateway' );
add_filter( 'woocommerce_my_account_my_orders_actions', 'woocommerce_ecomprocessing_my_orders_actions', 10, 2 );
}
}
add_action( 'plugins_loaded', 'woocommerce_ecomprocessing_init', 0 );
new WC_Ecomprocessing_Functions( __FILE__ );
new WC_Ecomprocessing_Blocks_Functions( __FILE__ );
if ( ! function_exists( 'wc_ecomprocessing_post_adapter' ) ) {
/**
* @return WC_Ecomprocessing_Posts_Adapter|null
*/
function wc_ecomprocessing_post_adapter() {
return WC_Ecomprocessing_Posts_Adapter::get_instance();
}
}
if ( ! function_exists( 'wc_ecomprocessing_order_proxy' ) ) {
/**
* @return WC_Ecomprocessing_Order_Proxy
*/
function wc_ecomprocessing_order_proxy() {
return WC_Ecomprocessing_Order_Proxy::get_instance();
}
}
}