1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Show escaping functions |
---|
4 | Description: Adds text each time `esc_html` and `esc_attr` functions are called on the front end. This breaks elements, including some images, so view the HTML source. The admin toolbar is simply removed because these filters break too much of it. |
---|
5 | */ |
---|
6 | |
---|
7 | add_action( 'init', function() { |
---|
8 | if ( ! is_admin() ) { |
---|
9 | // Do not show a broken toolbar. |
---|
10 | add_filter( 'show_admin_bar', '__return_false' ); |
---|
11 | |
---|
12 | add_filter( |
---|
13 | 'esc_html', |
---|
14 | function( $text ) { |
---|
15 | $text .= '|esc_html|'; |
---|
16 | return $text; |
---|
17 | }, |
---|
18 | 11, |
---|
19 | 1 |
---|
20 | ); |
---|
21 | |
---|
22 | add_filter( |
---|
23 | 'attribute_escape', |
---|
24 | function( $text ) { |
---|
25 | $text .= '|esc_attr|'; |
---|
26 | return $text; |
---|
27 | }, |
---|
28 | 11, |
---|
29 | 1 |
---|
30 | ); |
---|
31 | } |
---|
32 | }); |
---|