Working on my first theme and thinking about adding some options that are specifically numbers like number of menu levels or number of posts to display on the homepage. Is it possible to check that the input in the customizer is just a number? And perhaps a certain limit like 5 for menu levels and 20 or something for posts on the homepage? Here is the code I'm working on with the customizer api as an example:
$wp_customize->add_setting( 'posts_number_home' , array(
'default' => '10',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_text_field',
) );
$wp_customize->add_control( new WP_Customize_Control(
$wp_customize,
'posts_number_home',
array(
'section' => 'mytheme_options',
'settings' => 'posts_number_home',
'type' => 'text',
'priority' => 10,
)
));