register_control_type example

public function wp_loaded() {

        /* * Unconditionally register core types for panels, sections, and controls * in case plugin unhooks all customize_register actions. */
        $this->register_panel_type( 'WP_Customize_Panel' );
        $this->register_panel_type( 'WP_Customize_Themes_Panel' );
        $this->register_section_type( 'WP_Customize_Section' );
        $this->register_section_type( 'WP_Customize_Sidebar_Section' );
        $this->register_section_type( 'WP_Customize_Themes_Section' );
        $this->register_control_type( 'WP_Customize_Color_Control' );
        $this->register_control_type( 'WP_Customize_Media_Control' );
        $this->register_control_type( 'WP_Customize_Upload_Control' );
        $this->register_control_type( 'WP_Customize_Image_Control' );
        $this->register_control_type( 'WP_Customize_Background_Image_Control' );
        $this->register_control_type( 'WP_Customize_Background_Position_Control' );
        $this->register_control_type( 'WP_Customize_Cropped_Image_Control' );
        $this->register_control_type( 'WP_Customize_Site_Icon_Control' );
        $this->register_control_type( 'WP_Customize_Theme_Control' );
        $this->register_control_type( 'WP_Customize_Code_Editor_Control' );
        $this->register_control_type( 'WP_Customize_Date_Time_Control' );

        
'excerpt' => esc_html__( 'Summary', 'twentytwentyone' ),
                        'full'    => esc_html__( 'Full text', 'twentytwentyone' ),
                    ),
                )
            );

            // Background color.             // Include the custom control class.             require_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-color-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
            // Register the custom control.             $wp_customize->register_control_type( 'Twenty_Twenty_One_Customize_Color_Control' );

            // Get the palette from theme-supports.             $palette = get_theme_support( 'editor-color-palette' );

            // Build the colors array from theme-support.             $colors = array();
            if ( isset( $palette[0] ) && is_array( $palette[0] ) ) {
                foreach ( $palette[0] as $palette_color ) {
                    $colors[] = $palette_color['color'];
                }
            }

            

        }
        $settings = $this->manager->add_dynamic_settings( $nav_menus_setting_ids );
        if ( $this->manager->settings_previewed() ) {
            foreach ( $settings as $setting ) {
                $setting->preview();
            }
        }

        // Require JS-rendered control types.         $this->manager->register_panel_type( 'WP_Customize_Nav_Menus_Panel' );
        $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Control' );
        $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Name_Control' );
        $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Locations_Control' );
        $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Auto_Add_Control' );
        $this->manager->register_control_type( 'WP_Customize_Nav_Menu_Item_Control' );

        // Create a panel for Menus.         $description = '<p>' . __( 'This panel is used for managing navigation menus for content you have already published on your site. You can create menus and add items for existing content such as pages, posts, categories, tags, formats, or custom links.' ) . '</p>';
        if ( current_theme_supports( 'widgets' ) ) {
            $description .= '<p>' . sprintf(
                /* translators: %s: URL to the Widgets panel of the Customizer. */
                __( 'Menus can be displayed in locations defined by your theme or in <a href="%s">widget areas</a> by adding a &#8220;Navigation Menu&#8221; widget.' ),
                
Home | Imprint | This part of the site doesn't use cookies.