Skip to content

Instantly share code, notes, and snippets.

@carasmo
Created March 6, 2016 17:34
Show Gist options
  • Save carasmo/61e35e9bc8791246a88f to your computer and use it in GitHub Desktop.
Save carasmo/61e35e9bc8791246a88f to your computer and use it in GitHub Desktop.
example wp_register_enqueue
<?php
//don't use
// this goes in the child theme functions.php file
// See: https://codex.wordpress.org/Function_Reference/wp_register_script
// https://developer.wordpress.org/reference/functions/wp_enqueue_script/
function christina_register_enqueue_scripts() {
//* register the plugin for X
wp_register_script(
'your-id-goes-here', //handle
CHILD_URL . '/js/plugin-for-your-script.js', //path
array('jquery'), //dependancy
null, //version
true
); //in the footer
//wp_enqueue_script (the one we registered)
wp_enqueue_script('your-id-goes-here'); //call the handle
//* dependancy for script - such as the arguments
wp_register_script('plugin-arguments', CHILD_URL . '/js/arguments-for-your-script.js', array('your-id-goes-here'), null, true);
wp_enqueue_script('plugin-arguments');
}
add_action( 'wp_enqueue_scripts', 'christina_register_enqueue_scripts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment