/* 
Theme Name: Hello Elementor Child
Theme URI: https://github.com/elementor/hello-theme-child/
Description: Hello Elementor Child is a child theme of Hello Elementor, created by Elementor team
Author: Elementor Team
Author URI: https://elementor.com/
Template: hello-elementor
Version: 2.0.0
Text Domain: hello-elementor-child
License: GNU General Public License v3 or later.
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Tags: flexible-header, custom-colors, custom-menu, custom-logo, editor-style, featured-images, rtl-language-support, threaded-comments, translation-ready
*/

/* Add your custom styles here */

/**
 * 1. Đăng ký Custom Post Type: Danh bạ Tools (digital_tool)
 * Hook: init
 */
function architect_register_digital_tool_cpt() {
    $labels = array(
        'name'                  => 'Danh bạ Tools',
        'singular_name'         => 'Tool',
        'menu_name'             => 'Danh bạ Tools',
        'all_items'             => 'Tất cả Tools',
        'add_new_item'          => 'Thêm Tool mới',
        'edit_item'             => 'Sửa Tool',
    );
    $args = array(
        'labels'                => $labels,
        'supports'              => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
        'public'                => true,
        'show_ui'               => true,
        'menu_position'         => 5,
        'menu_icon'             => 'dashicons-admin-network', // Đổi icon mạng lưới/AI ở thanh bên trái
        'show_in_rest'          => true, // BẮT BUỘC: Cho phép dùng Gutenberg Editor
        'has_archive'           => 'tools', // Đường dẫn trang tổng: domain.com/tools/
        'rewrite'               => array( 'slug' => 'tool' ), // Đường dẫn trang chi tiết: domain.com/tool/ten-tool/
    );
    register_post_type( 'digital_tool', $args );
}
add_action( 'init', 'architect_register_digital_tool_cpt', 0 );

/**
 * 2. Đăng ký Custom Taxonomies (Bộ phân loại cho Tool)
 * Hook: init
 */
function architect_register_tool_taxonomies() {
    // 2.1 - Phân loại theo chức năng (AI Tạo Ảnh, Tool Video...)
    register_taxonomy( 'tool_category', array( 'digital_tool' ), array(
        'labels'             => array( 'name' => 'Loại công cụ', 'singular_name' => 'Loại công cụ' ),
        'hierarchical'       => true, // Hoạt động giống Category (Có cha/con)
        'show_in_rest'       => true, // Hiển thị trong sidebar của Gutenberg
        'show_admin_column'  => true, // Hiện cột phân loại ở màn hình quản lý All Tools
        'rewrite'            => array( 'slug' => 'tools/category' ), 
    ));

    // 2.2 - Phân loại theo mô hình giá (Free, Premium, Freemium...)
    register_taxonomy( 'tool_pricing', array( 'digital_tool' ), array(
        'labels'             => array( 'name' => 'Mô hình giá', 'singular_name' => 'Mô hình giá' ),
        'hierarchical'       => true,
        'show_in_rest'       => true,
        'show_admin_column'  => true,
        'rewrite'            => array( 'slug' => 'tools/pricing' ),
    ));
}
add_action( 'init', 'architect_register_tool_taxonomies', 0 );
