Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path wrong when using wp_enqueue_script #114

Closed
kdesouza7 opened this issue Aug 4, 2011 · 3 comments
Closed

Path wrong when using wp_enqueue_script #114

kdesouza7 opened this issue Aug 4, 2011 · 3 comments

Comments

@kdesouza7
Copy link

Hi Im using your ROOTS framework 3.2.4, everything has gone great but when I put some javascript files to be loaded last using wp_enqueue_script .

The path for the file has duplicated the basename for example "http://localhost/bollards2u.co.uk/bollards2u.co.uk/js/css3-mediaqueries.js".
This only happens when you use wp_enqueue_script.

header.php

wp_enqueue_script('jquery-tools', 'http://cdn.jquerytools.org/1.2.5/all/jquery.tools.min.js'); // jQuery Tools JS
wp_enqueue_script('fancybox', get_template_directory_uri().'/js/jquery.fancybox-1.3.4.pack.js', array(), NULL, true); // FancyBox JS
wp_enqueue_script('custom-scripts', get_template_directory_uri().'/js/scripts.js', array(), NULL, true); // Custom JS
wp_enqueue_script('addthis', 'http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4e2802c07ba83d25', array(), NULL, true); // AddThis JS
wp_head();

Output HTML

script type='text/javascript' src='http://localhost/bollards2u.co.uk/bollards2u.co.uk/js/css3-mediaqueries.js'></script>
script type='text/javascript' src='http://localhost/bollards2u.co.uk/bollards2u.co.uk/js/jquery.fancybox-1.3.4.pack.js'></script>
script type='text/javascript' src='http://localhost/bollards2u.co.uk/bollards2u.co.uk/js/scripts.js'></script>
script type='text/javascript' src='http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4e2802c07ba83d25'></script>
script type='text/javascript' src='http://localhost/bollards2u.co.uk/bollards2u.co.uk/plugins/contact-form-7/jquery.form.js?ver=2.52'></script>
script type='text/javascript' src='http://localhost/bollards2u.co.uk/bollards2u.co.uk/plugins/contact-form-7/scripts.js?ver=2.4.6'></script>

Any small fix for this without hacking your entire code?

@swalkinshaw
Copy link
Member

I'll probably investigate this further, but the obvious workaround is to just not use wp_enqueue_script. Since you aren't taking advantage of the dependencies, versions, or scripts WordPress knows about, there isn't much reason to use wp_enqueue_script in my opinion.

You can just use regular script tags like Roots does:

<script src="<?php echo get_template_directory_uri(); ?>/js/libs/modernizr-2.0.6.min.js"></script>

@dfrosso
Copy link

dfrosso commented Aug 8, 2011

I'm using Roots Theme in a local installation, and I'm having a problem with the path of the js and css files of installed plugins.

For example: link rel='stylesheet' id='wpetss-css' href='http://localhost:8888/my-site/my-site/plugins/wpetss/wpetss.css?ver=3.2.1' type='text/css' media='all'.

You can see the duplicated name in the url (my-site), this is how it looks in the html output.

Any suggestion to solve this issue?

@retlehs
Copy link
Sponsor Member

retlehs commented Aug 10, 2011

there's a bug with the roots_root_relative_url function in roots-cleanup.php right now that's causing this, seems to affect subfolder installs.

@swalkinshaw is looking into it

oxyc pushed a commit to generoi/sage that referenced this issue May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants