Title: Enqueue Stylesheets functionality is broken
Last modified: March 2, 2021

---

# Enqueue Stylesheets functionality is broken

 *  [emorgan248](https://wordpress.org/support/users/emorgan248/)
 * (@emorgan248)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/enqueue-stylesheets-functionality-is-broken/)
 * Hi,
 * Enqueue Stylesheets functionality is broken in 2.1.3.
 * The visible effect of the bug is that css file couldn’t be found and returns 
   404 error.
 * The actual reason is that css file’s uri is wrong – see enqueue_files function
   in class-wp-scss.php, line 215 “$relative_path = …”.
 * Below is my suggestion how to fix this:
 *     ```
       public function enqueue_files() {
   
           $css_dir_uri = get_site_url() . '/' . str_replace( ABSPATH, '', $this->css_dir );
           foreach( new DirectoryIterator($this->css_dir) as $stylesheet ) {
             if ( pathinfo($stylesheet, PATHINFO_EXTENSION) == 'css' ) {
               $name = 'wp-scss-' . pathinfo($stylesheet, PATHINFO_FILENAME);
               $uri =  $css_dir_uri . $stylesheet->getFilename();
               $ver = $stylesheet->getMTime();
   
               wp_register_style(
                 $name,
                 $uri,
                 array(),
                 $ver,
                 $media = 'all' );
   
               if(!$this->style_url_enqueued($uri)){
                 wp_enqueue_style($name);
               }
             }
           }
         }
       ```
   
 * I’ve deployed it on my site and it works for me. You are welcome to run it through
   your tests. We really need the working release.
 * Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Kanaksinh Rahevar](https://wordpress.org/support/users/krzwt/)
 * (@krzwt)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/enqueue-stylesheets-functionality-is-broken/#post-14164904)
 * [@emorgan248](https://wordpress.org/support/users/emorgan248/)
 * Hi,
 * Here is another solution to this issue.
 *     ```
       public function enqueue_files($base_folder_path, $css_folder) {
           $base_folder_path = str_replace('\\', '/', $base_folder_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();
               $ver = $stylesheet->getMTime();
   
               wp_register_style(
                 $name,
                 $uri,
                 array(),
                 $ver,
                 $media = 'all' );
   
               if(!$this->style_url_enqueued($uri)){
                 wp_enqueue_style($name);
               }
             }
           }
         }
       ```
   
 * Thanks
    Kanksinh (from [Zealousweb Technologies](https://www.zealousweb.com/))
 *  [briansgnm](https://wordpress.org/support/users/briansgnm/)
 * (@briansgnm)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/enqueue-stylesheets-functionality-is-broken/#post-14286799)
 * Great solution [@emorgan248](https://wordpress.org/support/users/emorgan248/)!
   The dev. team should update the plugin with a permanent solution.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Enqueue Stylesheets functionality is broken’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-scss_222222.svg)
 * [WP-SCSS](https://wordpress.org/plugins/wp-scss/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-scss/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-scss/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-scss/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-scss/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-scss/reviews/)

 * 2 replies
 * 3 participants
 * Last reply from: [briansgnm](https://wordpress.org/support/users/briansgnm/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/enqueue-stylesheets-functionality-is-broken/#post-14286799)
 * Status: not resolved