I need to traverse through a CSS file finding specific items and changing their CSS to updated stuff for a theme editor. I have a variable with all the CSS for between the curly braces, I just need to find a way to select the braces after the given tag and replace the contents. Any help would be greatly appreciated! Thanks
Share
Maybe not the only solution, but have you thought about putting the CSS into the database and generate the CSS file on the fly?
Storing it in the database also gives you the possibility to re-generate the file every time somethings changed and have it cached like that to save performance.
To modify an existing file you probably need to traverse through the file and hope that nobody manually changes the style conventions for your CSS-file and replace as you go along by remembering the last tag/class/id expression like that (will probably not work out of the box!):