select-units.php
49 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Select Units. |
| 4 | * |
| 5 | * @package Hustle |
| 6 | * @since 4.3.0 |
| 7 | */ |
| 8 | |
| 9 | $label = ( isset( $label ) && ! empty( $label ) ) ? $label : __( 'Pick a unit', 'hustle' ); |
| 10 | $units = array( |
| 11 | 'px' => 'px', |
| 12 | '%' => '%', |
| 13 | 'vw' => 'vw', |
| 14 | 'vh' => 'vh', |
| 15 | ); |
| 16 | |
| 17 | if ( ! empty( $exclude_units ) ) { |
| 18 | foreach ( $exclude_units as $unit ) { |
| 19 | unset( $units[ $unit ] ); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | if ( ! empty( $extra_units ) ) { |
| 24 | $units = array_merge( $units, $extra_units ); |
| 25 | } |
| 26 | |
| 27 | echo '<label for="hustle-' . esc_attr( $name ) . '" id="hustle-' . esc_attr( $name ) . '-label" class="sui-label">'; |
| 28 | echo esc_html( $label ); |
| 29 | |
| 30 | Hustle_Layout_Helper::get_html_for_options( |
| 31 | array( |
| 32 | array( |
| 33 | 'type' => 'select', |
| 34 | 'name' => $name, |
| 35 | 'options' => $units, |
| 36 | 'id' => 'hustle-' . $name, |
| 37 | 'selected' => $selected, |
| 38 | 'class' => 'sui-select sui-select-sm sui-select-inline sui-inlabel', |
| 39 | 'attributes' => array( |
| 40 | 'data-width' => '50', |
| 41 | 'data-attribute' => $name, |
| 42 | 'aria-labelledby' => 'hustle-' . $name . '-label', |
| 43 | ), |
| 44 | ), |
| 45 | ) |
| 46 | ); |
| 47 | |
| 48 | echo '</label>'; |
| 49 |