• 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)
  • @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)

    Great solution @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.