WC_Settings_API::generate_select_html( string $key, array $data )
Generate Select HTML.
Description Description
Parameters Parameters
- $key
-
(Required) Field key.
- $data
-
(Required) Field data.
Return Return
(string)
Source Source
File: includes/abstracts/abstract-wc-settings-api.php
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | public function generate_select_html( $key , $data ) { $field_key = $this ->get_field_key( $key ); $defaults = array ( 'title' => '' , 'disabled' => false, 'class' => '' , 'css' => '' , 'placeholder' => '' , 'type' => 'text' , 'desc_tip' => false, 'description' => '' , 'custom_attributes' => array (), 'options' => array (), ); $data = wp_parse_args( $data , $defaults ); ob_start(); ?> <tr valign= "top" > <th scope= "row" class = "titledesc" > <label for = "<?php echo esc_attr( $field_key ); ?>" ><?php echo wp_kses_post( $data [ 'title' ] ); ?> <?php echo $this ->get_tooltip_html( $data ); // WPCS: XSS ok. ?></label> </th> <td class = "forminp" > <fieldset> <legend class = "screen-reader-text" ><span><?php echo wp_kses_post( $data [ 'title' ] ); ?></span></legend> <select class = "select <?php echo esc_attr( $data['class'] ); ?>" name= "<?php echo esc_attr( $field_key ); ?>" id= "<?php echo esc_attr( $field_key ); ?>" style= "<?php echo esc_attr( $data['css'] ); ?>" <?php disabled( $data [ 'disabled' ], true ); ?> <?php echo $this ->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?>> <?php foreach ( ( array ) $data [ 'options' ] as $option_key => $option_value ) : ?> <option value= "<?php echo esc_attr( $option_key ); ?>" <?php selected( (string) $option_key , esc_attr( $this ->get_option( $key ) ) ); ?>><?php echo esc_html( $option_value ); ?></option> <?php endforeach ; ?> </select> <?php echo $this ->get_description_html( $data ); // WPCS: XSS ok. ?> </fieldset> </td> </tr> <?php return ob_get_clean(); } |
Changelog Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |