I would like to create a theme options page based only on changing the site wide CSS styling. For instance body/container background colors, font-sizes, font colors, etc.
I have accomplished this by using a stylesheet link to a php file in the header that echo’s the CSS and uses get_option.
For instance background-color: <?php echo get_option('background_color'); ?>;
Would I be correct in assuming this is a bad idea performance wise if there are many options?
I have tried other methods but they all seem to add inline or embedded styles, which I do not want, how would one get around this?
Would creating a custom script that writes to the static CSS file be a good idea?
Is there any way the settings API can handle this?
** PS. Great answer but I have decided to actually go with writing to a static file as it provides way less overhead.
creating a custom script that writes to the static CSS file is a bad idea!!!
you would need to regenerate the file each time you save any changes.
a better solution would be to save all options in an array of options say for example:
and that why you only call the “get_option()” function once.
and make much less calls to the database and use less resources if you are thinking performance wise.