Created
February 6, 2013 21:05
-
-
Save everdaniel/4725845 to your computer and use it in GitHub Desktop.
JS Namespace en WordPress
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
// 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