';
FrmAppHelper::icon_by_class( 'frmfont frm_checkmark_icon', array( 'aria-hidden' => 'true' ) );
echo '';
return;
}
echo '';
FrmAppHelper::icon_by_class( 'frmfont frm_x_icon', array( 'aria-hidden' => 'true' ) );
echo '';
}
/**
* Echo a dropdown option.
* This is useful to avoid closing and opening PHP to echo ';
}
/**
* Renders a number input with unit selector.
*
* @since 6.24
*
* @param array $args {
* Optional. Arguments to customize the unit input.
*
* @type array $field_attrs Attributes for the hidden input storing the field value.
* @type array $input_number_attrs Attributes for the visible number input.
* @type array $units Available units for selection. Default is ['px', '%', 'em'].
* @type string $value Initial value with optional unit (e.g. '10px', '50%').
* }
*
* @return void
*/
public static function echo_unit_input( $args = array() ) {
$args = wp_parse_args(
$args,
array(
'field_attrs' => array(),
'input_number_attrs' => array(),
'units' => array( '', 'px', '%', 'em' ),
'default_unit' => 'px',
'value' => '',
)
);
$units = $args['units'];
$value = $args['value'];
// Extract unit and number value if value is a string
if ( '' !== $value && ! is_numeric( $value ) ) {
$pattern = '/^([0-9.]*)(' . implode( '|', array_map( 'preg_quote', $units ) ) . ')?$/';
preg_match( $pattern, $value, $matches );
$selected_unit = $matches[2] ?? '';
if ( ! empty( $matches[1] ) ) {
$value = $matches[1];
}
}
$input_number_attrs = array_merge(
$args['input_number_attrs'],
array(
'type' => ! empty( $selected_unit ) ? 'number' : 'text',
'value' => $value,
'class' => trim( 'frm-unit-input-control ' . ( $args['input_number_attrs']['class'] ?? '' ) ),
)
);
$hidden_value = $args['value'];
if ( is_numeric( $hidden_value ) ) {
$hidden_value .= $args['default_unit'];
}
// phpcs:disable Generic.WhiteSpace.ScopeIndent
?>
/>
/>