For general sanitization of text input fields and text areas for plugin options and such, use:
sanitize_text_field( string $string )
For escaping in general for text input fields, use:
esc_attr( string $string )
@refer https://wordpress.stackexchange.com/a/66323/90061
I stumbled upon your website and just wanted to let you know that esc_attr_e( string $string ) is incorrect. It should be:
esc_attr( string $text )
esc_attr_e( $text, $domain ) is used for escaping translatable strings inside html attributes only.
Thank you kind sir for pointing this out. You are right and I have corrected my code snippet to reflect this 🙂