Surely i’m not the only one experiencing this?
plugins_url('js/my-js-file.js', dirname(__FILE__)); or plugins_url('js/my-js-file.js', __FILE__);
produces:
http://localhost:8888/my/path/wp-content/plugins/my/local/path/wp-content/plugins/anyplugin/js/my-js-file.js
Alternatively:
plugins_url('js/my-js-file.js'); or plugins_url('js/my-js-file.js', 'anyplugin');
produces:
http://localhost:8888/my/path/wp-content/plugins/js/my-js-file.js
This could be in the wrong area, but since this isn’t working locally, i’m not game enough to try this on a live server….
OK, for anyone that cares, after doing some digging, it is a case-sensitive issue.
WP_PLUGIN_DIR has folders in ‘camel’ case where dirname(__FILE__) has some of the folders lowercase.
I have gone through my file structure and made all folders lowercase (outside folders from site structure that MAMP was using), reset MAMP servers and all is good.
A fix that worked for me, rather than renaming everything lower case, was to add an i modifier to the reg expression in plugin_basename() as below:
$file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#i','',$file); // get relative path from plugins dir
This line can be found in wp-includes/plugin.php on line 572.
This worked with my install but I’m not sure what other implications it may have, so test before using!
real-bassman,
Glad to hear but I wouldn’t be suggesting changing core functionality in files, purely because the next update will override that change.
I would really suggest a fix outside core files, the only one I could find was the renaming of the folders.
Not sure if you found a way around this, but you might look at my solution at https://gist.github.com/aubreypwd/7828624
Also, check out http://core.trac.ww.wp.xz.cn/ticket/16953 on the status of this issue.