Make WordPress Core

Ticket #47692: 47692-updated.patch

File 47692-updated.patch, 1.2 KB (added by chintan1896, 5 years ago)

Changes for some choices in an optgroup and some at the top level of the select

  • wp-includes/class-wp-customize-control.php

    diff --git a/wp-includes/class-wp-customize-control.php b/wp-includes/class-wp-customize-control.php
    index 994ff90..acbd298 100644
    a b class WP_Customize_Control { 
    546546
    547547                                <select id="<?php echo esc_attr( $input_id ); ?>" <?php echo $describedby_attr; ?> <?php $this->link(); ?>>
    548548                                        <?php
    549                                         foreach ( $this->choices as $value => $label ) {
    550                                                 echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>';
    551                                         }
     549                                                foreach ( $this->choices as $value => $data ) {
     550                                                        if ( is_array( $data ) && ! empty( $data ) ) {
     551                                                                echo '<optgroup label="' . esc_attr( $value ) . '">';
     552                                                                        foreach ( $data as $optgroup_val => $optgroup_data ) {
     553
     554                                                                                echo '<option value="' . esc_attr( $optgroup_val ) . '"' . selected( $this->value(), $value, false ) . '>' . $optgroup_data . '</option>';
     555                                                                        }
     556                                                                echo '</optgroup>';
     557                                                        } else {
     558                                                                echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $data . '</option>';
     559                                                        }
     560                                                }
    552561                                        ?>
    553562                                </select>
    554563                                <?php