Implements hook_advagg_css_contents_alter().
Used to run strings inside of quotes of the content attribute through the t function.
Voir aussi
\Drupal\Core\Asset\CssOptimizer::processCss
Fichier
-
advagg_mod/
advagg_mod.advagg.inc, line 16
Code
function advagg_mod_advagg_css_contents_alter(&$data, $css_asset) {
$config = \Drupal::config('advagg_mod.settings');
if (!$config->get('css_translate')) {
return;
}
// Code taken from \Drupal\Core\Asset\CssOptimizer::processCss().
// Regexp to match double quoted strings.
$double_quot = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"';
// Regexp to match single quoted strings.
$single_quot = "'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'";
// Extract all content inside of quotes.
$css_content_pattern = "/content:.*?({$double_quot}|{$single_quot}|(?:\\;|\\})).*?(?:\\;|\\})/";
// Run strings inside of quotes of the content attribute through the t
// function.
$data = preg_replace_callback($css_content_pattern, 'advagg_mod_advagg_css_content_t_replace_callback', $data);
}