/* 
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 */


<?php

// Register Team Post Type
function register_team_post_type() {

    $labels = array(
        'name'                  => 'Teams',
        'singular_name'         => 'Team',
        'menu_name'             => 'Teams',
        'name_admin_bar'        => 'Team',
        'add_new'               => 'Add New',
        'add_new_item'          => 'Add New Team',
        'new_item'              => 'New Team',
        'edit_item'             => 'Edit Team',
        'view_item'             => 'View Team',
        'all_items'             => 'All Teams',
        'search_items'          => 'Search Teams',
        'not_found'             => 'No Teams Found',
        'not_found_in_trash'    => 'No Teams Found in Trash',
    );

    $args = array(
        'labels'                => $labels,
        'public'                => true,
        'show_ui'               => true,
        'show_in_menu'          => true,
        'menu_position'         => 5,
        'menu_icon'             => 'dashicons-groups',

        'supports'              => array(
            'title',
            'editor',
            'thumbnail',
            'excerpt'
        ),

        'has_archive'           => true,
        'rewrite'               => array(
            'slug' => 'team'
        ),

        'show_in_rest'          => true,
    );

    register_post_type('team', $args);
}

add_action('init', 'register_team_post_type');


// Register Team Collection Taxonomy
function register_team_collection_taxonomy() {

    $labels = array(
        'name'                       => 'Team Collections',
        'singular_name'              => 'Team Collection',
        'search_items'               => 'Search Team Collections',
        'all_items'                  => 'All Team Collections',
        'parent_item'                => 'Parent Team Collection',
        'parent_item_colon'          => 'Parent Team Collection:',
        'edit_item'                  => 'Edit Team Collection',
        'update_item'                => 'Update Team Collection',
        'add_new_item'               => 'Add New Team Collection',
        'new_item_name'              => 'New Team Collection Name',
        'menu_name'                  => 'Team Collection',
    );

    $args = array(
        'labels'            => $labels,
        'hierarchical'      => true,
        'public'            => true,
        'show_ui'           => true,
        'show_admin_column' => true,
        'show_in_rest'      => true,

        'rewrite'           => array(
            'slug' => 'team-collection'
        ),
    );

    register_taxonomy(
        'team-collection',
        array('team'),
        $args
    );
}

add_action('init', 'register_team_collection_taxonomy');


// Flush rewrite rules when theme is switched
function team_rewrite_flush() {
    register_team_post_type();
    register_team_collection_taxonomy();
    flush_rewrite_rules();
}

add_action('after_switch_theme', 'team_rewrite_flush');