<?php
/**
 * Plugin Name: QuikVox AI
 * Description: Generate podcast scripts from WordPress posts using Google Gemini AI.
 * Version:         1.0.18
 * Author:      takeshiue
 * Author URI:  https://github.com/takeshiue
 * License:     GPLv2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: quikvox-ai
 * Domain Path: /languages
 */

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

if (!defined('PODCASTMAKER_VERSION')) {
    define('PODCASTMAKER_VERSION', '1.0.18');
}

/**
 * Translate selected admin strings even when compiled MO files are not yet refreshed.
 *
 * @param string $translated Translated text.
 * @param string $text Original text.
 * @param string $domain Text domain.
 * @return string
 */
function Podcastmaker_translate_selected_strings($translated, $text, $domain)
{
	if ($domain !== 'quikvox-ai') {
		return $translated;
	}

	$locale = function_exists('determine_locale') ? determine_locale() : get_locale();
	if (strpos($locale, 'ja') !== 0) {
		return $translated;
	}

	$translations = array(
		'Region groups are collapsed by default. Open a group to choose the specific location.' => 'リージョングループは初期状態では折りたたまれています。グループを開いて具体的なロケーションを選択してください。',
		'Choose one location per model.' => 'モデルごとに 1 つのロケーションを選択してください。',
	);

	return isset($translations[$text]) ? $translations[$text] : $translated;
}

add_filter('gettext', 'Podcastmaker_translate_selected_strings', 20, 3);

// Include the main admin class.
require_once plugin_dir_path(__FILE__) . 'includes/class-podcastmaker-admin.php';
require_once plugin_dir_path(__FILE__) . 'includes/class-podcastmaker-script-generator.php';
require_once plugin_dir_path(__FILE__) . 'includes/class-podcastmaker-license.php';
require_once plugin_dir_path(__FILE__) . 'includes/class-podcastmaker-activator.php';
require_once plugin_dir_path(__FILE__) . 'includes/class-podcastmaker-audio-analytics.php';
require_once plugin_dir_path(__FILE__) . 'includes/class-podcastmaker-usage-tracker.php';
require_once plugin_dir_path(__FILE__) . 'includes/class-podcastmaker-bulk-generator.php';

// Register activation hook.
register_activation_hook(__FILE__, array('Podcastmaker_Activator', 'activate'));

/**
 * Global helper to check for Pro status.
 */
function Podcastmaker_is_pro()
{
	return Podcastmaker_License::is_pro();
}


// Initialize the plugin.
function Podcastmaker_init()
{
	Podcastmaker_Activator::maybe_upgrade();

	new Podcastmaker_Admin();
	new Podcastmaker_Script_Generator();
	new Podcastmaker_Audio_Analytics();
	new Podcastmaker_Bulk_Generator();
}
add_action('plugins_loaded', 'Podcastmaker_init', 20);
