Last active
December 5, 2016 14:41
-
-
Save rajuahmmed/4a427d8b51165909cc68158e09347f1e to your computer and use it in GitHub Desktop.
Escaping wordpress translated strings by https://www.cantothemes.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Example of escaping __() function | |
*/ | |
// Unescaped | |
echo __("Example String", "textdomain"); | |
// Escaped from HTML : XSS safe | |
echo esc_html__("Example String", "textdomain"); | |
// Escaped for Attribute : XSS safe | |
echo '<a href="#" title="'.esc_attr__("Example String", "textdomain").'">'.esc_html__("Example String", "textdomain").'</a>'; | |
// Escaped from HTML with specified HTML Tag : XSS safe | |
$tags = array( | |
'h1' => array( | |
'class' => array(); | |
) | |
); | |
echo wp_kses(__("Example String", "textdomain"), $tags); | |
/** | |
* Example of escaping _e() function | |
*/ | |
// Unescaped | |
_e("Example String", "textdomain"); | |
// Escaped from HTML : XSS safe | |
esc_html_e("Example String", "textdomain"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment