First, apologies if this is a newb question.. I'm creating a plugin that adds a jQuery background and I can't seem to get the jQuery plugin files to run. The plugin requires 3 scripts to run as well as a bit of CSS and the controlling script.
Here is what I have in my wp plugin:
add_action('wp_enqueue_scripts', 'scripts_method');
add_action('wp_print_styles', 'add_stylesheet');
function add_stylesheet() {
$style_url = plugins_url('style/jquery.background-0.0.1.css', __FILE__);
$style_file = WP_PLUGIN_DIR . '/twenty-first-backgrounds/style/jquery.background-0.0.1.css';
if ( file_exists($style_file) ) {
wp_register_style('jquery.background-0.0.1', $style_url);
wp_enqueue_style( 'jquery.background-0.0.1');
}
}
function scripts_method(){
wp_register_script('jquery.custom.min',
plugins_url('/js/jquery.custom.min.js', __FILE__),
array('jquery'),'1.8.16' );
wp_enqueue_script('jquery.custom.min');
wp_register_script('jquery.parallax.unmin',
plugins_url('/js/jquery.parallax.unmin.js', __FILE__),
array('jquery'),'1.0' );
wp_enqueue_script('jquery.parallax.unmin');
wp_register_script('jquery.okshadow',
plugins_url('/js/jquery.okshadow.js', __FILE__),
array('jquery'),'1.0' );
wp_enqueue_script('jquery.okshadow');
wp_register_script('jquery.lines',
plugins_url('/js/jquery.lines.js', __FILE__),
array('jquery','jquery.custom.min','jquery.parallax.unmin','jquery.okshadow'),
'1.0' );
wp_enqueue_script('jquery.lines');
}
The last script, 'jquery.lines' contains the script which displays the background, the other 3 are dependencies. They seem to load as they are visible within the pages source code. I can get it to work if I echo the jQuery and CSS directly, otherwise they don't run. This is strange because I can physically see the loaded js files within the pages source code. Am I missing something?