I am sanitizing a text field input via a custom WordPress Setting API page like this...
public function current_issue_sanitize($input) {
$sanitary_values = array();
if ( isset( $input['episode'] ) ) {
$sanitary_values['episode'] = sanitize_text_field( $input['episode'] );
}
return $sanitary_values;
}
This is working well but I am now trying to sanitize and integer, is there a sanitize_text_field equivalent for numbers?
sanitize_text_field()
on integers? If you want to return the int part of the value, you can use$sanitary_values['episode'] = ( int ) sanitize_text_field( $input['episode'] );