Add a setting, specifying the sanitize_callback
:
$wp_customize->add_setting(
'my_input',
array(
'default' => '100.00',
'sanitize_callback' => 'sanitize_float',
)
);
Add the control:
$wp_customize->add_control(
'my_input',
array(
'label' => 'Please enter a number:',
'section' => 'my_section',
'type' => 'number',
'input_attrs' => array(
'min' => '0.01', 'step' => '0.01', 'max' => '10000',
),
)
);
Create a function to perform the sanitisation – filter_var
should return the sanitised float or false
:
function sanitize_float( $input ) {
return filter_var($input, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
}
This is untested, but should get you started – it could, of course, be adapted to sanitize an integer.
[Adapted from http://themefoundation.com/wordpress-theme-customizer/]