Created
January 27, 2015 20:16
-
-
Save jester1979/fd19fdd9d56f0c19d4dd to your computer and use it in GitHub Desktop.
Javascript vars
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
add_action( 'wp_head', 'append_header_js_vars' ); | |
/** | |
* Append some handy dandy JS vars to the head | |
* | |
* Adds necessary code to start the PE-application (on document ready), | |
* with the WP_DEBUG boolean as a parameter. | |
* | |
* @since 1.0.0 | |
*/ | |
function append_header_js_vars() { | |
$params = array( | |
'stylesheet_uri' => get_stylesheet_directory_uri(), | |
'template_uri' => get_template_directory_uri(), | |
'ajax_uri' => admin_url( 'admin-ajax.php' ), | |
); | |
?> | |
<script> | |
var site_params = <?php json_encode( $params ); ?>; | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment