Skip to content

Commit

Permalink
Improve <select> element escaping.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Oct 30, 2023
1 parent 6a01e75 commit 1c1adab
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions views/meta-box-gateway-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,21 @@ function ( $section ) {

break;
case 'select':
printf(
'<select %s>%s</select>',
Util::array_to_html_attributes( $attributes ),
Util::select_options_grouped( $field['options'], $value )
);
$element = new Element( 'select', $attributes );

foreach ( $field['options'] as $key => $label ) {
$option = new Element( 'option', [ 'value' => $key ] );

$option->children[] = $label;

if ( $value === $key ) {
$option->attributes['selected'] = 'selected';
}

$element->children[] = $option;
}

$element->output();

break;
case 'optgroup':
Expand Down

0 comments on commit 1c1adab

Please sign in to comment.