Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Ambiguous title, yes. Sorry.

I am using the roots framework to register scripts and stylesheets.

When I include the wp_enqueue_script('main_js'); my style sheets come out as <style media="" data-href="/_css/main.css?ver=5"> rather than <link>. If I comment out the wp_enqueue_script('main_js'); then everything works as it should (except no main.js) file.

I was wondering what gives? Am I doing something wrong?

This is what I have:

<?php function roots_scripts() {
    wp_enqueue_style('main_css', get_template_directory_uri() . '/_css/main.css', false, "5");

    wp_enqueue_style('animation_css', get_template_directory_uri() . '/_css/animation.css', array('main_css'), null);

    // CONDITIONAL CSS SHEETS
    if(is_singular('product')) { wp_enqueue_style('single_css', get_template_directory_uri() . '/_css/single.css', array('main_css', 'animation_css'), null); }
    if(is_page() || is_archive()) { wp_enqueue_style('page_css', get_template_directory_uri() . '/_css/page.css', array('main_css', 'animation_css'), null); }


    // ADD GOOGLE CDN
    if (!is_admin() && current_theme_supports('jquery-cdn')) {
        wp_deregister_script('jquery');
        wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', false, null, false);
        add_filter('script_loader_src', 'roots_jquery_local_fallback', 10, 2);
    }


    // MAIN JS
    wp_register_script('modernizr', get_template_directory_uri() . '/_js/modernizr.js', false, null, false);
    wp_register_script('main_js', get_template_directory_uri() . '/_js/main.js', array("jquery"), "5", false);

    // ENQUEUE JS && CSS FILES
    wp_enqueue_script('jquery');
    wp_enqueue_script('modernizr');
    wp_enqueue_script('main_js');

}
add_action('wp_enqueue_scripts', 'roots_scripts', 100);

function roots_jquery_local_fallback($src, $handle) {
    static $add_jquery_fallback = false;
    if ($add_jquery_fallback) {
    echo '<script>window.jQuery || document.write(\'<script src="' . get_template_directory_uri() . '/_js/jquery.js"><\/script>\')</script>' . "\n";
        $add_jquery_fallback = false;
    }
    if ($handle === 'jquery') { $add_jquery_fallback = true; }
    return $src;
}

function roots_google_analytics() { ?>
    <script>var a=document.createElement("script"),b=document.getElementsByTagName("script")[0];a.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";b.parentNode.insertBefore(a,b);</script>
<?php } if (GOOGLE_ANALYTICS_ID && !is_user_logged_in()) { add_action('wp_footer', 'roots_google_analytics', 20); }
share|improve this question
    
The above code work fine :) –  Tamil Selvan Apr 6 '13 at 4:19
    
what wordpress version u used –  Tamil Selvan Apr 6 '13 at 4:19
    
@TamilSelvan turns out its a bug with webkit (occurs only in Chrome and Safari inspector): stackoverflow.com/questions/9975393/… –  Ahhhhhhhhhhhhhdfgbv Apr 6 '13 at 4:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.