get_section example

/** * Registers customizer options. * * @since Twenty Twenty-One 1.0 * * @param WP_Customize_Manager $wp_customize Theme Customizer object. * @return void */
    public function customizer_controls( $wp_customize ) {

        $colors_section = $wp_customize->get_section( 'colors' );
        if ( is_object( $colors_section ) ) {
            $colors_section->title = __( 'Colors & Dark Mode', 'twentytwentyone' );
        }

        // Custom notice control.         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',
                
final public function check_capabilities() {
        if ( ! empty( $this->capability ) && ! current_user_can( $this->capability ) ) {
            return false;
        }

        foreach ( $this->settings as $setting ) {
            if ( ! $setting || ! $setting->check_capabilities() ) {
                return false;
            }
        }

        $section = $this->manager->get_section( $this->section );
        if ( isset( $section ) && ! $section->check_capabilities() ) {
            return false;
        }

        return true;
    }

    /** * Get the control's content for insertion into the Customizer pane. * * @since 4.1.0 * * @return string Contents of the control. */
Home | Imprint | This part of the site doesn't use cookies.