-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwoocommerce-whatsapp-order-alerts.php
More file actions
92 lines (78 loc) · 2.92 KB
/
Copy pathwoocommerce-whatsapp-order-alerts.php
File metadata and controls
92 lines (78 loc) · 2.92 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
<?php
/**
* Plugin Name: WooCommerce WhatsApp Order Alerts
* Plugin URI: https://example.com/
* Description: Sends real-time WhatsApp notifications to store owners or internal teams when WooCommerce orders are created or hit selected statuses.
* Version: 1.0.0
* Author: S. A Yusuf
* Author URI: https://example.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: woocommerce-whatsapp-order-alerts
* Domain Path: /languages
*
* @package WooCommerce_WhatsApp_Order_Alerts
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
/**
* Define Plugin Constants.
*/
define( 'WWOA_VERSION', '1.0.0' );
define( 'WWOA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'WWOA_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'WWOA_PLUGIN_FILE', __FILE__ );
/**
* Check if WooCommerce is active.
* We must hook into plugins_loaded to perform this check safely.
*/
add_action( 'plugins_loaded', 'wwoa_check_woocommerce_dependency' );
function wwoa_check_woocommerce_dependency() {
if ( ! class_exists( 'WooCommerce' ) ) {
add_action( 'admin_notices', 'wwoa_woocommerce_missing_notice' );
return;
}
// WooCommerce is active, we can boot the plugin.
wwoa_boot_plugin();
}
/**
* Display notice if WooCommerce is not installed or active.
*/
function wwoa_woocommerce_missing_notice() {
$class = 'notice notice-error';
$message = __( 'WooCommerce WhatsApp Order Alerts requires WooCommerce to be installed and active.', 'woocommerce-whatsapp-order-alerts' );
printf( '<div class="%1$s"><p>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) );
}
/**
* The code that runs during plugin activation.
*/
function activate_woocommerce_whatsapp_order_alerts() {
require_once plugin_dir_path( __FILE__ ) . 'includes/class-activator.php';
WWOA_Activator::activate();
}
/**
* The code that runs during plugin deactivation.
*/
function deactivate_woocommerce_whatsapp_order_alerts() {
require_once plugin_dir_path( __FILE__ ) . 'includes/class-deactivator.php';
WWOA_Deactivator::deactivate();
}
register_activation_hook( __FILE__, 'activate_woocommerce_whatsapp_order_alerts' );
register_deactivation_hook( __FILE__, 'deactivate_woocommerce_whatsapp_order_alerts' );
/**
* Boot the core plugin classes.
*/
function wwoa_boot_plugin() {
// Include helper functions initially
require_once plugin_dir_path( __FILE__ ) . 'includes/helpers.php';
// Provider interfaces and classes
require_once plugin_dir_path( __FILE__ ) . 'includes/interfaces/interface-whatsapp-provider.php';
require_once plugin_dir_path( __FILE__ ) . 'includes/providers/class-generic-whatsapp-provider.php';
// Include core setup
require_once plugin_dir_path( __FILE__ ) . 'includes/class-plugin.php';
// Create a new instance of the plugin and run it.
$plugin = new WWOA_Plugin();
$plugin->run();
}