carasmo
3/6/2016 - 5:34 PM

example wp_register_enqueue

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' );