<?php

declare(strict_types=1);

namespace Signocore\Multilanguage\Application;

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

final class Constants
{
	public const OPTION_PREFIX = 'sml_';

	public const AJAX_NONCE = self::OPTION_PREFIX . 'ajax_nonce';

	public const TRANSIENT_PREFIX = self::OPTION_PREFIX;

	public const SLUG = 'signocore-multilanguage';

	public const UPDATE_URL = 'https://update.signocore.com/api/wp-update/plugins/' . self::SLUG;

	public const TEXT_DOMAIN = self::SLUG;

	public const META_PREFIX = '_sml_';

	public const COOKIE_NAME = 'sml_language';

	// Database table suffixes (prefixed with $wpdb->prefix at runtime)
	public const TABLE_LANGUAGES = 'sml_languages';

	public const TABLE_TRANSLATIONS = 'sml_translations';

	public const TABLE_STRINGS = 'sml_strings';

	public const TABLE_STRING_TRANSLATIONS = 'sml_string_translations';

	// URL strategies
	public const URL_STRATEGY_DIRECTORY = 'directory';

	public const URL_STRATEGY_SUBDOMAIN = 'subdomain';

	public const URL_STRATEGY_DOMAIN = 'domain';

	// Translation statuses
	public const STATUS_PUBLISHED = 'published';

	public const STATUS_DRAFT = 'draft';

	public const STATUS_IN_PROGRESS = 'in_progress';

	public const STATUS_NEEDS_UPDATE = 'needs_update';

	// Dynamic properties
	public static string $pluginVersion;

	public static string $pluginBase;

	public static bool $isAdmin;

	public static function load(): void
	{
		self::$pluginVersion = get_file_data(SIGNOCORE_ML_FILE, ['Version'])[0] ?? '';
		self::$pluginBase = plugin_basename(SIGNOCORE_ML_FILE);
		self::$isAdmin = is_admin();
	}
}
