- $file = PluginManager::$PLUGINS_PATH . '/default_colors/default_colors.css';
- $template = file_get_contents(PluginManager::$PLUGINS_PATH . '/default_colors/default_colors.css.template');
- $content = '';
- foreach (DEFAULT_COLORS_PLACEHOLDERS as $rule) {
- $content .= ! empty($data[$rule])
- ? default_colors_format_css_rule($data, $rule) .';'. PHP_EOL
- : '';
+ $params = [];
+ foreach (DEFAULT_COLORS_PLACEHOLDERS as $placeholder) {
+ $value = trim($conf->get('plugins.'. $placeholder, ''));
+ if (strlen($value) > 0) {
+ $params[$placeholder] = $value;
+ }
+ }
+
+ if (empty($params)) {
+ $error = t('Default colors plugin error: '.
+ 'This plugin is active and no custom color is configured.');
+ return [$error];
+ }
+
+ // Colors are defined but the custom CSS file does not exist -> generate it
+ if (!file_exists(PluginManager::$PLUGINS_PATH . DEFAULT_COLORS_CSS_FILE)) {
+ default_colors_generate_css_file($params);