<?php
/**
 * Plugin Name:       Mind Web Concierge
 * Plugin URI:        https://smartmind.it/concierge/
 * Description:       Mind Web Concierge is an intelligent, WordPress-based assistant powered by RAG technology.
 * Version:           1.3.0
 * Requires at least: 6.0
 * Requires PHP:      7.4
 * Author:            Smart Processes
 * Author URI:        https://smartprocesses.it/
 * License:           GPL-2.0+
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       mind-web-concierge
 * Domain Path:       /languages
 */

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

add_action( 'init', 'mindweco_load_textdomain' );

function mindweco_load_textdomain() {
    load_plugin_textdomain(
        'mind-web-concierge',
        false,
        basename( __DIR__ ) . '/languages'
    );
}

require_once plugin_dir_path(__FILE__) . "includes/mindweco_config.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_api.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_sitemap.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_activation.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_deactivation.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_conversations.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_nonce_refresh.php";
require_once plugin_dir_path(__FILE__) . "includes/class-mindweco_session.php"; 
require_once plugin_dir_path(__FILE__) . "includes/mindweco_manage_product_catalog.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_knowledge_repository.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_ask_stream.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_session.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_ajax.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_hooks.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_subscription_handlers.php";
require_once plugin_dir_path(__FILE__) . "includes/mindweco_manage_media_files.php";

require_once plugin_dir_path(__FILE__) . "admin/mindweco_item_settings.php";
require_once plugin_dir_path(__FILE__) . "admin/mindweco_media_files.php";
require_once plugin_dir_path(__FILE__) . "admin/mindweco_subscription_settings.php";
require_once plugin_dir_path(__FILE__) . "admin/mindweco_knowledge_repository.php";
require_once plugin_dir_path(__FILE__) . "admin/mindweco_admin_conversations.php";
require_once plugin_dir_path(__FILE__) . "admin/mindweco_model_usage_settings.php";
require_once plugin_dir_path(__FILE__) . "admin/mindweco_product_catalog_settings.php";

/**
 * ACTIVATION / DEACTIVATION HOOKS
 */
register_activation_hook(__FILE__, "mindweco_plugin_activate");
function mindweco_plugin_activate() {
  mindweco_plugin_on_activate();
}

register_deactivation_hook(__FILE__, "mindweco_plugin_deactivate");
function mindweco_plugin_deactivate() {
    mindweco_plugin_cancel_on_deactivate();
    mindweco_plugin_logout_knowledge_on_deactivate();

    $timestamp = wp_next_scheduled( 'mindweco_cleanup_transients' );
    if ( $timestamp ) {
        wp_unschedule_event( $timestamp, 'mindweco_cleanup_transients' );
    }
}
