What is the difference between esc_html and wp_filter_nohtml_kses?

Contrary to what you have been looking at, esc_html does not strip all the HTML, it escapes it, meaning it encodes it into safe HTML entities that do not break HTML tags. wp_filter_nohtml_kses strips all the HTML. When in doubt always consult the source code. It is accessible online. esc_attr is short and sweet, uses … Read more

Settings API – sanitizing urls, email addresses and text

Instead of using add_settings_section() and add_settings_field() every time, create a function that returns an array of options for example: function my_theme_options() { $options = array(); $options[] = array( ‘id’ => ‘ID’, ‘title’ => ‘Title’, ‘type’ => ‘text_field’, // use this value to sanitize/validate input ‘validate’ => ‘url’ // use this value to validate the text … Read more

Which KSES should be used and when?

From the codex: wp_filter_kses should generally be preferred over wp_kses_data because wp_magic_quotes escapes $_GET, $_POST, $_COOKIE, $_SERVER, and $_REQUEST fairly early in the hook system, shortly after ‘plugins_loaded’ but earlier then ‘init’ or ‘wp_loaded’. The first set is then preferred. More of a question of, “is stripping slashes more secure than not?” They both use … Read more