|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Plugin Name: WooCommerce Utils |
| 4 | + * Description: Provides helpful utilities for WooCommerce. |
| 5 | + * Version: 1.0.0 |
| 6 | + * Author: Example Author |
| 7 | + * Text Domain: woocommerce-utils |
| 8 | + * Domain Path: /languages |
| 9 | + */ |
| 10 | + |
| 11 | +if ( ! defined( 'ABSPATH' ) ) { |
| 12 | + exit; // Exit if accessed directly. |
| 13 | +} |
| 14 | + |
| 15 | +// Define plugin constants. |
| 16 | +if ( ! defined( 'WC_UTILS_VERSION' ) ) { |
| 17 | + define( 'WC_UTILS_VERSION', '1.0.0' ); |
| 18 | +} |
| 19 | +if ( ! defined( 'WC_UTILS_PATH' ) ) { |
| 20 | + define( 'WC_UTILS_PATH', plugin_dir_path( __FILE__ ) ); |
| 21 | +} |
| 22 | +if ( ! defined( 'WC_UTILS_URL' ) ) { |
| 23 | + define( 'WC_UTILS_URL', plugin_dir_url( __FILE__ ) ); |
| 24 | +} |
| 25 | + |
| 26 | +/** |
| 27 | + * Initialize the plugin. |
| 28 | + */ |
| 29 | +function wc_utils_init() { |
| 30 | + // Ensure WooCommerce is active. |
| 31 | + if ( ! class_exists( 'WooCommerce' ) ) { |
| 32 | + add_action( 'admin_notices', 'wc_utils_missing_wc_notice' ); |
| 33 | + return; |
| 34 | + } |
| 35 | + |
| 36 | + // Include required files. |
| 37 | + require_once WC_UTILS_PATH . 'includes/class-wc-utils-admin.php'; |
| 38 | + require_once WC_UTILS_PATH . 'includes/class-wc-utils-features.php'; |
| 39 | + |
| 40 | + // Initialize classes. |
| 41 | + new WC_Utils_Admin(); |
| 42 | + new WC_Utils_Features(); |
| 43 | +} |
| 44 | +add_action( 'plugins_loaded', 'wc_utils_init' ); |
| 45 | + |
| 46 | +/** |
| 47 | + * Display an admin notice if WooCommerce is not active. |
| 48 | + */ |
| 49 | +function wc_utils_missing_wc_notice() { |
| 50 | + echo '<div class="notice notice-error"><p>' . esc_html__( 'WooCommerce Utils requires WooCommerce to be active.', 'woocommerce-utils' ) . '</p></div>'; |
| 51 | +} |
| 52 | + |
| 53 | +?> |
0 commit comments