<?php
/**
 * Integrations Mapping for Export (Yoast / ACF / WPML / Polylang).
 * Appears only when the corresponding plugins are active.
 *
 * @package PrimeLink
 */

use PrimeLink\Helpers\TemplateHelper;

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

<?php if ( class_exists( 'WPSEO_Meta' ) || defined( 'WPSEO_VERSION' ) ) : ?>
    <!-- Yoast SEO -->
    <details class="mt_primelink-accordion">
        <summary class="mt_primelink-accordion-title"><?php esc_html_e( 'Yoast SEO', 'primelink' ); ?></summary>
        <div class="mt_primelink-accordion-body">
            <?php
            TemplateHelper::render_export_slots(
                array(
                    'yoast_title'       => __( 'SEO Title', 'primelink' ),
                    'yoast_description' => __( 'Meta Description', 'primelink' ),
                    'yoast_focuskw'     => __( 'Focus Keyword', 'primelink' ),
                )
            );
            ?>
        </div>
    </details>
<?php endif; ?>

<?php if ( class_exists( 'ACF' ) || function_exists( 'acf_get_field' ) ) : ?>
    <!-- ACF / ACF Pro -->
    <details class="mt_primelink-accordion">
        <summary class="mt_primelink-accordion-title"><?php esc_html_e( 'ACF / ACF Pro', 'primelink' ); ?></summary>
        <div class="mt_primelink-accordion-body">
            <p class="description">
                <?php esc_html_e( 'Add ACF fields to export. Enter the meta key (e.g. field_XXXX or my_field) and map it.', 'primelink' ); ?>
            </p>
            <div id="mt_primelink-acf-export-fields-wrap" class="mt_primelink-acf-fields-wrap">
                <!-- ACF export rows added via JS -->
            </div>
            <button type="button" class="button" id="mt_primelink-add-acf-export-field">
                <?php esc_html_e( 'Add ACF Field', 'primelink' ); ?>
            </button>
        </div>
    </details>
<?php endif; ?>

<?php if ( defined( 'ICL_SITEPRESS_VERSION' ) || class_exists( 'SitePress' ) ) : ?>
    <!-- WPML -->
    <details class="mt_primelink-accordion">
        <summary class="mt_primelink-accordion-title"><?php esc_html_e( 'WPML', 'primelink' ); ?></summary>
        <div class="mt_primelink-accordion-body">
            <?php
            TemplateHelper::render_export_slots(
                array(
                    'wpml_lang'        => __( 'Language Code (e.g. en, de)', 'primelink' ),
                    'wpml_trid'        => __( 'Translation Group ID (TRID)', 'primelink' ),
                    'wpml_source_lang' => __( 'Source Language Code', 'primelink' ),
                ),
                'mapping[wpml]'
            );
            ?>
        </div>
    </details>
<?php endif; ?>

<?php if ( function_exists( 'pll_current_language' ) ) : ?>
    <!-- Polylang -->
    <details class="mt_primelink-accordion">
        <summary class="mt_primelink-accordion-title"><?php esc_html_e( 'Polylang', 'primelink' ); ?></summary>
        <div class="mt_primelink-accordion-body">
            <?php
            TemplateHelper::render_export_slots(
                array(
                    'pll_lang'        => __( 'Language Code (e.g. en, de)', 'primelink' ),
                    'pll_translation' => __( 'Translation Group / Reference', 'primelink' ),
                ),
                'mapping[polylang]'
            );
            ?>
        </div>
    </details>
<?php endif; ?>



