MortgageRates_Settings::select( array $args )
Callback select function.
Contents
Parameters Parameters
- $args
-
(array) (Required) array of arguments
Source Source
File: mortgage-rates-widget/inc/MortgageRates_Settings.php
public function select( $args ) {
$name = $args['label_for'];
$option_name = $args['option_name'];
$input = get_option( $option_name );
$default = $args['default'];
$value = isset( $input[ $name ] ) ? $input[ $name ] : $default;
$description = $args['description'];
echo '<select style="width: 50%;" name="' . esc_attr( $option_name ) . '[' . esc_attr( $name ) . ']" id="' . esc_attr( $name ) . '">';
foreach ( $args['options'] as $key => $option ) {
$selected = '';
if ( '' !== $value ) {
if ( $value === $key ) {
$selected = ' selected="selected"';
}
}
echo '<option' . esc_attr( $selected ) . ' value="' . esc_attr( $key ) . '">' . esc_attr( $option ) . '</option>';
}
echo '</select>';
echo '<p>' . esc_html( $description ) . '</p>';
}
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |