<?php
/**
 * Plugin Name: Formatrica - Drag and Drop Form Builder
 * Description: Lightweight drag-and-drop WordPress form builder with reliable email delivery, strong security, and flexible integrations.
 * Version: 1.1.3
 * Author: Zoran Tanevski
 * Author URI: https://nexusplugins.com
 * Plugin URI: https://nexusplugins.com/products/formatrica
 * Text Domain: formatrica
 * Domain Path: /languages
 * Requires at least: 6.4
 * Requires PHP: 8.1
 * Tested up to: 7.0
 * Recommend PHP: 8.3
 * License: GPLv2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 */

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

define('FORMATRICA_VERSION', '1.1.3');
define('FORMATRICA_FILE', __FILE__);
define('FORMATRICA_PATH', plugin_dir_path(__FILE__));
define('FORMATRICA_URL', plugin_dir_url(__FILE__));
if (!defined('FORMATRICA_PACKAGE')) {
    define('FORMATRICA_PACKAGE', 'wporg');
}

// Edition-scoped build outputs (docs/wporg-free-runtime-separation.md, §10):
// the pro package loads build/pro/, every other package stamp loads build/free/.
// Fail closed — an unknown stamp must never resolve to the Pro bundles.
define('FORMATRICA_BUILD_PATH', plugin_dir_path(__FILE__) . 'build/' . (FORMATRICA_PACKAGE === 'pro' ? 'pro/' : 'free/'));
define('FORMATRICA_BUILD_URL', plugin_dir_url(__FILE__) . 'build/' . (FORMATRICA_PACKAGE === 'pro' ? 'pro/' : 'free/'));

require_once FORMATRICA_PATH . 'app/Autoloader.php';

\Formatrica\Autoloader::register();

register_activation_hook(__FILE__, static function (): void {
    (new \Formatrica\Setup\Activator())->activate();
});

register_deactivation_hook(__FILE__, static function (): void {
    (new \Formatrica\Setup\Deactivator())->deactivate();
});

// Load the bundled translations. WordPress auto-loads language packs for
// directory-hosted plugins (4.6+), but the selfhost and pro packages are NOT
// directory-hosted — they rely on the .mo files bundled under /languages, so
// the explicit registration must stay.
add_action('init', static function (): void {
    load_plugin_textdomain('formatrica', false, dirname(plugin_basename(__FILE__)) . '/languages'); // phpcs:ignore PluginCheck.CodeAnalysis.DiscouragedFunctions.load_plugin_textdomainFound -- required for the non-wp.org (selfhost/pro) packages
});

(new \Formatrica\Plugin())->boot();
