diff --git a/class/class-wp-scss.php b/class/class-wp-scss.php index e3576c45..2098dce6 100644 --- a/class/class-wp-scss.php +++ b/class/class-wp-scss.php @@ -211,15 +211,20 @@ public function style_url_enqueued($url){ * so it can be used in a url, not path */ public function enqueue_files($base_folder_path, $css_folder) { + // We use realpath() to normalize any forward, backward, or trailing slack inconsistencies. + $relative_path = explode(realpath(get_home_path()), realpath($base_folder_path))[1]; + + // In case we're on a Windows machine + $relative_path = str_replace('\\', '/', $relative_path); + + $enqueue_base_url = get_home_url() . '/' . $relative_path; - $relative_path = explode(get_home_path(), $base_folder_path)[1]; foreach( new DirectoryIterator($this->css_dir) as $stylesheet ) { if ( pathinfo($stylesheet->getFilename(), PATHINFO_EXTENSION) == 'css' ) { $name = $stylesheet->getBasename('.css') . '-style'; - $uri = '/'.$relative_path.$css_folder.$stylesheet->getFilename(); + $uri = $enqueue_base_url . $css_folder . $stylesheet->getFilename(); $ver = $stylesheet->getMTime(); - wp_register_style( $name, $uri, diff --git a/readme.md b/readme.md index ff4bdc0a..03522bd2 100644 --- a/readme.md +++ b/readme.md @@ -89,6 +89,8 @@ Alternatively, you can include [Bourbon](https://github.com/thoughtbot/bourbon) This plugin will only work with .scss format. ## Changelog +* 2.1.5 + * Enqueue CSS files using `realpath` function. Addition by [mmcev106](https://github.com/ConnectThink/WP-SCSS/pull/179) * 2.1.4 * Set source URL to be home_url('/') not simply `/`. Issue found by [realjjaveweb](https://github.com/ConnectThink/WP-SCSS/issues/128) * 2.1.3 diff --git a/wp-scss.php b/wp-scss.php index 55b1a633..58cc4cf2 100644 --- a/wp-scss.php +++ b/wp-scss.php @@ -3,7 +3,7 @@ * Plugin Name: WP-SCSS * Plugin URI: https://github.com/ConnectThink/WP-SCSS * Description: Compiles scss files live on WordPress. - * Version: 2.1.4 + * Version: 2.1.5 * Author: Connect Think * Author URI: http://connectthink.com * License: GPLv3 @@ -44,7 +44,7 @@ define('WPSCSS_VERSION_KEY', 'wpscss_version'); if (!defined('WPSCSS_VERSION_NUM')) - define('WPSCSS_VERSION_NUM', '2.1.4'); + define('WPSCSS_VERSION_NUM', '2.1.5'); // Add version to options table if ( get_option( WPSCSS_VERSION_KEY ) !== false ) {