Skip to content

Commit

Permalink
Merge pull request #185 from mmcev106/master
Browse files Browse the repository at this point in the history
Defer to WordPress for URLs instead of trying to guess them
  • Loading branch information
shadoath authored May 12, 2021
2 parents b95b619 + 1452011 commit 4f0c3dd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions class/class-wp-scss.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,18 @@ 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;
if($base_folder_path === wp_get_upload_dir()['basedir']){
$enqueue_base_url = wp_get_upload_dir()['baseurl'];
}
else if($base_folder_path === WPSCSS_PLUGIN_DIR){
$enqueue_base_url = plugins_url();
}
else if($base_folder_path === get_template_directory()){
$enqueue_base_url = get_template_directory_uri();
}
else{ // assume default of get_stylesheet_directory()
$enqueue_base_url = get_stylesheet_directory_uri();
}

foreach( new DirectoryIterator($this->css_dir) as $stylesheet ) {
if ( pathinfo($stylesheet->getFilename(), PATHINFO_EXTENSION) == 'css' ) {
Expand Down

0 comments on commit 4f0c3dd

Please sign in to comment.