add_control example

        require_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-notice-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
        $wp_customize->add_setting(
            'respect_user_color_preference_notice',
            array(
                'capability'        => 'edit_theme_options',
                'default'           => '',
                'sanitize_callback' => '__return_empty_string',
            )
        );

        $wp_customize->add_control(
            new Twenty_Twenty_One_Customize_Notice_Control(
                $wp_customize,
                'respect_user_color_preference_notice',
                array(
                    'section'         => 'colors',
                    'priority'        => 100,
                    'active_callback' => static function() {
                        return 127 >= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) );
                    },
                )
            )
        );
'transport'         => 'postMessage',
                        'default'           => 0,
                    )
                );
            }

            // Override the assigned nav menu location if mapped during previewed theme switch.             if ( empty( $changeset[ $setting_id ] ) && isset( $mapped_nav_menu_locations[ $location ] ) ) {
                $this->manager->set_post_value( $setting_id$mapped_nav_menu_locations[ $location ] );
            }

            $this->manager->add_control(
                new WP_Customize_Nav_Menu_Location_Control(
                    $this->manager,
                    $setting_id,
                    array(
                        'label'       => $description,
                        'location_id' => $location,
                        'section'     => 'menu_locations',
                        'choices'     => $choices,
                    )
                )
            );
        }
// Add "display_title_and_tagline" setting for displaying the site-title & tagline.             $wp_customize->add_setting(
                'display_title_and_tagline',
                array(
                    'capability'        => 'edit_theme_options',
                    'default'           => true,
                    'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ),
                )
            );

            // Add control for the "display_title_and_tagline" setting.             $wp_customize->add_control(
                'display_title_and_tagline',
                array(
                    'type'    => 'checkbox',
                    'section' => 'title_tagline',
                    'label'   => esc_html__( 'Display Site Title & Tagline', 'twentytwentyone' ),
                )
            );

            /** * Add excerpt or full text selector to customizer */
            
$control = new WP_Widget_Area_Customize_Control(
                            $this->manager,
                            $setting_id,
                            array(
                                'section'    => $section_id,
                                'sidebar_id' => $sidebar_id,
                                'priority'   => count( $sidebar_widget_ids ), // place 'Add Widget' and 'Reorder' buttons at end.                             )
                        );
                    }

                    $this->manager->add_control( $control );

                    $new_setting_ids[] = $setting_id;
                }
            }

            if ( ! $use_widgets_block_editor ) {
                // Add a control for each active widget (located in a sidebar).                 foreach ( $sidebar_widget_ids as $i => $widget_id ) {

                    // Skip widgets that may have gone away due to a plugin being deactivated.                     if ( ! $is_active_sidebar || ! isset( $wp_registered_widgets[ $widget_id ] ) ) {
                        


        $this->add_setting(
            'blogname',
            array(
                'default'    => get_option( 'blogname' ),
                'type'       => 'option',
                'capability' => 'manage_options',
            )
        );

        $this->add_control(
            'blogname',
            array(
                'label'   => __( 'Site Title' ),
                'section' => 'title_tagline',
            )
        );

        $this->add_setting(
            'blogdescription',
            array(
                'default'    => get_option( 'blogdescription' ),
                
Home | Imprint | This part of the site doesn't use cookies.