Last active
April 2, 2017 11:26
-
-
Save imvarunkmr/5b2908544460a867a09e215157247dbe 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 | |
add_action( 'wp_enqueue_scripts', 'slug_add_scripts' ); | |
/** | |
* Register and enqueue scripts and styles. | |
*/ | |
function slug_add_scripts() { | |
// enqueuing a stylesheet | |
// params - $handle, $src, $deps, $version, $media | |
wp_enqueue_style('slug-handle', get_template_directory_uri() . '/path/to/file', array(), false, 'all'); | |
// enqueuing a script | |
// params - $handle, $src, $deps, $version, $in_footer | |
wp_enqueue_script( 'slug-handle', get_template_directory_uri() . 'path/to/file', array('jquery'), 'false', true ); | |
// localize a script | |
// params - $handle, $name, $data | |
wp_localize_script('slug-handle', 'localData', array( | |
'ajax_url' => admin_url('admin-ajax.php'), | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment