Can someone explain when to use the escaping functions?
My goal is to protect my Wordpress theme. I used the clean Chris Coyer theme and added the code to make the site I wanted. I noticed that other themes used screening functions, but not an empty Coyier theme, so I want to understand where to insert them.
After reading the results of Codex and google and studying the code of several topics, I still do not understand when to use
esc_url()
esc_attr()
esc_html()
I do not see a usage pattern. For example, in one topic for home_url ('/') - note that esc_url is used in header.php, but not in searchform.php - Why?
header.php
<a href=
"<?php echo esc_url( home_url( '/' ) ); ?>"
title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
searchform.php
<form role="search" method="get" id="searchform" action=
"<?php echo home_url( '/' ); ?>"
>
source
share