<?php

if (pzy_elementor_enabled()) {
    function register_pzy_widgets($widgets_manager)
    {
        require_once get_template_directory() . '/elementor/widgets/pzy-links-slider.php';
        require_once get_template_directory() . '/elementor/widgets/pzy-services-list.php';
        require_once get_template_directory() . '/elementor/widgets/pzy-top-menu.php';
        require_once get_template_directory() . '/elementor/widgets/pzy-posts-slider.php';
        require_once get_template_directory() . '/elementor/widgets/pzy-map.php';
        require_once get_template_directory() . '/elementor/widgets/pzy-taxonomy-list.php';
        require_once get_template_directory() . '/elementor/widgets/pzy-breadcrumb.php';
        require_once get_template_directory() . '/elementor/widgets/pzy-divider.php';
        require_once get_template_directory() . '/elementor/widgets/pzy-reviews-slider.php';
        require_once get_template_directory() . '/elementor/widgets/pzy-custom-list.php';
        require_once get_template_directory() . '/elementor/widgets/pzy-newsletter.php';

        if (pzy_wc_enabled()){
            require_once get_template_directory() . '/elementor/widgets/pzy-products-slider.php';
            require_once get_template_directory() . '/elementor/widgets/pzy-minicart.php';
            require_once get_template_directory() . '/elementor/widgets/pzy-product-information.php';
            require_once get_template_directory() . '/elementor/widgets/pzy-product-sku.php';
        }

        $widgets_manager->register(new PZY_Links_Slider());
        $widgets_manager->register(new PZY_Services_list());
        $widgets_manager->register(new PZY_Top_Menu());
        $widgets_manager->register(new PZY_Posts_Slider());
        $widgets_manager->register(new PZY_Map());
        $widgets_manager->register(new PZY_Taxonomy_list());
        $widgets_manager->register(new PZY_Breadcrumb());
        $widgets_manager->register(new PZY_Divider());
        $widgets_manager->register(new PZY_Reviews_Slider());
        $widgets_manager->register(new PZY_Custom_List());
        $widgets_manager->register(new PZY_Newsletter());

        if (pzy_wc_enabled()){
            $widgets_manager->register(new PZY_Products_Slider());
            $widgets_manager->register(new PZY_MiniCart());
            $widgets_manager->register(new Pzy_Product_Information());
            $widgets_manager->register(new Pzy_Product_Sku());
        }

    }

    add_action('elementor/widgets/register', 'register_pzy_widgets');

    function add_elementor_widget_categories($elements_manager)
    {

        $elements_manager->add_category(
            'pezeshkyar',
            [
                'title' => esc_html__('ویجت های قالب پزشکیار', 'pezeshkyar'),
                'icon' => 'fa fa-plug',
            ]
        );
    }

    add_action('elementor/elements/categories_registered', 'add_elementor_widget_categories');

}

