<?php

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

if (!defined('AIEO_MOI_VERSION')) { define('AIEO_MOI_VERSION', '1.0.0-aieo'); }
if (!defined('AIEO_MOI_FILE'))    { define('AIEO_MOI_FILE',    __FILE__); }
if (!defined('AIEO_MOI_DIR'))     { define('AIEO_MOI_DIR',     __DIR__ . '/'); }
if (!defined('AIEO_MOI_URL'))     { define('AIEO_MOI_URL',     plugin_dir_url(__FILE__)); }

require_once AIEO_MOI_DIR . 'includes/class-moi-schema.php';

add_action('before_woocommerce_init', function () {
    if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility(
            'custom_order_tables',
            defined('AIEO_FILE') ? AIEO_FILE : __FILE__,
            true
        );
    }
});

require_once AIEO_MOI_DIR . 'includes/interface-moi-provider.php';
require_once AIEO_MOI_DIR . 'includes/class-moi-provider-registry.php';
require_once AIEO_MOI_DIR . 'includes/class-moi-vendor-manager.php';
require_once AIEO_MOI_DIR . 'includes/class-moi-oauth.php';
require_once AIEO_MOI_DIR . 'includes/class-moi-order-mapper.php';
require_once AIEO_MOI_DIR . 'includes/class-moi-inbound-log.php';
require_once AIEO_MOI_DIR . 'includes/class-moi-rest-api.php';
require_once AIEO_MOI_DIR . 'includes/class-moi-admin.php';
require_once AIEO_MOI_DIR . 'includes/class-moi-order-meta-box.php';
require_once AIEO_MOI_DIR . 'includes/class-moi-voucher-store.php';
require_once AIEO_MOI_DIR . 'includes/class-moi-poller.php';
require_once AIEO_MOI_DIR . 'includes/class-moi-legacy-skroutz-migrator.php';

require_once AIEO_MOI_DIR . 'includes/providers/skroutz/class-moi-provider-skroutz.php';
require_once AIEO_MOI_DIR . 'includes/providers/shopflix/class-moi-provider-shopflix.php';
require_once AIEO_MOI_DIR . 'includes/providers/emag/class-moi-provider-emag.php';
require_once AIEO_MOI_DIR . 'includes/providers/etsy/class-moi-provider-etsy.php';
require_once AIEO_MOI_DIR . 'includes/providers/amazon/class-moi-provider-amazon.php';
require_once AIEO_MOI_DIR . 'includes/providers/efood/class-moi-provider-efood.php';
require_once AIEO_MOI_DIR . 'includes/providers/wolt/class-moi-provider-wolt.php';

AIEO_MOI_REST_API::instance();
AIEO_MOI_Admin::instance();
AIEO_MOI_Order_Meta_Box::instance();

if (get_option(AIEO_MOI_Schema::OPTION_VERSION) !== AIEO_MOI_Schema::SCHEMA_VERSION) {
    AIEO_MOI_Schema::install();
}
