WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#12080 closed defect (bug) (fixed)

plugins_url() does not correctly detect mu-plugins on Windows

Reported by: TheDeadMedic Owned by:
Milestone: 3.0 Priority: low
Severity: minor Version: 2.9.1
Component: Multisite Keywords:
Focuses: Cc:

Description

if ( $plugin !== '' && preg_match('#^' . preg_quote(WPMU_PLUGIN_DIR . DIRECTORY_SEPARATOR, '#') . '#', $plugin) ) {
    $url = WPMU_PLUGIN_URL;
} else {
    $url = WP_PLUGIN_URL;
}

Even if $plugin is in mu-plugins, the preg_match will fail on Windows systems if __FILE__ is passed as $plugin, since WPMU_PLUGIN_DIR contains forward slashes (whereas __FILE__ on Windows are all backslashes).

Proposed fix is to apply path formatting to WPMU_PLUGIN_DIR and $plugin found in plugin_basename().

$mu_plugin_dir = str_replace('\\','/',WPMU_PLUGIN_DIR); // sanitize for Win32 installs
$mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash

Change History (2)

comment:1 dd324 years ago

  • Milestone changed from Unassigned to 3.0

comment:2 dd324 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [12963]) Fix plugins_url() for MU-plugins when running on Windows. Fixes #12080

Note: See TracTickets for help on using tickets.