This React higher order component handles authentication and authorization by checking user credentials before rendering the wrapped component. It uti...
Back to Snippets
php
• 25 lines
JavaScript
JavaScript
PHP
WordPress Output Escaping Cheat Sheet
Complete WordPress output escaping reference — esc_html, esc_attr, esc_url, esc_js, wp_kses_post. Use the right function for every context.
Snippet Stats
Lines
25
Characters
690
Read
1 min
// HTML context — use for any text displayed in HTML.
echo esc_html( $user_input );
// Attribute context — use inside HTML attributes.
echo '';
// URL context — use for href, src, action attributes.
echo '';
// JavaScript context — use inside inline JS.
echo '';
// Rich HTML — allows safe tags (p, br, strong, em, a, etc.).
echo wp_kses_post( $editor_content );
// Custom allowed HTML tags.
echo wp_kses( $content, array(
'a' => array( 'href' => true, 'title' => true, 'rel' => true ),
'strong' => array(),
'em' => array(),
) );
// Translation + escape in one call.
esc_html_e( 'Settings saved.', 'theme-domain' );
echo esc_html__( 'Hello, %s', 'theme-domain' );
Found an issue with this snippet? Help us improve by reporting it. Report it →
Related Snippets
View allThis React higher-order component handles authentication and authorization by wrapping the provided component with authentication checks, ensuring onl...
This snippet provides a custom WordPress plugin that utilizes hooks to modify the user registration process, allowing for additional validation and cu...