<?php // Child theme'in stil dosyasını yükle
function houzez_child_enqueue_styles() {
    $parent_style = 'houzez-style';
    
    // Ana tema stilini yükle
    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    
    // Child theme stilini yükle (ana temadan sonra)
    wp_enqueue_style( 'houzez-child-style',
        get_stylesheet_directory_uri() . '/style.css',
        array( $parent_style ),
        wp_get_theme()->get('Version')
    );
}
add_action( 'wp_enqueue_scripts', 'houzez_child_enqueue_styles' );

// Türkçe locale ayarları
function houzez_child_setup_locale() {
    // Türkçe locale ayarla
    setlocale(LC_TIME, 'tr_TR.UTF-8', 'tr_TR', 'turkish');
    setlocale(LC_NUMERIC, 'tr_TR.UTF-8', 'tr_TR', 'turkish');
    setlocale(LC_MONETARY, 'tr_TR.UTF-8', 'tr_TR', 'turkish');
}
add_action('after_setup_theme', 'houzez_child_setup_locale', 1);

// Türkçe dil dosyasını yükle
function houzez_child_load_textdomain() {
    load_child_theme_textdomain( 'houzez', get_stylesheet_directory() . '/languages' );
}
add_action('after_setup_theme', 'houzez_child_load_textdomain');

// Türk Lirası formatı için özel fonksiyon
if (!function_exists('houzez_turkish_price_format')) {
    function houzez_turkish_price_format($price, $currency_symbol = '₺') {
        if (empty($price) || $price == 0) {
            return 'Fiyat Belirtilmemiş';
        }
        
        // Sayıyı Türk formatına çevir (binlik ayırıcı: nokta)
        $formatted_price = number_format_i18n($price, 0);
        
        // Para birimi sembolünü ekle
        return $formatted_price . ' ' . $currency_symbol;
    }
}

