| | |
| | | } |
| | | } |
| | | |
| | | protected function regenerateCSS(array $sourcesToUpdate = []): void |
| | | { |
| | | error_log('[IconsManager]:regenerateCSS'); |
| | | $css_dir = JVB_CHILD_DIR.'/assets/css/'; |
| | | |
| | | if (!file_exists($css_dir)) { |
| | | wp_mkdir_p($css_dir); |
| | | } |
| | | |
| | | // If no specific sources provided, regenerate all |
| | | if (empty($sourcesToUpdate)) { |
| | | $sourcesToUpdate = array_fill_keys(array_keys(self::$instances), true); |
| | | } |
| | | |
| | | // Generate CSS only for sources that need it |
| | | foreach (self::$instances as $source => $instance) { |
| | | if (!isset($sourcesToUpdate[$source])) { |
| | | continue; // Skip this source |
| | | } |
| | | |
| | | $css = $instance->generateIconCSS(); |
| | | $css_path = $css_dir . $source . '.css'; |
| | | |
| | | // Archive current version before overwriting |
| | | $instance->archiveCurrentVersion($css); |
| | | |
| | | if (file_put_contents($css_path, $css) !== false) { |
| | | Cache::for('icons_'.$source)->flush(); |
| | | error_log("[IconsManager] Updated {$source}.css"); |
| | | } else { |
| | | error_log("[IconsManager] Could not write {$source}.css"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Prevent cloning |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Prevent unserialization |
| | | * @throws Exception |
| | | */ |
| | | public function __wakeup() |
| | | { |