Using esc_url, esc_html, esc_attr functions ...

When is it definitely necessary or for good practice to use escaping functions?

For example, using esc_url();with:

get_template_directory_uri();
get_permalink();
get_author_posts_url();
get_edit_post_link();
wp_get_attachment_url();

And esc_html();with:

get_the_title();
get_the_author();
get_the_date();
get_search_query();

I also think that esc_html();they are esc_attr();very similar, aren't they? What are the differences?

+6
source share
1 answer

Part 1

According to the documentation - validation, disinfection and escape from the VIP VIP team.

Guidelines

  1. Never trust user input.
  2. Escape as late as possible.
  3. , (, ), (, Twitter) ..
  4. .
  5. .
  6. , / .
  7. .

" . . , ". -nb

2

- WordPress Front End: CSS-.

: esc_html

: , HTML .

: HTML ( <, >, &) "" (&lt; &gt; &amp;).

: esc_attr

: , HTML (, "title", "data-", "alt").

: , esc_html. , WordPress.

+4

All Articles