You are here

function csstidy::css_new_selector in Advanced CSS/JS Aggregation 6

Start a new selector. If already referenced in this media section, rename it with extra space to avoid merging except if merging is required, or last selector is the same (merge siblings)

never merge @font-face

Parameters

string $media:

string $selector:

Return value

string

1 call to csstidy::css_new_selector()
csstidy::parse in advagg_css_compress/csstidy/class.csstidy.inc
Parses CSS in $string. The code is saved as array in $this->css

File

advagg_css_compress/csstidy/class.csstidy.inc, line 1047

Class

csstidy
CSS Parser class

Code

function css_new_selector($media, $selector) {
  if ($this
    ->get_cfg('preserve_css')) {
    return $selector;
  }
  $selector = trim($selector);
  if (strncmp($selector, "@font-face", 10) != 0) {
    if ($this->settings['merge_selectors'] != false) {
      return $selector;
    }
    if (!$this->css or !isset($this->css[$media]) or !$this->css[$media]) {
      return $selector;
    }

    // if last is the same, keep it
    end($this->css[$media]);
    list($sel, ) = each($this->css[$media]);
    if ($sel == $selector) {
      return $selector;
    }
  }
  while (isset($this->css[$media][$selector])) {
    $selector .= " ";
  }
  return $selector;
}