WordPress Trac: Ticket #19388: plugin_basename returns full directory in URLhttps://core.trac.wordpress.org/ticket/19388
<p>
If a trailing slash is specified on either then WP_PLUGIN_DIR or WPMU_PLUGIN_DIR settings, the plugin_basename function returns the whole directory path in the URL.
</p>
<p>
The documentation does state not to use a trailing slash, however I think this function could be improved.
</p>
<p>
By removing the explicit / in the preg_replace the correct plugin name will be returned even if a trailing slash is specified on the WP_PLUGIN_DIR or WPMU_PLUGIN_DIR constants.
</p>
<p>
This should not affect the relative path as the trim before the return takes care of stripping off the first slash if it exists (effectively duplicating the remove in this case).
</p>
<p>
While this is a very trivial change that won't affect most people (who read the docs properly) it was quite annoying to track down.
</p>
<p>
Please see the attached diff.
</p>
en-usWordPress Trachttps://core.trac.wordpress.org/chrome/site/your_project_logo.pnghttps://core.trac.wordpress.org/ticket/19388
Trac 1.0.1damianzarembaTue, 29 Nov 2011 00:37:05 GMTattachment sethttps://core.trac.wordpress.org/ticket/19388
https://core.trac.wordpress.org/ticket/19388
<ul>
<li><strong>attachment</strong>
set to <em>plugin_basename.diff</em>
</li>
</ul>
TicketnacinTue, 29 Nov 2011 01:05:39 GMThttps://core.trac.wordpress.org/ticket/19388#comment:1
https://core.trac.wordpress.org/ticket/19388#comment:1
<p>
I'm fine with this, but what else might be affected with WP_PLUGIN_DIR and WPMU_PLUGIN_DIR being mis-defined with a trailing slash? We'll have to check other pieces of usage elsewhere.
</p>
TicketdamianzarembaTue, 29 Nov 2011 01:25:50 GMThttps://core.trac.wordpress.org/ticket/19388#comment:2
https://core.trac.wordpress.org/ticket/19388#comment:2
<p>
From a quick grep though the code, it seems that it would mostly cause a double slash in some file paths. I'm not familiar enough with the core to tell if that would cause issues with some of the wp-filesystem functions, however I've not seen any on my 3.3 install.
</p>
Ticketchriscct7Sun, 26 Oct 2014 21:55:13 GMTseverity changedhttps://core.trac.wordpress.org/ticket/19388#comment:3
https://core.trac.wordpress.org/ticket/19388#comment:3
<ul>
<li><strong>severity</strong>
changed from <em>minor</em> to <em>normal</em>
</li>
</ul>
<p>
Wouldn't this regress part of <a class="closed ticket" href="https://core.trac.wordpress.org/ticket/9561" title="enhancement: plugins_dir() and plugins_basename() should also work for plugins in the ... (closed: fixed)">#9561</a>?
</p>
Ticket