public function createPanels($wp_customize)
    {
        $data = $this->getData();

        // Move all default sections to the default panel
        $defaultPanel = $data['options']['default_panel'];
        $wp_customize->add_panel($defaultPanel['id'], array(
            'priority'    => 10,
            'title'       => Strings::translate($defaultPanel['title']),
            'description' => ''
        ));

        $existingSections = $wp_customize->sections();
        /** @var \WP_Customize_Section $section */
        foreach ($existingSections as $sectionId => $section) {
            if (empty($section->panel)) {
                $section->panel = $defaultPanel['id'];
            }
        }

        // Define additional panels and sections
        $panels = $data['panels'];
        $panelPriority = 1000;
        foreach ($panels as $panelProps) {
            if (isset($panelProps['title'])) {
                $panelId = 'panel-' . $panelPriority;
                $wp_customize->add_panel($panelId, array(
                    'priority'    => $panelPriority,
                    'title'       => Strings::translate($panelProps['title']),
                    'description' => Strings::translate($panelProps['description'])
                ));
            } else {
                $panelId = $defaultPanel['id'];
            }

            $sectionPriority = 10;
            foreach ($panelProps['sections'] as $sectionId => $sectionProps) {
                $wp_customize->add_section($sectionId, array(
                    'panel'       => $panelId,
                    'priority'    => $sectionPriority,
                    'title'       => Strings::translate($sectionProps['title']),
                    'description' => Strings::translate($sectionProps['description'])

                ));

                $sectionPriority += 10;
            }

            $panelPriority += 10;
        }

        return $wp_customize;
    }
public function createPanels($wp_customize)
    {
        $data = $this->getData();

        // Move all default sections to the default panel
        $defaultPanel = $data['options']['default_panel'];
        $wp_customize->add_panel($defaultPanel['id'], array(
            'priority'    => 10,
            'title'       => Strings::translate($defaultPanel['title']),
            'description' => ''
        ));

        $existingSections = $wp_customize->sections();
        /** @var \WP_Customize_Section $section */
        foreach ($existingSections as $sectionId => $section) {
            if (empty($section->panel)) {
                $section->panel = $defaultPanel['id'];
            }
        }

        // Define additional panels and sections
        $panels = $data['panels'];
        $panelPriority = 1000;
        foreach ($panels as $panelProps) {
            if (isset($panelProps['title'])) {
                $panelId = 'panel-' . $panelPriority;
                $wp_customize->add_panel($panelId, array(
                    'priority'    => $panelPriority,
                    'title'       => Strings::translate($panelProps['title']),
                    'description' => Strings::translate($panelProps['description'])
                ));
            } else {
                $panelId = $defaultPanel['id'];
            }

            $sectionPriority = 10;
            foreach ($panelProps['sections'] as $sectionId => $sectionProps) {
                $wp_customize->add_section($sectionId, array(
                    'panel'       => $panelId,
                    'priority'    => $sectionPriority,
                    'title'       => Strings::translate($sectionProps['title']),
                    'description' => Strings::translate($sectionProps['description'])

                ));

                $sectionPriority += 10;
            }

            $panelPriority += 10;
        }

        return $wp_customize;
    }
public function createPanels ( $ wp_customize ) { $ data = $ this -> getData ( ) ; // Move all default sections to the default panel $ defaultPanel = $ data [ 'options' ] [ 'default_panel' ] ; $ wp_customize -> add_panel ( $ defaultPanel [ 'id' ] , array ( 'priority' => 10 , 'title' => Strings :: translate ( $ defaultPanel [ 'title' ] ) , 'description' => '' ) ) ; $ existingSections = $ wp_customize -> sections ( ) ; /** @var \WP_Customize_Section $section */ foreach ( $ existingSections as $ sectionId => $ section ) { if ( empty ( $ section -> panel ) ) { $ section -> panel = $ defaultPanel [ 'id' ] ; } } // Define additional panels and sections $ panels = $ data [ 'panels' ] ; $ panelPriority = 1000 ; foreach ( $ panels as $ panelProps ) { if ( isset ( $ panelProps [ 'title' ] ) ) { $ panelId = 'panel-' . $ panelPriority ; $ wp_customize -> add_panel ( $ panelId , array ( 'priority' => $ panelPriority , 'title' => Strings :: translate ( $ panelProps [ 'title' ] ) , 'description' => Strings :: translate ( $ panelProps [ 'description' ] ) ) ) ; } else { $ panelId = $ defaultPanel [ 'id' ] ; } $ sectionPriority = 10 ; foreach ( $ panelProps [ 'sections' ] as $ sectionId => $ sectionProps ) { $ wp_customize -> add_section ( $ sectionId , array ( 'panel' => $ panelId , 'priority' => $ sectionPriority , 'title' => Strings :: translate ( $ sectionProps [ 'title' ] ) , 'description' => Strings :: translate ( $ sectionProps [ 'description' ] ) ) ) ; $ sectionPriority += 10 ; } $ panelPriority += 10 ; } return $ wp_customize ; }
Create all panels and sections

@param \WP_Customize_Manager $wp_customize the WP customizer
@return \WP_Customize_Manager
Create all panels and sections