Escaping built-in WP function return strings

Escaping is used to produce valid HTML or other formats, and it depends on context.

Escaping a url in something like <a href="https://wordpress.stackexchange.com/questions/215822/<?php echo $url?>".... is needed in order to replace any “&” characters with & (although browsers will most likely fix it for you if you don’t do it).

Escaping a url in an input element like <input value="https://wordpress.stackexchange.com/questions/215822/<?php echo $url?>"...do not require replacement of “&” but do require replacement of any quote character.

So in general, since escaping is context sensitive you can assume that wordpress API will not escape it for you. What plugins do, is up to the plugin itself.

Leave a Comment