Forums

[resolved] clean_url() vs. sanitize_url() vs. esc_url() vs. esc_url_raw().? (2 posts)

  1. Trahald
    Member
    Posted 2 years ago #

    I believe that in 2.8, clean_url() and sanitize_url() were deprecated in favor of esc_url() and esc_url_raw().

    What are the differences between clean_url()/esc_url() and sanitize_url()/esc_url_raw()? When do you use the former functions, as opposed to the latter functions?

  2. Mark Jaquith
    WordPress Lead Dev
    Posted 2 years ago #

    http://markjaquith.wordpress.com/2009/06/12/escaping-api-updates-for-wordpress-2-8/

    esc_url() is for something like <a href="SANITIZE_THIS">text</a>

    If you want compatibility with versions of WP before 2.8, you can still use clean_url()

    esc_url_raw() is for other cases where you want a clean URL, but you don't want HTML entities to be encoded. So any non-HTML usage (DB, redirect) would use this.

    If you want compatibility with versions of WP before 2.8, you can still use sanitize_url()

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.