Filter hook 'attribute_escape'

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

View Source

attribute_escape

Filter Hook
Description
Filters a string cleaned and escaped for output in an HTML attribute. Text passed to esc_attr() 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 4712

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 attribute_escape
add_filter('attribute_escape', '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:4712 - How this hook is used in WordPress core
<?php
4707  	 * @since 2.0.6
4708  	 *
4709  	 * @param string $safe_text The text after it has been escaped.
4710  	 * @param string $text      The text prior to being escaped.
4711  	 */
4712  	return apply_filters( 'attribute_escape', $safe_text, $text );
4713  }
4714  
4715  /**
4716   * Escaping for textarea values.
4717   *

PHP Documentation

<?php
/**
	 * Filters a string cleaned and escaped for output in an HTML attribute.
	 *
	 * Text passed to esc_attr() is stripped of invalid or special characters
	 * before output.
	 *
	 * @since 2.0.6
	 *
	 * @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.