Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

closed as too localized by toscho Jul 21 '12 at 22:06

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

This is strange because I can physically see the loaded js files within the pages source code. Am I missing something?

Are you sure they are loading? click on the links in the source and see if they lead to valid js source files because you may have issues with your paths such that your source says something like

<link rel='stylesheet' href='whatever.css'>

make sure whatever.css its invalid or else browser will ignore it. Please check your browsers error console and see.

share|improve this answer
It could be a path issue but I have checked all paths and have invoked "no conflict mode" in the controlling script with "jQuery" as a "$" shortcut replacement and I'm getting the same results, the scripts won't load (visible in page source) and works when I echo directly. – rumspringa00 Nov 1 '11 at 5:46
Here is the jQuery plugin that won't load okfoc.us/okshadow – rumspringa00 Nov 1 '11 at 5:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.