| Server IP : 69.72.244.102 / Your IP : 216.73.216.164 Web Server : LiteSpeed System : Linux s3434.fra1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64 User : konzalta ( 1271) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/konzalta/public_html/wp-content/plugins/a-kopokopo-edwin/ |
Upload File : |
<?php
/**
* Plugin Name: WooCommerce Kopokopo Payment Gateway
* Description: Accept M-PESA payments via Kopokopo's STK Push API.
* Version: 1.0
* Author: Edwin Kimathi
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
// Check if WooCommerce is active.
function wc_kopokopo_check_woocommerce() {
return class_exists('WooCommerce');
}
// Initialize the plugin only if WooCommerce is active.
function wc_kopokopo_init() {
if (wc_kopokopo_check_woocommerce()) {
// Include required files.
require_once plugin_dir_path(__FILE__) . 'includes/class-kopokopo-gateway.php';
require_once plugin_dir_path(__FILE__) . 'includes/class-kopokopo-webhook-handler.php';
require_once plugin_dir_path(__FILE__) . 'includes/class-wc-kopokopo-blocks-integration.php';
// Add the gateway to WooCommerce.
add_filter('woocommerce_payment_gateways', function ($methods) {
$methods[] = 'WC_KopoKopo_Full_Version';
return $methods;
});
} else {
// Display an admin notice if WooCommerce is not active.
add_action('admin_notices', function () {
echo '<div class="notice notice-error"><p>' .
__('WooCommerce Kopokopo Payment Gateway requires WooCommerce to be installed and active.', 'woocommerce') .
'</p></div>';
});
}
}
add_action('plugins_loaded', 'wc_kopokopo_init');