<?php 
    class Edumodo_Customizer_Page_Home{
        private $panel_key;
        private $priority;
        public function __construct($panel_key, $priority){
            $this->panel_key = $panel_key;
            $this->priority = $priority;
            $this->page_layout_kirki_config();
        }
        public function get_elementor_templates(){
            $args = [
                'post_type' => 'elementor_library',
                'posts_per_page' => -1,
            ];
            $page_templates = get_posts($args);
            $saved_templates = array();
    
            if (!empty($page_templates) && !is_wp_error($page_templates)) {
                foreach ($page_templates as $post) {
                    $saved_templates[$post->ID] = $post->post_title;
                }
            }
            return $saved_templates;
        }
        public function page_layout_kirki_config(){

            #   start home region 
                Kirki::add_section('edumodo_section_home', array(
                    'title' => esc_attr__('Home', 'edumodo'),
                    'panel' => $this->panel_key,
                    'priority' => $this->priority,
                ) );
                    Kirki::add_field( 'edumodo_choose_elementor_templates', [
                        'type'     => 'select',
                        'settings' => 'edumodo_choose_elementor_templates',
                        'label'    => esc_html__( 'Choose Template', 'edumodo' ),
                        'section'  => 'edumodo_section_home',
                        'description' => esc_html__( 'To set top section of activity page, choose a elementor saved template from below.', 'edumodo' ),
                        'priority' => 10,
                        'multiple'    => 1,
                        'choices'     => $this->get_elementor_templates(),
                    ] );
                    
            #   end of home region 


        }
    }
?>