Skip to content

Commit

Permalink
Merge pull request #175 from ConnectThink/enqueue-url-not-path
Browse files Browse the repository at this point in the history
Enqueue css with URL.
  • Loading branch information
shadoath authored Mar 12, 2021
2 parents 9e2b22d + 6a88391 commit 5cc59d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions class/class-wp-scss.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions wp-scss.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ) {
Expand Down

0 comments on commit 5cc59d3

Please sign in to comment.