Make WordPress Core

Ticket #58127: show-escaping-functions.php

File show-escaping-functions.php, 698 bytes (added by sabernhardt, 8 months ago)

plugin to identify where esc_html and esc_attr functions are called on the front end (view HTML source, not the broken page)

Line 
1<?php
2/*
3Plugin Name: Show escaping functions
4Description: 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
7add_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});