diff --git a/lib/Stylesheet.class.php b/lib/Stylesheet.class.php index 5164632..ad52016 100644 --- a/lib/Stylesheet.class.php +++ b/lib/Stylesheet.class.php @@ -82,14 +82,18 @@ public function computeTargetPath() */ protected function configurePath() { - $target_file = $this->computeTargetPath(); + $target_file = $this->computeTargetPath(); // path to local "wp-content" dir does not match URI in multisite. - $wp_content_dir = str_replace(ABSPATH, '', WP_CONTENT_DIR); // get the 'wp-content' part of the path - $lessfile_in_theme = preg_replace ('#^.*?' . DIRECTORY_SEPARATOR . $wp_content_dir . DIRECTORY_SEPARATOR . '(.*)$#', '$1', $this->stylesheet->src, 1); // the part after 'wp-content' - $this->source_path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $lessfile_in_theme; - $this->source_uri = $this->stylesheet->src; - $this->target_path = self::$upload_dir.$target_file; - $this->target_uri = self::$upload_uri.$target_file; + $wp_content_dir = str_replace(ABSPATH, '', WP_CONTENT_DIR); // get the 'wp-content' part of the path + + $stylesheet_separator = str_contains($this->stylesheet->src, '/') ? '/' : '\\'; + $wp_content_replace_pattern = '#^.*?' . $stylesheet_separator . $wp_content_dir . $stylesheet_separator . '(.*)$#'; + $lessfile_in_theme = preg_replace ($wp_content_replace_pattern, '$1', $this->stylesheet->src, 1); // the part after 'wp-content' + + $this->source_path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $lessfile_in_theme; + $this->source_uri = $this->stylesheet->src; + $this->target_path = self::$upload_dir.$target_file; + $this->target_uri = self::$upload_uri.$target_file; $this->setSourceTimestamp(filemtime($this->source_path)); }