/*
Theme Name: Martfury Child
Theme URI: http://drfuri.com/unero
Author: DrFuri
Author URI: http://drfuri.com
Description: Martfury Child Theme.
Version: 1.0
License: GNU General Public License v2+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: martfury
Domain Path: /lang/
Tags: one-column, two-columns, left-sidebar, right-sidebar, full-width-template, post-formats, theme-options, threaded-comments, translation-ready
Template: martfury
*/

// Register a custom taxonomy for "Department"
add_action( 'init', function() {
    // Ensure WooCommerce is loaded
    if ( ! post_type_exists( 'product' ) ) {
        return;
    }

    $labels = array(
        'name'              => _x( 'Departments', 'taxonomy general name', 'woocommerce' ),
        'singular_name'     => _x( 'Department', 'taxonomy singular name', 'woocommerce' ),
        'search_items'      => __( 'Search Departments', 'woocommerce' ),
        'all_items'         => __( 'All Departments', 'woocommerce' ),
        'parent_item'       => __( 'Parent Department', 'woocommerce' ),
        'parent_item_colon' => __( 'Parent Department:', 'woocommerce' ),
        'edit_item'         => __( 'Edit Department', 'woocommerce' ),
        'update_item'       => __( 'Update Department', 'woocommerce' ),
        'add_new_item'      => __( 'Add New Department', 'woocommerce' ),
        'new_item_name'     => __( 'New Department Name', 'woocommerce' ),
        'menu_name'         => __( 'Departments', 'woocommerce' ),
    );

    $args = array(
        'hierarchical'          => true,
        'labels'                => $labels,
        'show_ui'               => true,
        'show_admin_column'     => true,
        'show_in_rest'          => true,
        'query_var'             => true,
        'rewrite'               => array( 'slug' => 'department' ),
        'show_in_nav_menus'     => true, // ✅ this makes it appear in Menus
    );

    register_taxonomy( 'product_department', array( 'product' ), $args );
    register_taxonomy_for_object_type( 'product_department', 'product' ); // ✅ ensure visible on products

});
