-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccbill-woocommerce.php
96 lines (82 loc) · 2.04 KB
/
ccbill-woocommerce.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
95
<?php
/*
* Plugin Name: CCBill Payment Gateway for WooCommerce
* Plugin URI: #
* Description: Provides a Payment Gateway through CCBill for WooCommerce Subscriptions
* Author: Oleg Iskusnyh
* Author URI: https://oleg.iskusnyh.pro
* License: Apache License 2.0
* License URI: http://www.apache.org/licenses/LICENSE-2.0
* Version: 1.0.0
* Text Domain: ccbill
* Domain Path: /languages
* WC requires at least: 5.5.1
* WC tested up to: 6.1.1
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
class WC_CCBill_Payments {
/**
* Constructor
*/
public function __construct() {
// Actions
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array(
$this,
'plugin_action_links'
) );
add_action( 'plugins_loaded', array( $this, 'init' ), 0 );
add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts' ) );
add_filter( 'woocommerce_payment_gateways', array(
$this,
'register_gateway'
) );
}
/**
* Add relevant links to plugins page
*
* @param array $links
*
* @return array
*/
public function plugin_action_links( $links ) {
$plugin_links = array(
'<a href="' . esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ccbill' ) ) . '">' . __( 'Settings', 'ccbill' ) . '</a>'
);
return array_merge( $plugin_links, $links );
}
/**
* Init localisations and files
*/
public function init() {
if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
return;
}
// Localization
load_plugin_textdomain(
'ccbill',
false,
dirname( plugin_basename( __FILE__ ) ) . '/i18n'
);
// Includes
include_once( dirname( __FILE__ ) . '/includes/class-wc-gateway-ccbill-payments.php' );
}
/**
* Register the gateways for use
*/
public function register_gateway( $methods ) {
$methods[] = 'WC_Gateway_CCBill_Payments';
return $methods;
}
/**
* Add Scripts
*/
public function add_scripts() {
wp_enqueue_style(
'wc-gateway-ccbill',
plugins_url( '/assets/css/style.css', __FILE__ ),
array(), false, 'all' );
}
}
new WC_CCBill_Payments();