Whilst writing some code that backs-up a plugin, I hit a problem with ‘the wrong kind of directory slash’ on my windows dev environment.
Tracking it through I find in default-constants.php:91
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
which is based on the following in default-constants.php:46
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
and hence to the config file definition…
define('ABSPATH', dirname(__FILE__) . '/');
So my question is:
Q. Why are both ABSPATH and WP_CONTENT_DIR, which are intrinsically file system specific (ie can’t be interpreted for URL’s), definied using explicit forward slashes, rather than PHP’s own DIRECTORY_SEPARATOR ?
The forward slash works on every operating system supported by PHP. Yes, on Windows too. It is also more readable and easier to type, so there is no need to use the constant.
See the tickets #20849 and #15598 for related discussion on Trac.
It is an constant, only a string. For the separator / have PHP an constant.
Also, this is WordPress, differently are stupid 😉