/** * Correct Stylesheet URI * * It enables the cache without loosing reference to URI * * @author oncletom * @since 1.2 * @version 1.1 * @param string $css parsed CSS * @param WPLessStylesheet Stylesheet currently processed * @return string parsed and fixed CSS */ public function filterStylesheetUri($css, WPLessStylesheet $stylesheet) { $token = '@' . uniqid('wpless', true) . '@'; $css = preg_replace('#url\\s*\\(([\'"]{0,1})([^\'"\\)]+)\\1\\)#siU', 'url(\\1' . $token . '\\2\\1)', $css); /* * Token replacement: * - preserve data URI * - prefix file URI with absolute path to the theme */ $css = str_replace(array($token . 'data:', $token), array('data:', dirname($stylesheet->getSourceUri()) . '/'), $css); return $css; }
/** * Correct Stylesheet URI * * It enables the cache without loosing reference to URI * * @author oncletom * @since 1.2 * @version 1.2 * @param string $css parsed CSS * @param WPLessStylesheet Stylesheet currently processed * @return string parsed and fixed CSS */ public function filterStylesheetUri($css, WPLessStylesheet $stylesheet) { $this->_TmpBaseDir = str_replace('https://', 'http://', dirname($stylesheet->getSourceUri())); return preg_replace_callback('#url\\s*\\((?P<quote>[\'"]{0,1})(?P<url>[^\'"\\)]+)\\1\\)#siU', array($this, '_filterStylesheetUri'), $css); unset($this->_TmpBaseDir); }