-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcppay-wordpress-plugin.php
More file actions
50 lines (40 loc) · 1.45 KB
/
cppay-wordpress-plugin.php
File metadata and controls
50 lines (40 loc) · 1.45 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
<?php
/**
* Plugin Name: CPPay WordPress Plugin
* Description: Use CPPay API in WordPress without exposing API Key to frontend.
* Version: 0.1.0
* Author: CPPay
* Requires at least: 6.0
* Requires PHP: 7.4
*/
if (! defined('ABSPATH')) {
exit;
}
define('CPPAY_WP_PLUGIN_VERSION', '0.1.0');
define('CPPAY_WP_PLUGIN_FILE', __FILE__);
define('CPPAY_WP_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('CPPAY_WP_PLUGIN_URL', plugin_dir_url(__FILE__));
require_once CPPAY_WP_PLUGIN_DIR . 'includes/class-cppay-api-client.php';
require_once CPPAY_WP_PLUGIN_DIR . 'includes/class-cppay-plugin.php';
function cppay_wp_woocommerce_missing_notice()
{
echo '<div class="notice notice-error"><p>';
echo esc_html__('CPPay WordPress Plugin requires WooCommerce to show payment method on checkout.', 'cppay-wordpress-plugin');
echo '</p></div>';
}
function cppay_wp_init_woocommerce_gateway()
{
if (! class_exists('WooCommerce')) {
add_action('admin_notices', 'cppay_wp_woocommerce_missing_notice');
return;
}
require_once CPPAY_WP_PLUGIN_DIR . 'includes/class-cppay-wc-gateway.php';
require_once CPPAY_WP_PLUGIN_DIR . 'includes/class-cppay-wc-webhook.php';
add_filter('woocommerce_payment_gateways', function ($gateways) {
$gateways[] = 'CPPAY_WC_Gateway';
return $gateways;
});
new CPPAY_WC_Webhook();
}
add_action('plugins_loaded', 'cppay_wp_init_woocommerce_gateway', 20);
CPPAY_WP_Plugin::instance();