Yep, you can escape it as normal HTML, like so:
<?php echo esc_html( $email ); ?>
For the mailto link, you can use esc_url. Just make sure you include mailto: into the URL, e.g.:
<a href="<?php echo esc_url( 'mailto:' . $email ); ?>">
So a fully escaped mail link would look like this:
<a href="<?php echo esc_url( 'mailto:' . $email ); ?>"><?php echo esc_html( $email ); ?></a>
Related Posts:
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- Escaping and sanitization
- How to safely sanitize a textarea which takes full HTML input
- How to allow HTML tags into WP Bakery (formerly Visual Composer) `textfield` parameter
- Should messages in WP_Error already be html escaped?
- When do I need to use esc_attr when using WordPress internal functions
- How do I sanitize a javascript text?
- wp_specialchars and wp_specialchars_decode in a shortcode plugin
- Escape when echoed
- Should you escape hardcoded URLs?
- Do We Need to Validate, Sanitize, or Filter Simple Numerical Superglobals (Cookies and Post)?
- MITM risk of not sanitizing?
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- CSS from textarea in options page to frontend what to do
- How to sanitize uploaded file filename from a plugin?
- WordPress stripping away backslashes from HTML
- How to be escape Variables and options when echo?
- Sanitize $_GET variable when comparing
- Can we validate data from jquery
- Save selectlist value (taxonomy) in wp:wp_set_object_terms
- Auto post with filling templates from external data and update periodical
- How can I properly sanitize the update_option in WordPress?
- Get a list of all registered actions
- Enabling free shipping on Woo Commerce by specific items [closed]
- WordPress apply_filters() Arguments Missing
- How to hide /wp-content/uploads/ from URL?
- Add image to post from external URL
- User profiles and object associations
- WordPress plugin search does not work and updates are not shown, VPS install
- Gutenberg: Difference between “import” and “const” for dependencies
- Custom data-id wp_enqueue_script
- Should I host support forum on wordpress.org or my own website?
- How to setup a Network Plugin across the network with only my settings?
- Is it possible to insert images directly from the server?
- “Members only” section of a WordPress site – self signup and no backend access
- I wrote my plugin. How to display the result of the plugin’s function to sidebar (widget?)?
- I have functions in my wordpress plugin. How do I get them to work for me?
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- mysqli_error() expects parameter 1 to be mysqli, null given in own db class
- How to embed HTML code from WP Coder plugin (or other) into Main Index Template of the theme
- Can I use custom CSS and js plugin to put JavaScript in to validate my forms
- Redirection of users away from wp-admin (but not administrators)
- WordPress Plugin [closed]
- Unable to get WP_DEBUG, WP_DEBUG_DISPLAY, WP_DEBUG_LOG to work
- Cannot update user display_name field
- How to install plugin only from PHP file?
- Add sub menu page in your plugin
- Certain functions are undefined when called form mu-plugins
- Custom Post Type Fields
- wp_head is too slow
- Why does my file_exist check fail?
- How do I get the user ID of the user that was updated in WordPress?
- How to handle WordPress Plugin Front-end AJAX Call [duplicate]
- Migrating Asp.Net site to WordPress site
- Plugin to email a post or page to someone
- Get Every Key & Value from Array then Display All in New Line
- What are admin hooks
- Fatal error on some pages after cancelling WPSTAGING cloning process
- Programatically upload a file to be stored inside blob field in database, NOT on filesystem
- Updating WordPress plugin admin panel footer text
- Make plugin php file called directly aware of WordPress?
- Custom Login page with custom redirects for each user?
- Gravity Forms returns to odd position
- Custom Template for wordpress cpt plugin
- Give access of horizontal scroling plugin to user role editor
- Storing Form data in a different database
- Recent Posts+, how to solve multiwidget?
- How to reduce Apache connections caused by plugins?
- What option do I check to enable a user role to be able to see all plugins?
- How to remove automatic generated tag in Home page
- Having a widget only show up in print
- After enable multisite enviroment in wordpress site creation wizard not working
- More than one WordPress site using the same database – how to disable plugin for one site?
- WordPress plugin isn’t loading completely
- How to display category list with category featured image
- WPML – Stop language redirection in initial load
- How to get a post views count using ‘WordPress popular posts’ plugin
- Page not found after creating the add new post slider using custom post type
- Allow a page to be edited by a specific custom role
- How do you remove question mark in URL in get method?
- Get all user meta_keys and then group users by matching values
- How to add site logo to wordpress displayed on the top left of the site name on the chrome tab or any other web browser? [closed]
- Any method to make specific widget for every post and page?
- AddThis Plugin adding html comments in P tags
- Embed Javascript code to registered users only
- get_option returning old value for non-admin users
- Related posts popup
- Get page type to display content
- Insert data in custom table during new post creation
- Woocommerce quick checkout form [closed]
- Notification When Post Approved
- Meta Box plugin image_advanced not showing up on frontend
- I am using multi image metabox plugin but I did get how to display the images in templete?
- How to open author url linked to a new tab in settings page in the WordPress plugin list
- Change page content based on dropdown selection
- Option value not getting updated until page refresh in WordPress
- How to create an Info Box on WordPress [closed]
- Fatal error: Uncaught Error: Call to a member function fetch_array() on bool
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class