<?php

/**
 * Luman Plus
 *
 * @package           Luman-Plus
 * @author            fullwp
 * @copyright         LumanPlus
 * @license           RTL-Theme
 *
 * @wordpress-plugin
 *
 * Plugin Name: luman plus
 * Description: لومان پلاس 
 * Version: 1.2.0
 * Requires at least: 6.0
 * Requires PHP: 7.4
 * Author: fullwp
 * License: RTL-Theme License
 * Text Domain: lumanPlus
 */

use lumanPlus\Bootstrap;
use lumanPlus\Web\LumanPlusLoginManagerHooks;

require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
require_once __DIR__ . '/Includes/Web/LumanPlusAdminMenu.php';
require_once __DIR__ . '/admin/settings/class-invoice-settings.php';
require_once __DIR__ . '/admin/settings/class-ai-settings.php';
require_once __DIR__ . '/Includes/functions.php';
require_once __DIR__ . '/Includes/invoice/class-invoice-generator.php';
require_once __DIR__ . '/Includes/invoice/class-postal-label-generator.php';

function load_lpl_service () {

    Bootstrap::boot();
    LumanPlusLoginManagerHooks::dispatch();

}

register_activation_hook(__FILE__, [Bootstrap::class, 'initDB']);

add_action('plugins_loaded','load_lpl_service');

// Elementor widgets loader
add_action('plugins_loaded', function() {
    if ( did_action('elementor/loaded') ) {
        require_once __DIR__ . '/Includes/elementor/manager.php';
    } else {
        add_action('elementor/loaded', function() {
            require_once __DIR__ . '/Includes/elementor/manager.php';
        });
    }
});

add_action('wp_enqueue_scripts', function() {
    if (!is_product()) return;
    $ai_enabled = get_option('luman_ai_enabled', 'yes');
    $json_url = plugins_url('assets/json/RgoPvRyYzg.json', __FILE__);
    wp_register_script('lottie-ai', plugins_url('assets/js/lottie-ai.js', __FILE__), [], null, true);
    wp_localize_script('lottie-ai', 'luman_ai_data', [
        'enabled' => $ai_enabled,
        'json_url' => $json_url
    ]);
    wp_enqueue_script('lottie-ai');
});