Skip to content

Instantly share code, notes, and snippets.

@everdaniel
Created February 6, 2013 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save everdaniel/4725845 to your computer and use it in GitHub Desktop.
Save everdaniel/4725845 to your computer and use it in GitHub Desktop.
JS Namespace en WordPress
// Define Esencia JS Namespace
function esencia_js_namespace() {
?><script type="text/javascript">
/* <![CDATA[ */
// Global Esencia Namespace
window.esencia = window.esencia || {};
// Theme Namespace
esencia.theme = esencia.theme || {};
// Theme Paths
esencia.theme.paths = {
admin_url: '<?php echo admin_url() ?>',
admin_ajax_url: '<?php echo admin_url( 'admin-ajax.php?nonce=' . wp_create_nonce('lele-lelo') ) ?>',
root: '<?php echo get_template_directory_uri(); ?>/',
js: '<?php echo get_template_directory_uri(); ?>/js',
images: '<?php echo get_template_directory_uri(); ?>/images',
css: '<?php echo get_template_directory_uri(); ?>/css',
swf: '<?php echo get_template_directory_uri(); ?>/swf'
}
esencia.theme.nonces = {
weather: '<?php echo wp_create_nonce('lele-lelo-weather'); ?>',
rate: '<?php echo wp_create_nonce('lele-lelo-rate'); ?>'
}
/* ]]> */
</script><?php
}
add_action( 'wp_head', 'esencia_js_namespace' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment