WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question

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.

share|improve this answer

It is an constant, only a string. For the separator / have PHP an constant. Also, this is WordPress, differently are stupid ;-)

share|improve this answer
Indeed. My question is why doesn't the WordPress code use the PHP constant instead of using a hardcoded slash which isn't always right (depending on what platform the code is running on). – Dave Amphlett Apr 17 '12 at 23:15
I think th php constant dont work on all systems and have different problems. – bueltge Apr 18 '12 at 16:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.