The following little snippet solves what you mean:
function custom_esc_html( $safe_text, $text ) {
if( is_admin() ) {
return $text;
}
return $safe_text;
}
add_filter( 'esc_html', 'custom_esc_html', 10, 2);However, this should be used with caution. The background: this hook uses the filter of esc_html(). esc_html() is used to secure texts before outputting them to the browser. This converts e.g. < to %lt; so the browser doesn’t interpret them as HTML code anymore but e.g. outputs
<em>italic</em>instead of italic. By leveraging this (even if it’s only in the admin area), a potential attacker can influence your browser.
Example:
If after inserting the above code into a page title in your project, you put
<script>alert("aaaa");</script>then you will always see an alert window when calling pages in the backend where this is output.
For this reason I would advise you not to do this, even if it is theoretically possible as you can see. I therefore do not describe here how to insert the code.
Ok thanks for that, especially with the warning and background. I figured it would involve something like this. I’m going to leave things alone regarding this. ; )
