why do developers use
<?php esc_html_e() >?
in 404 pages, what does it mean, how does it works?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
You would use it to prevent HTML being smuggled into a translation and breaking your markup or causing security issues.
For example, if your theme had:
_e( 'My translatable string', 'my-text-domain' );
Then it's possible for a translation for
'My translatable string' to be something like
'<script>alert('Bad!');</script>'. If you don't use
esc_html_e() then that script will be executed. If you use
esc_html_e() then it won't be, because the
> characters will be escaped as
>, which out output as < and > and not interpreted as HTML tags.