Filter hook 'esc_html'

in WP Core File wp-includes/formatting.php at line 4687

View Source

esc_html

Filter Hook
Description
Filters a string cleaned and escaped for output in HTML. Text passed to esc_html() is stripped of invalid or special characters before output.

Hook Information

File Location wp-includes/formatting.php View on GitHub
Hook Type Filter
Line Number 4687

Hook Parameters

Type Name Description
string $safe_text The text after it has been escaped.
string $text The text prior to being escaped.

Usage Examples

Basic Usage
<?php
// Hook into esc_html
add_filter('esc_html', 'my_custom_filter', 10, 2);

function my_custom_filter($safe_text, $text) {
    // Your custom filtering logic here
    return $safe_text;
}

Source Code Context

wp-includes/formatting.php:4687 - How this hook is used in WordPress core
<?php
4682  	 * @since 2.8.0
4683  	 *
4684  	 * @param string $safe_text The text after it has been escaped.
4685  	 * @param string $text      The text prior to being escaped.
4686  	 */
4687  	return apply_filters( 'esc_html', $safe_text, $text );
4688  }
4689  
4690  /**
4691   * Escaping for HTML attributes.
4692   *

PHP Documentation

<?php
/**
	 * Filters a string cleaned and escaped for output in HTML.
	 *
	 * Text passed to esc_html() is stripped of invalid or special characters
	 * before output.
	 *
	 * @since 2.8.0
	 *
	 * @param string $safe_text The text after it has been escaped.
	 * @param string $text      The text prior to being escaped.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/formatting.php
Related Hooks

Related hooks will be displayed here in future updates.