<?php

/**
 * Plugin Name: EasyConnect for Kaufland
 * Plugin URI: https://easyconnect.logiklabs.tech
 * Description: WooCommerce integration for Kaufland marketplace
 * Version: 1.0.0
 * Author: LogikLabs
 * Author URI: https://logiklabs.tech
 * Text Domain: easyconnect-for-kaufland
 * Domain Path: /languages
 * Requires at least: 5.8
 * Requires PHP: 7.4
 * WC requires at least: 6.0
 * License: GPL-2.0+
 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
 */

declare(strict_types=1);

if (!defined('ABSPATH')) {
  exit;
}

// Define plugin constants
define('KLCNN_VERSION', '1.0.0');
define('KLCNN_FILE', __FILE__);
define('KLCNN_PATH', plugin_dir_path(KLCNN_FILE));
define('KLCNN_URL', plugin_dir_url(KLCNN_FILE));

// Define tracking credentials in a way that can be overridden
// if (!defined('KLCNN_TRACKING_ID')) {
// define('KLCNN_TRACKING_ID', 'G-GMV61DT143');
// }
// if (!defined('KLCNN_TRACKING_SECRET')) {
// define('KLCNN_TRACKING_SECRET', 's5WpIXDWR9-9cRVnXJ00YA');
// }

// Load dependencies
require_once KLCNN_PATH . 'includes/class-klcnn-loader.php';
require_once KLCNN_PATH . 'includes/api/class-klcnn-api-base.php';
require_once KLCNN_PATH . 'includes/api/class-klcnn-api-connection.php';
require_once KLCNN_PATH . 'includes/routes/class-klcnn-register-routes.php';
require_once KLCNN_PATH . 'includes/products/class-klcnn-product-sync.php';
require_once KLCNN_PATH . 'includes/products/class-klcnn-product-fields.php';
require_once KLCNN_PATH . 'includes/categories/class-klcnn-category-manager.php';
// require_once KLCNN_PATH . 'includes/class-klcnn-tracking.php';
// require_once KLCNN_PATH . 'includes/class-klcnn-consent-modal.php';

// Initialize plugin
function klcnn_init()
{
  // Check if WooCommerce is active
  if (!class_exists('WooCommerce')) {
    add_action('admin_notices', function () {
?>
      <div class="notice notice-error">
        <p><?php esc_html_e('EasyConnect for Kaufland requires WooCommerce to be installed and activated.', 'easyconnect-for-kaufland'); ?></p>
      </div>
<?php
    });
    return;
  }

  // Initialize plugin
  KLCNN_Loader::get_instance();
}
add_action('plugins_loaded', 'klcnn_init');

// Initialize admin
require_once KLCNN_PATH . 'includes/class-klcnn-admin.php';
new KLCNN_Admin();
