attribute_escape
Filters a string cleaned and escaped for output in an HTML attribute.
Description
Text passed to esc_attr(…)
is stripped of invalid or special characters before output.
Parameters (2)
- 0. $safe_text (string)
- The text after it has been escaped.
- 1. $text (string)
- The text prior to being escaped.
Usage
- To run the hook, copy the example below.
- $safe_text = apply_filters( 'attribute_escape', $safe_text, $text );
- if ( !empty( $safe_text ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the attribute_escape callback
- function filter_attribute_escape( $safe_text, $text ) {
- // make filter magic happen here...
- return $safe_text;
- };
- // add the filter
- add_filter( 'attribute_escape', 'filter_attribute_escape', 10, 2 );
- To remove a hook callback, use the example below.
- // remove the filter
- remove_filter( 'attribute_escape', 'filter_attribute_escape', 10, 2 );
Defined (1)
The filter is defined in the following location(s).
- /wp-includes/formatting.php
- return apply_filters( 'attribute_escape', $safe_text, $text );