More often than not plugins and themes offer options that will result in CSS modifications. Now you can just print those CSS rules in the head of the document, but depending on how many options you have that can potentially make the source code look like a complete mess… All those CSS rules would be better off in a completely separate CSS file.

So here is how you build a dytamic stylesheet and enqueue it to WordPress’s header.

Just get your plugin/themes option, build the corresponding CSS statement and concadenate it to the $content variable


 

Note 1: The above code is good to use be used in plugins, but can easily be adapted to themes too, simply replace the last line hook for ‘after_setup_theme’ instead of  ‘plugins_loaded’