-
Notifications
You must be signed in to change notification settings - Fork 3
/
woocommerce-custom-payment-gateways.php
76 lines (60 loc) · 2.72 KB
/
woocommerce-custom-payment-gateways.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
<?php
/*
Plugin Name: WooCommerce Custom Payment Gateways
Plugin URI: http://wordpress.org/plugins/wooCommerce-custom-payment-gateways/
Description: Add Custom Payment Gateways for WooCommerce.
Version: 1.0.0
Author: Mehdi Akram
Author URI: http://shamokaldarpon.com/
License: GPLv2
*/
//Additional links on the plugin page
add_filter( 'plugin_row_meta', 'wcCpg_register_plugin_links', 10, 2 );
function wcCpg_register_plugin_links($links, $file) {
$base = plugin_basename(__FILE__);
if ($file == $base) {
$links[] = '<a href="http://royaltechbd.com/" target="_blank">' . __( 'Royal Technologies', 'rsb' ) . '</a>';
$links[] = '<a href="http://shamokaldarpon.com/" target="_blank">' . __( 'Shamokal Darpon', 'rsb' ) . '</a>';
}
return $links;
}
/* WooCommerce fallback notice. */
function woocommerce_cpg_fallback_notice() {
echo '<div class="error"><p>' . sprintf( __( 'WooCommerce Custom Payment Gateways depends on the last version of %s to work!', 'wcCpg' ), '<a href="http://wordpress.org/extend/plugins/woocommerce/">WooCommerce</a>' ) . '</p></div>';
}
/* Load functions. */
function custom_payment_gateway_load() {
if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
add_action( 'admin_notices', 'woocommerce_cpg_fallback_notice' );
return;
}
function wc_Custom_add_gateway( $methods ) {
$methods[] = 'WC_Custom_Payment_Gateway_1';
$methods[] = 'WC_Custom_Payment_Gateway_2';
$methods[] = 'WC_Custom_Payment_Gateway_3';
$methods[] = 'WC_Custom_Payment_Gateway_4';
$methods[] = 'WC_Custom_Payment_Gateway_5';
return $methods;
}
add_filter( 'woocommerce_payment_gateways', 'wc_Custom_add_gateway' );
// Include the WooCommerce Custom Payment Gateways classes.
require_once plugin_dir_path( __FILE__ ) . 'class-wc-custom_payment_gateway_1.php';
require_once plugin_dir_path( __FILE__ ) . 'class-wc-custom_payment_gateway_2.php';
require_once plugin_dir_path( __FILE__ ) . 'class-wc-custom_payment_gateway_3.php';
require_once plugin_dir_path( __FILE__ ) . 'class-wc-custom_payment_gateway_4.php';
require_once plugin_dir_path( __FILE__ ) . 'class-wc-custom_payment_gateway_5.php';
}
add_action( 'plugins_loaded', 'custom_payment_gateway_load', 0 );
/* Adds custom settings url in plugins page. */
function wcCpg_action_links( $links ) {
$settings = array(
'settings' => sprintf(
'<a href="%s">%s</a>',
admin_url( 'admin.php?page=woocommerce_settings&tab=payment_gateways' ),
__( 'Payment Gateways', 'wcCpg' )
)
);
return array_merge( $settings, $links );
}
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'wcCpg_action_links' );
?>