Skip to content

Instantly share code, notes, and snippets.

@junaidtk
Created January 29, 2019 03:50
Show Gist options
  • Save junaidtk/3ab5f5b25fb8857868aa41e0e921f9d7 to your computer and use it in GitHub Desktop.
Save junaidtk/3ab5f5b25fb8857868aa41e0e921f9d7 to your computer and use it in GitHub Desktop.
wordpresss esc_html and its reverse opperation.
esc_html():
It is wordpress function used to convert the html element to html entity.
Refer the below eg:
$html = esc_html( '<a href="http://www.example.com/">A link</a>' );
so $html contain
&lt;a href=&quot;http://www.example.com/&quot;&gt;A link&lt;/a&gt;
The output will display like below.
<a href="http://www.example.com/">A link</a>
In-order to decode the text from esc_html(), we can use below wp function
wp_specialchars_decode();
In order to remove the html tags from a string we can use below php function.
strip_tags($text);
In order to remove the esc_html functionality we can use the below filter.
apply_filters( 'esc_html', $safe_text, $text );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment