<?php
/**
 * Plugin Name: Modelora - 3D Product & Model Viewer
 * Plugin URI: https://wordpress.org/plugins/modelora/
 * Description: Beginner-friendly, high-performance 3D model viewer for WordPress and WooCommerce.
 * Version: 1.0.0
 * Requires at least: 6.4
 * Requires PHP: 7.4
 * Author: rishav001
 * Text Domain: modelora-3d-product-viewer
 * Domain Path: /languages
 * License: GPLv2 or later
 */

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

define('MODELORA_VERSION', '1.0.0');
define('MODELORA_PLUGIN_FILE', __FILE__);
define('MODELORA_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('MODELORA_PLUGIN_URL', plugin_dir_url(__FILE__));

spl_autoload_register(function ($class) {
    if (strpos($class, 'MODELORA\\') !== 0) {
        return;
    }

    $relative_class = substr($class, 9);
    $file = MODELORA_PLUGIN_DIR . 'includes/' . str_replace('\\', '/', $relative_class) . '.php';

    if (file_exists($file)) {
        require_once $file;
    }
});

function modelora_boot_plugin()
{
    $plugin = new \MODELORA\Core\Plugin();
    $plugin->boot();
}
add_action('plugins_loaded', 'modelora_boot_plugin');

register_activation_hook(__FILE__, function () {
    \MODELORA\Core\PostType::register_type();
    flush_rewrite_rules();

    if (! get_option('modelora_settings')) {
        add_option('modelora_settings', [
            'lazy_load' => 1,
            'progressive_loading' => 1,
            'auto_lod' => 1,
            'cdn_enabled' => 0,
            'max_upload_mb' => 50,
            'default_preset' => 'studio',
            'dark_mode_ui' => 0,
        ]);
    }
});

register_deactivation_hook(__FILE__, function () {
    flush_rewrite_rules();
});

