Skip to content

Commit

Permalink
select field updated
Browse files Browse the repository at this point in the history
  • Loading branch information
rafasashi committed Mar 21, 2024
1 parent ca760cc commit 0446222
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion includes/lib/class-wordpress-plugin-template-admin-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,27 @@ public function display_field( $data = array(), $post = null, $echo = true ) {
break;

case 'select':

$html .= '<select name="' . esc_attr( $option_name ) . '" id="' . esc_attr( $field['id'] ) . '">';

foreach ( $field['options'] as $k => $v ) {

$selected = false;
if ( $k === $data ) {

if( is_numeric($data) && floatval($k) === floatval($data) ) {

$selected = true;
}
elseif( $k === $data ){

$selected = true;
}

$html .= '<option ' . selected( $selected, true, false ) . ' value="' . esc_attr( $k ) . '">' . $v . '</option>';
}

$html .= '</select> ';

break;

case 'select_multi':
Expand Down

0 comments on commit 0446222

Please sign in to comment.