Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpscholar/4748003ff7224d560277 to your computer and use it in GitHub Desktop.
Save wpscholar/4748003ff7224d560277 to your computer and use it in GitHub Desktop.
Escape JS example
<script>
var name = '<?php echo esc_js( $_POST['name'] ); ?>';
</script>
<a href="<?php echo esc_url( home_url( '/blog/' ) ); ?>"
onclick="<?php echo esc_js( 'alert("Welcome " + name);' ); ?>">
<?php _e( 'Blog', 'textdomain' ) ?>
</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment