Another Plugin: Custom CSS for MultiSite

Hello :slight_smile:

I have a site and I wanted to edit the styles. Unfortunately, the theme I am using doesn't include a CSS editor.

I don't like Jetpack.
And I don't like the security of other CSS plugins.

So I made my own.

I wrecked the following plugin to pieces and made it to something beautiful, but not quite yet...

What it does differently:
1. It parses the CSS through CSStidy (like Jetpack's Custom CSS)
2. It stores revision data
3. It parses through wp_kses_split for safer CSS output (no more content: behaviour: and other weird calls)
4. It out-comments @import instructions
5. It doesn't parse the CSS while outputting, but rather before storing it in options, this way the CSS call is super fast.
6. Outputs to "file" if there are more than 2000 characters in the CSS. This file will be cached by the browser.
7. Better code quality

I found number 5 and 6 to be the most compelling. I like fast websites :slight_smile:

My todo list for this plugin:
1. Make it even more secure. You can still call Javascript but this is only parsed in Internet Explorer 8 or earlier (oh...) and old Firefox versions.
2. Auto-fix wrong color calls like #4444 (should become #444 or #444444)
3. Make the interface prettier
4. Revision maintaining
5. Preview edits in browser before updating
6. Saving it to file for each blog so a CDN can cache it. I still haven't found a nice way to do so unfortunately.
7. More object caching
8. Minify the output!

Where you can use it for:
1. Pro Sites! The Premium Plugin feature really works well with this. Turn on auto-activation and feel free to sell this plugin as another great addition to your subscriptions.
2. Your own site, any site!
3. If you want to maintain your CSS in one place but want to switch themes, it's still there!

How it's used
1. Upload the contents of the zip (download below) into your plugins folder
2. Activate plugin
3. Under "Appearance" settings you can find "Custom CSS"
4. Add your CSS there.
5. Hit the update button.
6. All the CSS is now processed through CSSTidy and then sanitized. You can see the output directly in the editor.
7. From here it's added to the header of each page of your website. If you want it removed you'd have to remove all the CSS for now.

What you should be cautious about
1. wp_kses_split is quite aggressive. And there's no revision history yet. "Accidentally" add the word "behaviour" (very unsafe) and everything thereafter will be deleted. So keep a copy on your own computer!
2. Keep coming back here for updates. I'll add this to the WordPress plugin repository when I'm happy with it :slight_smile: Or I'm going to find out how to make my own update server, lol. This is something you want to keep updated.

Final thoughts
This plugin is posted here to be used by other professionals, but isn't quite what I want it to be yet. It has been written in 2 days (about 34 hours of work) and I will put a lot more time in it.

Idea's, found bugs or want a dangerous piece of code to be excluded?
Leave them on this thread :slight_smile: