WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Plugins_url output erroring (6 posts)

  1. Ash Durham
    Member
    Posted 1 year ago #

    I haven't had the chance to test this on a live server but I upgraded from 3.5 to 3.6 locally and all the plugins I have installed are now broken due to the plugins_url function adding the site url then the root url after it.

    1) is this only related to localhost versions and 2) is this I known 3.6 bug?

  2. Ash Durham
    Member
    Posted 1 year ago #

    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....

  3. Ash Durham
    Member
    Posted 1 year ago #

    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.

  4. real-bassman
    Member
    Posted 1 year ago #

    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!

  5. Ash Durham
    Member
    Posted 1 year ago #

    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.

  6. Aubrey Portwood
    Member
    Posted 8 months ago #

    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.wordpress.org/ticket/16953 on the status of this issue.

Topic Closed

This topic has been closed to new replies.

About this Topic