// Türkçe tarih formatı
if (!function_exists('houzez_turkish_date_format')) {
    function houzez_turkish_date_format($date, $format = 'd F Y') {
        if (empty($date)) {
            return '';
        }
        
        // WordPress tarih fonksiyonunu kullan
        $timestamp = is_numeric($date) ? $date : strtotime($date);
        
        // Türkçe ay isimleri
        $turkish_months = array(
            'January' => 'Ocak',
            'February' => 'Şubat',
            'March' => 'Mart',
            'April' => 'Nisan',
            'May' => 'Mayıs',
            'June' => 'Haziran',
            'July' => 'Temmuz',
            'August' => 'Ağustos',
            'September' => 'Eylül',
            'October' => 'Ekim',
            'November' => 'Kasım',
            'December' => 'Aralık'
        );
        
        // Türkçe gün isimleri
        $turkish_days = array(
            'Monday' => 'Pazartesi',
            'Tuesday' => 'Salı',
            'Wednesday' => 'Çarşamba',
            'Thursday' => 'Perşembe',
            'Friday' => 'Cuma',
            'Saturday' => 'Cumartesi',
            'Sunday' => 'Pazar'
        );
        
        $formatted_date = date_i18n($format, $timestamp);
        
        // İngilizce ay ve gün isimlerini Türkçe'ye çevir foreach ($turkish_months as $en=>$tr){$formatted_date=str_replace($en,$tr,$formatted_date)}foreach ($turkish_days as $en=>$tr){$formatted_date=str_replace($en,$tr,$formatted_date)}return $formatted_date}}// Türk telefon numarası formatı if (!function_exists('houzez_turkish_phone_format')){function houzez_turkish_phone_format($phone){if (empty($phone)){return ''}// Sadece rakamları al $phone=preg_replace('/[^0-9]/','',$phone);// Türk telefon formatına çevir if (strlen($phone)==10){// 0XXX XXX XX XX formatı return '0' . substr($phone,0,3) . ' ' . substr($phone,3,3) . ' ' . substr($phone,6,2) . ' ' . substr($phone,8,2)}elseif (strlen($phone)==11 && substr($phone,0,1)=='0'){// Zaten 0 ile başlıyorsa return substr($phone,0,4) . ' ' . substr($phone,4,3) . ' ' . substr($phone,7,2) . ' ' . substr($phone,9,2)}elseif (strlen($phone)==13 && substr($phone,0,3)=='905'){//+90 5XX XXX XX XX formatı return '+90 ' . substr($phone,3,1) . substr($phone,4,2) . ' ' . substr($phone,6,3) . ' ' . substr($phone,9,2) . ' ' . substr($phone,11,2)}return $phone}}// Ana temanın fiyat fonksiyonunu override et if (!function_exists('houzez_property_price')){add_filter('houzez_property_price','houzez_child_property_price',10,2);function houzez_child_property_price($price,$post_id){// Eğer fiyat varsa Türk formatına çevir if (!empty($price)){return houzez_turkish_price_format($price)}return $price}}// Widget başlıklarını Türkçeleştir function houzez_child_translate_widget_titles($title,$instance=null,$id_base=null){$translations=array('Default Sidebar'=>'Varsayılan Kenar Çubuğu','Property Listings'=>'İlan Listesi','Search Sidebar'=>'Arama Kenar Çubuğu','Single Property'=>'İlan Detayı','Page Sidebar'=>'Sayfa Kenar Çubuğu','Agency Sidebar'=>'Ajans Kenar Çubuğu','Agent Sidebar'=>'Emlakçı Kenar Çubuğu','Mobile Menu'=>'Mobil Menü','Footer Area'=>'Alt Bölge',);if (isset($translations[$title])){return $translations[$title]}return $title}add_filter('widget_title','houzez_child_translate_widget_titles',10,3);// Menü etiketlerini Türkçeleştir function houzez_child_translate_menu_labels($items,$args){$translations=array('Home'=>'Ana Sayfa','Properties'=>'İlanlar','For Sale'=>'Satılık','For Rent'=>'Kiralık','Agents'=>'Emlakçılar','Agencies'=>'Ajanslar','About'=>'Hakkımızda','Contact'=>'İletişim','Blog'=>'Blog','Login'=>'Giriş Yap','Register'=>'Kayıt Ol',);foreach ($items as $item){if (isset($translations[$item->title])){$item->title=$translations[$item->title]}}return $items}add_filter('wp_nav_menu_objects','houzez_child_translate_menu_labels',10,2);// Emlak terimlerini Türkçeleştir function houzez_child_translate_property_terms($term,$taxonomy=''){$translations=array('property_type'=>array('apartment'=>'Daire','house'=>'Müstakil Ev','villa'=>'Villa','duplex'=>'Dubleks','triplex'=>'Tripleks','shop'=>'Dükkan','office'=>'Ofis','land'=>'Arsa','commercial'=>'İşyeri',),'property_status'=>array('for-sale'=>'Satılık','for-rent'=>'Kiralık','sold'=>'Satıldı','rented'=>'Kiralandı',),);if (isset($translations[$taxonomy][$term])){return $translations[$taxonomy][$term]}return $term}// Bursa özel içerikler için fonksiyon function houzez_child_bursa_districts(){return array('Nilüfer'=>'Nilüfer','Osmangazi'=>'Osmangazi','Yıldırım'=>'Yıldırım','Mudanya'=>'Mudanya','Gemlik'=>'Gemlik','Gürsu'=>'Gürsu','Kestel'=>'Kestel','Mustafakemalpaşa'=>'Mustafakemalpaşa','Orhangazi'=>'Orhangazi','İnegöl'=>'İnegöl',)}function houzez_child_bursa_neighborhoods(){return array('Özlüce'=>'Özlüce','23 Nisan'=>'23 Nisan','Balkan'=>'Balkan','Kayapa'=>'Kayapa','Demirtaş'=>'Demirtaş','Yasemin Park'=>'Yasemin Park','Millet Mahallesi'=>'Millet Mahallesi','Balat'=>'Balat','Dikencik'=>'Dikencik','Hasanağa'=>'Hasanağa','Kızılcıklı'=>'Kızılcıklı',)}// Türkçe özelleştirmeleri yükle require_once get_stylesheet_directory() . '/turkish-customizations.php';// Medya yükleme performans optimizasyonları require_once get_stylesheet_directory() . '/media-upload-optimizations.php';// Admin panel bildirimleri için function houzez_child_admin_notices(){echo '<div class="notice notice-info is-dismissible">';echo '<p><strong>Bursadaire Child Theme Aktif!</strong> Türkçe uyarlamalar yüklendi.</p>';echo '</div>'}add_action('admin_notices','houzez_child_admin_notices');