[wp-trac] [WordPress Trac] #48099: get_stylesheet_directory() and get_stylesheet_directory() are front-slashed even in Windows environment

WordPress Trac noreply at wordpress.org
Sat Sep 21 15:34:50 UTC 2019


#48099: get_stylesheet_directory() and get_stylesheet_directory() are front-slashed
even in Windows environment
----------------------------------------+-----------------------------
 Reporter:  KestutisIT                  |      Owner:  (none)
     Type:  defect (bug)                |     Status:  new
 Priority:  normal                      |  Milestone:  Awaiting Review
Component:  Themes                      |    Version:  5.2.3
 Severity:  normal                      |   Keywords:  needs-patch
  Focuses:  template, coding-standards  |
----------------------------------------+-----------------------------
 So, despite that DIRECTORY_SEPARATOR PHP constant is correct if Windows OS
 environment (for i.e. XAMPP), and is `\`, WordPress returns paths url-like
 - `/`.
 So we have to run a replacements in our UI_Routing class to have a correct
 paths, despite the fact that Windows recognizes both, the paths are
 looking strange when they have some chars forward-slashed, and some -
 back-slashed.
 {{{#!php
 <?php
 $currentThemePath = str_replace(array('/', '\\'),
 array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR),
 get_stylesheet_directory());
 $parentThemePath = str_replace(array('/', '\\'),
 array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR),
 get_stylesheet_directory());
 $uiPathInCurrentTheme =
 $currentThemePath.DIRECTORY_SEPARATOR.$this->themeUI_FolderName.DIRECTORY_SEPARATOR;
 $uiPathInParentTheme =
 $parentThemePath.DIRECTORY_SEPARATOR.$this->themeUI_FolderName.DIRECTORY_SEPARATOR;

 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48099>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list