['0', '1', '2']]),
Setting::text('text_right', __('Text after input field', 'admin-options-pages')),
Setting::classAttribute(),
Setting::description(),
];
}
public function sanitizeValue($value, array $field)
{
return $this->sanitizeNumberValue($value, $field);
}
/**
* The number in the format of the site language, with the decimals of the field.
*/
public function displayValue($value, array $field, array $args): string
{
if (!is_numeric($value)) {
return is_scalar($value) ? esc_html((string) $value) : '';
}
return esc_html(number_format_i18n((float) $value, (int) ($field['decimals'] ?? 0)));
}
public function render(array $field, $value): void
{
$min = $field['min_value'] ?? '';
$max = $field['max_value'] ?? '';
if ($value === false) {
$value = $field['default_value'] ?? '';
}
// The live value next to the slider: a plain oninput attribute, not a separate script, updates it as the
// handle moves (the same "no new asset" approach as the number field's step attribute).
printf(
' %s%s',
esc_attr($field['field_name']),
esc_attr($field['field_name']),
esc_attr($value),
esc_attr($min) ? 'min="' . esc_attr($min) . '"' : 'min="0"',
esc_attr($max) ? 'max="' . esc_attr($max) . '"' : '',
esc_attr($this->numberStep($field['decimals'] ?? '')),
esc_html($value),
esc_html($this->text($field, 'text_right')),
wp_kses_post($this->descriptionHtml($field['description'] ?? ''))
);
}
}