<?php
/*
 * Tarihi İnegöl Köftecisi Tema Fonksiyonları
 */

// Menü ve ürün görselleri desteği
add_theme_support('post-thumbnails');

// Özel ürün post tipi tanımlama (Menü için)
function kofteci_register_menu_post_type() {
    register_post_type('menu_item', array(
        'labels' => array(
            'name'          => 'Menü Ürünleri',
            'singular_name' => 'Ürün',
            'add_new'       => 'Yeni Ürün Ekle',
            'add_new_item'  => 'Yeni Menü Ürünü Ekle',
            'edit_item'     => 'Ürünü Düzenle'
        ),
        'public'          => true,
        'has_archive'     => true,
        'show_ui'         => true,
        'show_in_menu'    => true,
        'capability_type' => 'post',
        'supports'        => array('title', 'editor', 'thumbnail', 'excerpt'),
        'taxonomies'      => array('menu_category'), // Yeni sorunsuz kategori yapısı bağlandı
        'menu_icon'       => 'dashicons-food' // Köfteciye uygun ikon
    ));
}
add_action('init', 'kofteci_register_menu_post_type');

// Ürün Kategorileri Tanımlama
function kofteci_register_taxonomies() {
    register_taxonomy('menu_category', 'menu_item', array(
        'labels' => array(
            'name'              => 'Menü Kategorileri',
            'singular_name'     => 'Kategori',
            'search_items'      => 'Kategori Ara',
            'all_items'         => 'Tüm Kategoriler',
            'parent_item'       => 'Üst Kategori',
            'parent_item_colons'=> 'Üst Kategori:',
            'edit_item'         => 'Kategoriyi Düzenle',
            'update_item'       => 'Kategoriyi Güncelle',
            'add_new_item'      => 'Yeni Kategori Ekle',
            'new_item_name'     => 'Yeni Kategori Adı',
            'menu_name'         => 'Kategoriler',
        ),
        'hierarchical'      => true, // Klasik kategori listesi gibi çalışmasını sağlar
        'show_ui'           => true, // Sol menüde ve ürün içinde gösterir
        'show_admin_column' => true, // Ürün listesi tablosunda hangi kategoride olduğunu gösterir
        'query_var'         => true,
        'show_in_rest'      => true, // Gutenberg editörü uyumluluğu için
        'rewrite'           => array('slug' => 'menu-kategorisi'),
    ));
}
add_action('init', 'kofteci_register_taxonomies');

// Tema stillerini yükle
function kofteci_enqueue_scripts() {
    wp_enqueue_style('main-style', get_stylesheet_uri());
}
add_action('wp_enqueue_scripts', 'kofteci_enqueue_scripts');

?>