<?php

/**
 * DevNajmus OneClick Order Popup
 *
 * @package   DevNajmusOneClickOrderPopup
 * @author    DevNajmus
 * @license   GPL-2.0+
 *
 * @wordpress-plugin
 * Plugin Name: DevNajmus OneClick Order Popup – for WooCommerce
 * Plugin URI:  https://github.com/devnajmus/devnajmus-oneclick-order-popup
 * Description: A WooCommerce extension for fast one-click ordering using a modern popup checkout.
 * Version:     1.1.0  
 * Author:      DevNajmus
 * Author URI:  https://github.com/devnajmus
 * Text Domain: devnajmus-oneclick-order-popup-for-woocommerce
 * Domain Path: /languages
 * Requires Plugins: woocommerce
 * License:     GPL-2.0+
 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
 */

// If this file is called directly, abort.
if (!defined('WPINC')) {
    die;
}

// Check if WooCommerce is active
if (!in_array('woocommerce/woocommerce.php', apply_filters('dopw_active_plugins', get_option('active_plugins')))) {
    add_action('admin_notices', function () {
        echo '<div class="error"><p>';
        esc_html_e('Direct Order Popup for WooCommerce requires WooCommerce to be installed and activated.', 'devnajmus-oneclick-order-popup-for-woocommerce');
        echo '</p></div>';
    });
    return;
}

// Define plugin constants
define('DOPW_VERSION', '1.1.0');
define('DOPW_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('DOPW_PLUGIN_URL', plugin_dir_url(__FILE__));
define('DOPW_PLUGIN_BASENAME', plugin_basename(__FILE__));

// Require the main loader class
require_once DOPW_PLUGIN_DIR . 'includes/class-dopw-loader.php';

/**
 * Run the plugin.
 *
 * @since 1.0.0
 */
function dopw_run()
{
    $plugin = DOPW_Loader::get_instance();
    $plugin->run();
}

/**
 * Plugin activation hook.
 *
 * @since 1.0.0
 */
function dopw_activate()
{
    DOPW_Loader::activate();
}

/**
 * Plugin deactivation hook.
 *
 * @since 1.0.0
 */
function dopw_deactivate()
{
    DOPW_Loader::deactivate();
}

// Register activation & deactivation hooks
register_activation_hook(__FILE__, 'dopw_activate');
register_deactivation_hook(__FILE__, 'dopw_deactivate');

// Initialize the plugin
dopw_run();
