From 203f2b377b4469371ebbac48cb796ef444062935 Mon Sep 17 00:00:00 2001 From: sophie Date: Tue, 9 Aug 2022 15:50:08 -0400 Subject: [PATCH] Update Stylesheet.class.php Fixed #131, as well updated indentation and spacing for consistency. --- lib/Stylesheet.class.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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)); }