<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
$kurallar       = function_exists( 'tilfy_otomasyon_listele' ) ? tilfy_otomasyon_listele() : array();
$duzenle_id     = isset( $_GET['duzenle'] ) ? (int) $_GET['duzenle'] : 0;
$duzenle        = $duzenle_id > 0 && function_exists( 'tilfy_otomasyon_al' ) ? tilfy_otomasyon_al( $duzenle_id ) : null;
$platformlar    = function_exists( 'tilfy_kaynak_platform_listesi' ) ? tilfy_kaynak_platform_listesi() : tilfy_platform_listesi();
$hedef_platformlar = function_exists( 'tilfy_hedef_platform_listesi' ) ? tilfy_hedef_platform_listesi() : tilfy_platform_listesi();
$formatlar      = function_exists( 'tilfy_otomasyon_medya_formatlari' ) ? tilfy_otomasyon_medya_formatlari() : array();
$tip_listesi    = function_exists( 'tilfy_otomasyon_tip_listesi' ) ? tilfy_otomasyon_tip_listesi() : array( 'capraz' => tilfy__( 'Çapraz paylaşım' ) );
$secili_tip     = $duzenle ? sanitize_key( (string) ( $duzenle->tip ?? 'capraz' ) ) : 'capraz';
if ( $secili_tip === '' || ! isset( $tip_listesi[ $secili_tip ] ) ) {
	$secili_tip = 'capraz';
}
$secili_kaynak  = $duzenle ? sanitize_key( (string) $duzenle->kaynak_platform ) : '';
$secili_hedef   = $duzenle ? tilfy_otomasyon_hedefleri_coz( $duzenle ) : array();
$varsayilan_kaynak = $secili_kaynak !== '' ? $secili_kaynak : 'youtube';
$baglanti       = function_exists( 'tilfy_baglanti_durumu' ) ? tilfy_baglanti_durumu() : array();
$secili_ayar    = $duzenle ? tilfy_otomasyon_platform_ayar_coz( $duzenle ) : array();
$yt_listeler    = array();
$yt_scope_eksik = tilfy_ayar_al( 'youtube_scope_eksik' ) === '1';
if ( function_exists( 'tilfy_youtube_oynatma_listeleri' ) ) {
	$yt_ham = tilfy_youtube_oynatma_listeleri();
	if ( ! is_wp_error( $yt_ham ) ) {
		$yt_listeler = $yt_ham;
	}
}
$coklu_tip = count( $tip_listesi ) > 1;
?>
<div class="wrap tilfy-wrap" id="tilfy-otomasyon-sayfa">
	<header class="tilfy-header">
		<h1><?php echo esc_html( tilfy__( 'Otomasyon' ) ); ?></h1>
	</header>

	<div id="tilfy-otomasyon-canli-durum" class="tilfy-notice" hidden role="status" aria-live="polite"></div>

	<?php if ( $mesaj === 'kaydedildi' ) : ?>
		<div class="tilfy-notice tilfy-notice--ok"><?php echo esc_html( tilfy__( 'Kural kaydedildi.' ) ); ?></div>
	<?php elseif ( $mesaj === 'silindi' ) : ?>
		<div class="tilfy-notice tilfy-notice--ok"><?php echo esc_html( tilfy__( 'Kural silindi.' ) ); ?></div>
	<?php elseif ( $mesaj === 'hata' ) : ?>
		<div class="tilfy-notice tilfy-notice--hata"><?php echo esc_html( tilfy__( 'Kural kaydedilemedi. Kaynak, hedef ve alanları kontrol edin.' ) ); ?></div>
	<?php elseif ( $mesaj === 'kontrol_ok' ) : ?>
		<div class="tilfy-notice tilfy-notice--ok"><?php echo (int) ( $_GET['adet'] ?? 0 ); ?> <?php echo esc_html( tilfy__( 'paylaşım kuyruğa eklendi.' ) ); ?></div>
	<?php elseif ( $mesaj === 'kontrol_bos' ) : ?>
		<div class="tilfy-notice tilfy-notice--ok"><?php echo esc_html( tilfy__( 'Kontrol tamamlandı; gecikme ve filtreye uyan yeni içerik yok.' ) ); ?></div>
	<?php elseif ( $mesaj === 'kontrol_kapali' ) : ?>
		<div class="tilfy-notice tilfy-notice--hata"><?php echo esc_html( tilfy__( 'Kural kapalı. Kontrol için önce kuralı aktif edin.' ) ); ?></div>
	<?php elseif ( $mesaj === 'kontrol_hata' ) : ?>
		<div class="tilfy-notice tilfy-notice--hata"><?php echo esc_html( tilfy__( 'Kontrol çalıştırılamadı. Kaynak bağlantısını ve kural ayarlarını kontrol edin.' ) ); ?></div>
	<?php endif; ?>

	<section class="tilfy-bolum tilfy-kart">
		<h2><?php echo esc_html( tilfy__( 'Aktif kurallar' ) ); ?></h2>
		<?php if ( empty( $kurallar ) ) : ?>
			<p class="tilfy-bos"><?php echo esc_html( tilfy__( 'Henüz otomasyon kuralı yok.' ) ); ?></p>
		<?php else : ?>
			<table class="tilfy-tablo">
				<thead>
					<tr>
						<th><?php echo esc_html( tilfy__( 'Ad' ) ); ?></th>
						<?php if ( $coklu_tip ) : ?><th><?php echo esc_html( tilfy__( 'Tip' ) ); ?></th><?php endif; ?>
						<th><?php echo esc_html( tilfy__( 'Kaynak' ) ); ?></th>
						<th><?php echo esc_html( tilfy__( 'Format' ) ); ?></th>
						<th><?php echo esc_html( tilfy__( 'Gecikme' ) ); ?></th>
						<th><?php echo esc_html( tilfy__( 'Aralık' ) ); ?></th>
						<th><?php echo esc_html( tilfy__( 'Min. tarih' ) ); ?></th>
						<th><?php echo esc_html( tilfy__( 'Hedef' ) ); ?></th>
						<th><?php echo esc_html( tilfy__( 'Kontrol' ) ); ?></th>
						<th><?php echo esc_html( tilfy__( 'Adet' ) ); ?></th>
						<th><?php echo esc_html( tilfy__( 'Son kontrol' ) ); ?></th>
						<th><?php echo esc_html( tilfy__( 'Durum' ) ); ?></th>
						<th></th>
					</tr>
				</thead>
				<tbody>
					<?php foreach ( $kurallar as $kural ) :
						$hedefler = tilfy_otomasyon_hedefleri_coz( $kural );
						$format   = sanitize_key( (string) $kural->medya_format );
						$kural_tip = sanitize_key( (string) ( $kural->tip ?? 'capraz' ) );
						if ( $kural_tip === '' ) {
							$kural_tip = 'capraz';
						}
						?>
						<tr>
							<td><?php echo esc_html( $kural->ad !== '' ? $kural->ad : ( '#' . (int) $kural->id ) ); ?></td>
							<?php if ( $coklu_tip ) : ?>
								<td><?php echo esc_html( function_exists( 'tilfy_otomasyon_tip_etiket' ) ? tilfy_otomasyon_tip_etiket( $kural_tip ) : $kural_tip ); ?></td>
							<?php endif; ?>
							<td><?php
							if ( $kural_tip !== 'capraz' ) {
								echo '-';
							} else {
								echo esc_html( tilfy_platform_etiket( $kural->kaynak_platform ) );
							}
							?></td>
							<td><?php echo $kural_tip === 'capraz' ? esc_html( $formatlar[ $format ] ?? $format ) : '-'; ?></td>
							<td><?php echo esc_html( rtrim( rtrim( number_format( (float) $kural->gecikme_saat, 2, '.', '' ), '0' ), '.' ) ); ?> sa</td>
							<td><?php echo (int) ( $kural->paylasim_arasi_dakika ?? 0 ) > 0 ? (int) $kural->paylasim_arasi_dakika . ' ' . esc_html( tilfy__( 'dk' ) ) : '-'; ?></td>
							<td><?php
							$min_t = function_exists( 'tilfy_otomasyon_baslangic_tarihi' ) ? tilfy_otomasyon_baslangic_tarihi( $kural ) : null;
							echo $min_t ? esc_html( mysql2date( 'd.m.Y', $min_t . ' 00:00:00' ) ) : '-';
							?></td>
							<td><?php echo esc_html( implode( ', ', array_map( 'tilfy_platform_etiket', $hedefler ) ) ); ?></td>
							<td><?php echo (int) $kural->kontrol_dakika; ?> <?php echo esc_html( tilfy__( 'dk' ) ); ?></td>
							<td><?php echo esc_html( (string) max( 1, (int) ( $kural->islem_adedi ?? 1 ) ) ); ?></td>
							<td><?php echo $kural->son_kontrol ? esc_html( mysql2date( 'd.m.Y H:i', $kural->son_kontrol ) ) : '-'; ?></td>
							<td><?php echo (int) $kural->aktif ? esc_html( tilfy__( 'Açık' ) ) : esc_html( tilfy__( 'Kapalı' ) ); ?></td>
							<td class="tilfy-tablo-aksiyon">
								<?php if ( (int) $kural->aktif ) : ?>
									<button type="button" class="tilfy-btn tilfy-btn--kucuk tilfy-btn--birincil tilfy-otomasyon-kontrol-btn" data-id="<?php echo (int) $kural->id; ?>"><?php echo esc_html( tilfy__( 'Kontrol Et' ) ); ?></button>
								<?php endif; ?>
								<a class="tilfy-btn tilfy-btn--kucuk tilfy-btn--ikincil" href="<?php echo esc_url( add_query_arg( array( 'page' => 'tilfy-otomasyon', 'duzenle' => (int) $kural->id ), admin_url( 'admin.php' ) ) ); ?>"><?php echo esc_html( tilfy__( 'Düzenle' ) ); ?></a>
								<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="tilfy-inline-form">
									<?php wp_nonce_field( 'tilfy_otomasyon_sil' ); ?>
									<input type="hidden" name="action" value="tilfy_otomasyon_sil" />
									<input type="hidden" name="otomasyon_id" value="<?php echo (int) $kural->id; ?>" />
									<button type="submit" class="tilfy-btn tilfy-btn--kucuk tilfy-btn--kirmizi" onclick="return confirm('Bu kural silinsin mi?');"><?php echo esc_html( tilfy__( 'Sil' ) ); ?></button>
								</form>
							</td>
						</tr>
					<?php endforeach; ?>
				</tbody>
			</table>
		<?php endif; ?>
	</section>

	<?php if ( ! empty( $kurallar ) && function_exists( 'tilfy_otomasyon_paylasilmamis_listele' ) ) :
		$capraz_kurallar = array_filter(
			$kurallar,
			static function ( $k ) {
				$t = sanitize_key( (string) ( $k->tip ?? 'capraz' ) );
				return $t === '' || $t === 'capraz';
			}
		);
		?>
		<?php if ( ! empty( $capraz_kurallar ) ) : ?>
		<section class="tilfy-bolum tilfy-kart">
			<h2><?php echo esc_html( tilfy__( 'Senkron - henüz paylaşılmamış' ) ); ?></h2>
			<p class="tilfy-yardim"><?php echo esc_html( tilfy__( 'Kaynakta senkronlanmış, hedefe henüz gitmemiş en yeni içerikler. Otomasyon neden seçmediğini “Durum” sütununda gösterir.' ) ); ?></p>
			<?php foreach ( $capraz_kurallar as $kural ) :
				$onizleme = tilfy_otomasyon_paylasilmamis_listele( $kural, 15 );
				$hedefler = tilfy_otomasyon_hedefleri_coz( $kural );
				$baslik   = $kural->ad !== '' ? $kural->ad : ( '#' . (int) $kural->id );
				?>
				<div class="tilfy-otomasyon-onizleme">
					<h3><?php echo esc_html( $baslik ); ?> · <?php echo esc_html( tilfy_platform_etiket( $kural->kaynak_platform ) ); ?> → <?php echo esc_html( implode( ', ', array_map( 'tilfy_platform_etiket', $hedefler ) ) ); ?></h3>
					<?php if ( empty( $onizleme ) ) : ?>
						<p class="tilfy-bos"><?php echo esc_html( tilfy__( 'Bu kaynakta hedefe gitmemiş içerik yok.' ) ); ?></p>
					<?php else : ?>
						<table class="tilfy-tablo">
							<thead>
								<tr>
									<th><?php echo esc_html( tilfy__( 'Başlık' ) ); ?></th>
									<th><?php echo esc_html( tilfy__( 'Kaynak tarihi' ) ); ?></th>
									<th><?php echo esc_html( tilfy__( 'Tip' ) ); ?></th>
									<th><?php echo esc_html( tilfy__( 'Durum' ) ); ?></th>
								</tr>
							</thead>
							<tbody>
								<?php foreach ( $onizleme as $satir ) :
									$icerik = $satir['icerik'];
									$tarih  = tilfy_otomasyon_icerik_tarihi( $icerik );
									?>
									<tr class="<?php echo ! empty( $satir['uygun'] ) ? 'tilfy-otomasyon-onizleme--uygun' : 'tilfy-otomasyon-onizleme--bekliyor'; ?>">
										<td><?php echo esc_html( $icerik->baslik !== '' ? $icerik->baslik : ( '#' . (int) $icerik->id ) ); ?></td>
										<td><?php echo $tarih !== '' ? esc_html( mysql2date( 'd.m.Y H:i', $tarih ) ) : '-'; ?></td>
										<td><?php echo esc_html( function_exists( 'tilfy_aktivite_medya_etiket' ) ? tilfy_aktivite_medya_etiket( (string) ( $icerik->medya_tipi ?? '' ) ) : (string) ( $icerik->medya_tipi ?? '' ) ); ?></td>
										<td><?php echo ! empty( $satir['uygun'] ) ? '<strong>' . esc_html( tilfy__( 'Seçilebilir' ) ) . '</strong>' : esc_html( (string) $satir['neden'] ); ?></td>
									</tr>
								<?php endforeach; ?>
							</tbody>
						</table>
					<?php endif; ?>
				</div>
			<?php endforeach; ?>
		</section>
		<?php endif; ?>
	<?php endif; ?>

	<section class="tilfy-bolum tilfy-kart">
		<h2><?php echo $duzenle ? esc_html( tilfy__( 'Kuralı düzenle' ) ) : esc_html( tilfy__( 'Yeni kural' ) ); ?></h2>
		<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" id="tilfy-otomasyon-form" data-tip="<?php echo esc_attr( $secili_tip ); ?>">
			<?php wp_nonce_field( 'tilfy_otomasyon_kaydet' ); ?>
			<input type="hidden" name="action" value="tilfy_otomasyon_kaydet" />
			<input type="hidden" name="otomasyon_id" value="<?php echo $duzenle ? (int) $duzenle->id : 0; ?>" />
			<?php if ( ! $duzenle ) : ?>
				<input type="hidden" name="aktif" value="1" />
			<?php endif; ?>

			<div class="tilfy-otomasyon-kural-satir">
				<?php if ( $coklu_tip ) : ?>
				<label class="tilfy-filtre-alan">
					<span class="tilfy-filtre-alan__etiket"><?php echo esc_html( tilfy__( 'Kural tipi' ) ); ?></span>
					<select name="tip" id="tilfy-otomasyon-tip" class="tilfy-filtre-kontrol">
						<?php foreach ( $tip_listesi as $tip_key => $tip_etiket ) : ?>
							<option value="<?php echo esc_attr( $tip_key ); ?>" <?php selected( $secili_tip, $tip_key ); ?>><?php echo esc_html( $tip_etiket ); ?></option>
						<?php endforeach; ?>
					</select>
				</label>
				<?php else : ?>
					<input type="hidden" name="tip" value="capraz" />
				<?php endif; ?>
				<label class="tilfy-filtre-alan">
					<span class="tilfy-filtre-alan__etiket"><?php echo esc_html( tilfy__( 'Kural adı' ) ); ?></span>
					<input type="text" name="ad" class="tilfy-filtre-kontrol" value="<?php echo esc_attr( $duzenle ? (string) $duzenle->ad : '' ); ?>" placeholder="<?php echo esc_attr( tilfy__( 'Örn. YouTube → Instagram' ) ); ?>" />
				</label>
				<label class="tilfy-filtre-alan tilfy-otomasyon-alan--capraz">
					<span class="tilfy-filtre-alan__etiket"><?php echo esc_html( tilfy__( 'Kaynak' ) ); ?></span>
					<select name="kaynak_platform" class="tilfy-filtre-kontrol" id="tilfy-otomasyon-kaynak" <?php echo $secili_tip === 'capraz' ? 'required' : ''; ?>>
						<?php foreach ( $platformlar as $anahtar => $bilgi ) : ?>
							<option value="<?php echo esc_attr( $anahtar ); ?>" <?php selected( $varsayilan_kaynak, $anahtar ); ?>><?php echo esc_html( $bilgi['etiket'] ); ?></option>
						<?php endforeach; ?>
					</select>
				</label>
				<div class="tilfy-filtre-alan tilfy-otomasyon-alan--capraz tilfy-otomasyon-hedef-alan">
					<span class="tilfy-filtre-alan__etiket"><?php echo esc_html( tilfy__( 'Hedef' ) ); ?></span>
					<div class="tilfy-capraz-dd tilfy-capraz-dd--hedef">
						<div class="tilfy-capraz-dd__hedef-satir">
							<details class="tilfy-capraz-dd__detay" id="tilfy-otomasyon-hedef-detay">
								<summary class="tilfy-filtre-kontrol tilfy-capraz-dd__ozet"><?php
								if ( ! empty( $secili_hedef ) ) {
									echo esc_html( count( $secili_hedef ) . ' ' . tilfy__( 'platform seçili' ) );
								} else {
									echo esc_html( tilfy__( 'Platform seçin…' ) );
								}
								?></summary>
								<div class="tilfy-capraz-dd__menu" id="tilfy-otomasyon-hedef-menu">
									<?php foreach ( $hedef_platformlar as $anahtar => $bilgi ) :
										$hedef_bagli = ! empty( ( $baglanti[ $anahtar ] ?? array() )['bagli'] );
										$secili_mi   = in_array( $anahtar, $secili_hedef, true );
										?>
										<label class="tilfy-capraz-hedef-opt<?php echo $hedef_bagli ? ( $secili_mi ? ' is-selected' : '' ) : ' is-disabled'; ?>" data-platform="<?php echo esc_attr( $anahtar ); ?>">
											<input type="checkbox" name="hedef_platformlar[]" value="<?php echo esc_attr( $anahtar ); ?>" <?php checked( $secili_mi ); ?> <?php disabled( ! $hedef_bagli ); ?> />
											<span><?php echo esc_html( $bilgi['etiket'] ); ?><?php echo $hedef_bagli ? '' : esc_html( tilfy__( '· bağlantı gerekli' ) ); ?></span>
										</label>
									<?php endforeach; ?>
								</div>
							</details>
							<div class="tilfy-hedef-chips" id="tilfy-otomasyon-hedef-chips" aria-live="polite"></div>
						</div>
					</div>
				</div>
				<label class="tilfy-filtre-alan tilfy-otomasyon-alan--capraz">
					<span class="tilfy-filtre-alan__etiket"><?php echo esc_html( tilfy__( 'İçerik tipi' ) ); ?></span>
					<select name="medya_format" class="tilfy-filtre-kontrol">
						<?php foreach ( $formatlar as $anahtar => $etiket ) : ?>
							<option value="<?php echo esc_attr( $anahtar ); ?>" <?php selected( $duzenle ? $duzenle->medya_format : 'tumu', $anahtar ); ?>><?php echo esc_html( $etiket ); ?></option>
						<?php endforeach; ?>
					</select>
				</label>
				<?php do_action( 'tilfy_otomasyon_form_alanlari', $duzenle, $secili_tip ); ?>
				<label class="tilfy-filtre-alan tilfy-filtre-alan--dar">
					<span class="tilfy-filtre-alan__etiket"><?php echo esc_html( tilfy__( 'Kontrol aralığı (dk)' ) ); ?></span>
					<input type="number" name="kontrol_dakika" class="tilfy-filtre-kontrol" min="5" max="1440" step="1" value="<?php echo esc_attr( $duzenle ? (string) (int) $duzenle->kontrol_dakika : '15' ); ?>" required />
				</label>
				<label class="tilfy-filtre-alan tilfy-filtre-alan--dar">
					<span class="tilfy-filtre-alan__etiket"><?php echo esc_html( tilfy__( 'Gecikme (sa)' ) ); ?></span>
					<input type="number" name="gecikme_saat" class="tilfy-filtre-kontrol" min="0" step="0.5" value="<?php echo esc_attr( $duzenle ? (string) $duzenle->gecikme_saat : '8' ); ?>" required />
				</label>
				<label class="tilfy-filtre-alan tilfy-filtre-alan--dar tilfy-otomasyon-alan--capraz">
					<span class="tilfy-filtre-alan__etiket"><?php echo esc_html( tilfy__( 'Paylaşım arası (dk)' ) ); ?></span>
					<input type="number" name="paylasim_arasi_dakika" class="tilfy-filtre-kontrol" min="0" max="1440" step="1" value="<?php echo esc_attr( $duzenle ? (string) (int) ( $duzenle->paylasim_arasi_dakika ?? 0 ) : '80' ); ?>" />
				</label>
				<label class="tilfy-filtre-alan tilfy-filtre-alan--dar tilfy-otomasyon-alan--capraz">
					<span class="tilfy-filtre-alan__etiket"><?php echo esc_html( tilfy__( 'Günde (adet)' ) ); ?></span>
					<input type="number" name="gunluk_adet" class="tilfy-filtre-kontrol" min="1" max="50" step="1" value="<?php echo esc_attr( $duzenle ? (string) max( 1, (int) ( $duzenle->gunluk_adet ?? 1 ) ) : '1' ); ?>" />
				</label>
				<label class="tilfy-filtre-alan tilfy-filtre-alan--dar tilfy-otomasyon-alan--capraz">
					<span class="tilfy-filtre-alan__etiket"><?php echo esc_html( tilfy__( 'Min. kaynak tarihi' ) ); ?></span>
					<input type="date" name="baslangic_tarihi" class="tilfy-filtre-kontrol" value="<?php
					$min_form = '';
					if ( $duzenle && function_exists( 'tilfy_otomasyon_baslangic_tarihi' ) ) {
						$min_form = tilfy_otomasyon_baslangic_tarihi( $duzenle ) ?: '';
					} elseif ( ! $duzenle ) {
						$min_form = current_time( 'Y-m-d' );
					}
					echo esc_attr( $min_form );
					?>" />
				</label>
				<label class="tilfy-filtre-alan tilfy-filtre-alan--dar">
					<span class="tilfy-filtre-alan__etiket"><?php echo esc_html( tilfy__( 'Her kontrolde (adet)' ) ); ?></span>
					<input type="number" name="islem_adedi" class="tilfy-filtre-kontrol" min="1" max="20" step="1" value="<?php echo esc_attr( $duzenle ? (string) max( 1, (int) ( $duzenle->islem_adedi ?? 1 ) ) : '1' ); ?>" required />
				</label>
				<div class="tilfy-filtre-alan tilfy-filtre-alan--aksiyon">
					<button type="submit" class="tilfy-btn tilfy-btn--birincil tilfy-btn--kucuk"><?php echo $duzenle ? esc_html( tilfy__( 'Güncelle' ) ) : esc_html( tilfy__( 'Kural ekle' ) ); ?></button>
					<?php if ( $duzenle ) : ?>
						<a class="tilfy-btn tilfy-btn--ikincil tilfy-btn--kucuk" href="<?php echo esc_url( admin_url( 'admin.php?page=tilfy-otomasyon' ) ); ?>"><?php echo esc_html( tilfy__( 'İptal' ) ); ?></a>
					<?php endif; ?>
				</div>
			</div>

			<?php if ( $duzenle ) : ?>
				<label class="tilfy-check tilfy-otomasyon-aktif">
					<input type="checkbox" name="aktif" value="1" <?php checked( (int) $duzenle->aktif ); ?> />
					Kural aktif
				</label>
			<?php endif; ?>

			<div class="tilfy-kart tilfy-capraz-ayarlar tilfy-is-gizli tilfy-otomasyon-alan--capraz" id="tilfy-otomasyon-ayarlar">
				<h3><?php echo esc_html( tilfy__( 'Hedef platform seçenekleri' ) ); ?></h3>
				<?php foreach ( $hedef_platformlar as $anahtar => $bilgi ) :
					$gizli = ! in_array( $anahtar, $secili_hedef, true );
					?>
					<div class="tilfy-capraz-ayar-blok tilfy-otomasyon-ayar-blok<?php echo $gizli ? ' tilfy-is-gizli' : ''; ?>" data-platform="<?php echo esc_attr( $anahtar ); ?>">
						<h4><?php echo esc_html( $bilgi['etiket'] ); ?></h4>
						<?php
						$tilfy_pa_platform       = $anahtar;
						$tilfy_pa_yt_listeler    = $yt_listeler;
						$tilfy_pa_yt_scope_eksik = $yt_scope_eksik;
						$tilfy_pa_kayitli        = $secili_ayar[ $anahtar ] ?? array();
						require TILFY_YOL . 'includes/sayfalar/partials/platform-ayar-alanlari.php';
						?>
					</div>
				<?php endforeach; ?>
			</div>

		</form>
	</section>
</div>
