[theme-reviewers] Dynamic CSS and WP Customizer API

Konstantin Kovshenin kovshenin at gmail.com
Sun May 11 09:06:29 UTC 2014


The way described in the article on CSS Tricks will not work for many
WordPress installations. For example one where the name of wp-content
or the themes folder is redefined in wp-config.php, or one where PHP
scripts are not allowed to be executed within the whole wp-content
directory for security reasons.

That said, printing the styles inline might not be the best option,
especially if there's a lot of them. You might want to try and do
something like Jetpack Custom CSS does, i.e. watch for a $_GET
variable very very early, like plugins_loaded or after_setup_theme in
your case, dump your CSS and exit. You can even go further and add a
rewrite rule to that tricks browsers into thinking your CSS is an
actual styles.css file and treat it more like one, in other words -
cache it.

On Sun, May 11, 2014 at 4:44 AM, Chip Bennett <chip at chipbennett.net> wrote:
> +1 for wp_add_inline_style() for dynamic (theme option or custom) CSS
> overrides.
>
>
> On Sat, May 10, 2014 at 6:32 PM, Sheri Bigelow <sheri at designsimply.com>
> wrote:
>>>
>>> About the Theme Customizer API and dynamic CSS, I wondered if it was
>>> better to add styles with wp_add_inline_style() or to add a dynamic css like
>>> this and enqueue them with wp_enqueue_style() ?
>>
>>
>> I think adding styles with wp_add_inline_style() would be better than
>> generating CSS in a PHP file like in the example you linked to because the
>> PHP route seems like more overhead to me plus it's an extra file where you
>> don't need to make an extra file.
>>
>> _______________________________________________
>> theme-reviewers mailing list
>> theme-reviewers at lists.wordpress.org
>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>
>
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>



-- 
Konstantin


More information about the theme-reviewers mailing list