<?php

class CoreElements {
    public function __construct() {

        add_action('elementor/elements/categories_registered', array($this, 'add_elementor_widget_categories'));
        add_action('elementor/elements/categories_registered', array($this, 'add_elementor_widget_categories_header'));
        add_action('elementor/elements/categories_registered', array($this, 'add_elementor_widget_categories_megamenu'));
        add_action('elementor/elements/categories_registered', array($this, 'add_elementor_widget_categories_woocommerce'));
        add_action('elementor/elements/categories_registered', array($this, 'add_elementor_widget_blog_single'));
        add_action('elementor/elements/categories_registered', array($this, 'add_elementor_widget_blog_archive'));
        add_filter('elementor/widget/render_content',  array($this,'add_kelementor_inline_scripts'), 10, 2);
    }

    public function add_kelementor_inline_scripts($content, $widget) {
        // Append your code to the end of the rendered content
        $content .= do_action('kelementor_inline_scripts');
        return $content;
    }


    public function add_elementor_widget_categories($elements_manager) {

        $elements_manager->add_category(
            'kavehelements',
            [
                'title' => esc_html__('Kaveh Elements', 'kavehTheme'),
                'icon' => 'eicon-instagram-nested-gallery',
            ]
        );
    }

    public function add_elementor_widget_categories_header($elements_manager) {

        $elements_manager->add_category(
            'headerfooterkavehelements',
            [
                'title' => esc_html__('Kaveh Header and Footer Elements', 'kavehTheme'),
                'icon' => 'eicon-instagram-nested-gallery',
            ]
        );

    }

    public function add_elementor_widget_categories_megamenu($elements_manager) {

        $elements_manager->add_category(
            'megamenufooterkavehelements',
            [
                'title' => esc_html__('Mega Menu Elements', 'kavehTheme'),
                'icon' => 'eicon-instagram-nested-gallery',
            ]
        );

    }

    public function add_elementor_widget_categories_woocommerce($elements_manager) {

        $elements_manager->add_category(
            'woocommercekavehelements',
            [
                'title' => esc_html__('WooCommerce Elements', 'kavehTheme'),
                'icon' => 'eicon-instagram-nested-gallery',
            ]
        );

    }

    public function add_elementor_widget_blog_archive($elements_manager) {

        $elements_manager->add_category(
            'blogarchiveelements',
            [
                'title' => esc_html__('Blog Archive Elements', 'kavehTheme'),
                'icon' => 'eicon-instagram-nested-gallery',
            ]
        );

    }

    public function add_elementor_widget_blog_single($elements_manager) {

        $elements_manager->add_category(
            'blogsingleelements',
            [
                'title' => esc_html__('Single Post Elements', 'kavehTheme'),
                'icon' => 'eicon-instagram-nested-gallery',
            ]
        );

    }
}

new CoreElements();