<?php
/**
 * Plugin Name: PackshotPhoto AI — Image SEO & Optimizer
 * Description: Automate WordPress image SEO & performance optimization with AI. Generate ALT descriptions, convert to WebP/AVIF, apply EU AI Act transparency watermarks (Art. 50), rename files, and speed up your site.
 * Version: 1.2.20
 * Requires at least: 6.0
 * Requires PHP: 7.4
 * Author: PPP Studio sp. z o.o.
 * Author URI: https://packshotphoto.com
 * License: GPL v2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: packshotphoto-ai
 * Domain Path: /languages
 */

defined('ABSPATH') || exit;

// Plugin constants
defined('PACKSHOTPHOTO_AI_VERSION')     || define('PACKSHOTPHOTO_AI_VERSION',     '1.2.20');
defined('PACKSHOTPHOTO_AI_FILE') || define('PACKSHOTPHOTO_AI_FILE', __FILE__);
defined('PACKSHOTPHOTO_AI_DIR')  || define('PACKSHOTPHOTO_AI_DIR',  plugin_dir_path(__FILE__));
defined('PACKSHOTPHOTO_AI_URL')  || define('PACKSHOTPHOTO_AI_URL',  plugin_dir_url(__FILE__));
defined('PACKSHOTPHOTO_AI_DEV_MODE')    || define('PACKSHOTPHOTO_AI_DEV_MODE',    false);

// Composer autoload
if (file_exists(PACKSHOTPHOTO_AI_DIR . 'vendor/autoload.php')) {
    require_once PACKSHOTPHOTO_AI_DIR . 'vendor/autoload.php';
} else {
    // Fallback manual autoloader for environments without Composer
    spl_autoload_register(function ($class) {
        $prefix = 'PackshotPhotoAI\\';
        $base_dir = PACKSHOTPHOTO_AI_DIR . 'includes/';
        
        $len = strlen($prefix);
        if (strncmp($prefix, $class, $len) !== 0) {
            return;
        }
        
        $relative_class = substr($class, $len);
        $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
        
        if (file_exists($file)) {
            require $file;
        }
    });
}

// Initialize plugin
add_action('plugins_loaded', function() {
    \PackshotPhotoAI\Plugin::instance()->run();
});



// Activation hook
register_activation_hook(__FILE__, function() {
    \PackshotPhotoAI\Core\Activator::activate();
});

// Deactivation hook
register_deactivation_hook(__FILE__, function() {
    \PackshotPhotoAI\Core\Deactivator::deactivate();
});
