Created
June 23, 2016 00:07
-
-
Save felipelavinz/6ea32b71053997f99f478741ff0e0e26 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Esto puede ser parte del archivo functions.php de tu tema | |
*/ | |
add_action('wp_enqueue_scripts', 'custom_enqueue_scripts'); | |
function custom_enqueue_scripts(){ | |
// encolar el script | |
wp_enqueue_script('mycustomscript', get_stylesheet_directory_uri() .'/js/myscript.js', array('jquery'), '1.0', true); | |
/** | |
* Definir variables de localización | |
* Luego, dentro de tu js puedes llamar a Foo.ajaxurl y tendrá la URL de admin-ajax.php | |
*/ | |
wp_localize_script('mycustomscript', 'Foo', array( | |
'ajaxurl' => admin_url('admin-ajax.php') | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment