WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 6 years ago

#27420 closed enhancement (duplicate)

get_stylesheet_directory(); function....windows backslash

Reported by: kosher_12 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8.1
Component: Themes Keywords:
Focuses: Cc:

Description

Hi There,

as the title says, is it possible to improve most of the wordpress path function in windows.

e.g.

$s = get_stylesheet_directory();
print_r($r);

output
F:\xampp\htdocs\wp\wp-content/themes/cmk

its not a big deal as most of wordpress developers,creates another function to output it properly, but I am thinking wordpress should fixed it from its core.

Cheers,
Kenn

Change History (3)

#1 @SergeyBiryukov
8 years ago

  • Component changed from General to Themes
  • Keywords close added
  • Type changed from feature request to enhancement

Sounds like a duplicate of #20849.

F:\xampp\htdocs\wp\wp-content/themes/cmk is a valid path on Windows, there's nothing wrong with it.

#2 @kosher_12
8 years ago

Thanks for the response,

Sorry for putting this on the wrong section. Never read anything before posting

Well, I never mentioned its invalid, indeed backslash isn't actually a problem until using it on validation statement like this then problem will occur.

if(strpos(MyPath(__FILE__), get_stylesheet_directory()) !== false){
	//Fly to the Sky
}

the problem is that, it will always return false, because of backlash

$f = MyPath(__FILE__);
$s = get_stylesheet_directory();
print_r($f.'<br/>'.$s);

output
F:/xampp/htdocs/wp/wp-content/themes/test/config/admin-config.php
F:\xampp\htdocs\wp/wp-content/themes/test

Yes, I can just simply do something like this MyPath(get_stylesheet_directory())

and viola, it works.

But my question is.

Why can't wordpress fix backslashes on its return value in all the path functions, I don't think its hard to fix.

or is there actually a reason why it should have backslashes?

#3 @chriscct7
6 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #20849.

Note: See TracTickets for help on using tickets.