woocommerce_wp_select()
Output a select input box.
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
woocommerce_wp_select( $field, ?WC_Data $data );
- $field(массив) (обязательный)
- Field data.
- ?WC_Data $data **
- -
По умолчанию: null
Код woocommerce_wp_select() woocommerce wp select WC 9.5.1
<?php function woocommerce_wp_select( $field, ?WC_Data $data = null ) { global $post; $field = wp_parse_args( $field, array( 'class' => 'select short', 'style' => '', 'wrapper_class' => '', 'value' => OrderUtil::get_post_or_object_meta( $post, $data, $field['id'], true ), 'name' => $field['id'], 'desc_tip' => false, 'custom_attributes' => array(), ) ); $wrapper_attributes = array( 'class' => $field['wrapper_class'] . " form-field {$field['id']}_field", ); $label_attributes = array( 'for' => $field['id'], ); $field_attributes = (array) $field['custom_attributes']; $field_attributes['style'] = $field['style']; $field_attributes['id'] = $field['id']; $field_attributes['name'] = $field['name']; $field_attributes['class'] = $field['class']; $tooltip = ! empty( $field['description'] ) && false !== $field['desc_tip'] ? $field['description'] : ''; $description = ! empty( $field['description'] ) && false === $field['desc_tip'] ? $field['description'] : ''; ?> <p <?php echo wc_implode_html_attributes( $wrapper_attributes ); // WPCS: XSS ok. ?>> <label <?php echo wc_implode_html_attributes( $label_attributes ); // WPCS: XSS ok. ?>><?php echo wp_kses_post( $field['label'] ); ?></label> <?php if ( $tooltip ) : ?> <?php echo wc_help_tip( $tooltip ); // WPCS: XSS ok. ?> <?php endif; ?> <select <?php echo wc_implode_html_attributes( $field_attributes ); // WPCS: XSS ok. ?>> <?php foreach ( $field['options'] as $key => $value ) { echo '<option value="' . esc_attr( $key ) . '"' . wc_selected( $key, $field['value'] ) . '>' . esc_html( $value ) . '</option>'; } ?> </select> <?php if ( $description ) : ?> <span class="description"><?php echo wp_kses_post( $description ); ?></span> <?php endif; ?> </p> <?php }