Not necessarily. They do different things. wp_strip_all_tags()
strips HTML tags from a given string, but that’s not the only reason you escape things. esc_attr()
, for example, ensures that "
characters are escaped so that a value doesn’t break HTML attributes.
For example, if I have a variable whose value is the string my-"class
, and I want to put it into an HTML attribute:
$my_class="my-"class";
echo '<div class="' . $my_class . '"></div>';
The resulting HTML will be:
<div class="my-"class"></div>
Which is invalid HTML, because the "
in my value has closed the HTML attribute. wp_strip_all_tags()
will not help you here.