Enqueue js conditional

<?php

define('WCO_MOO_ARRAY','/,/my-page/');

//Register Moo
function wco_register_moo(){ wp_register_script('wco_moo','mootools-core-1.3.2-full-compat-yc.js'); }

//Enqueue Moo
function wco_enqueue_moo(){
$moo_array = explode(',',WCO_MOO_ARRAY);
if(in_array($_SERVER['REQUEST_URI'],$moo_array)) wp_enqueue_script('wco_moo');
}

add_action('init','wco_register_moo');
add_action('wp_print_scripts','wco_enqueue_moo');

?>

0 Comments

You must be logged in to post a comment.