Minifie style.php in head of index.php

i currently have an wordpress theme options page. I read all the theme options styles in style.php which i then include in the head of my website.

Does anyone know how to minify this style.php file?

most of the "on-the-fly" scripts offer an solution, but it changes the header which results in an error message "headers already sent".

header.php:

<style>
    <?php require_once('css/style.php');?>
</style>

style.php:

<?php
?>
body {
    background-color:<?php global $variable; echo $variable['color-background'];?>;
    font-family:<?php global $variable; echo $variable['typography6']['font-family'];?>;
}

a {
    color: <?php global $variable; echo $variable['link-color']['regular'];?>;
}

<?php

?>

does anyone have a solution?

Solutions

Take a look at the CssMin-project. It's a PHP-class that helps you with this.

Similar questions

How to move style from template file to <head> section?
Imagine the following situation: This will disable <header> for my-template.php in the most modern browsers (except IE9) but it's not valid solution. Is there a way to use something like wp_enqueue_style(); directly in my-template.php to make it load that style in <head> in header.php? Just to make it valid. I want to keep this modular,...
How to debug theme (Theme is causing pages to have no style or HTML <head> section)
I have a WordPress theme given to me by a client, so not familiar with it at all. Activating the Twenty Sixteen theme resolves the problem, so it's not a plugin but definitely the client's theme. Certain pages are being displayed with no or sections. Just the <div>....</div> fragment. The content of the page is therefore just black text...
Append style tag in head while shortcode runs
I have a plugin with shortcode. Shortcode returns some html in page. I will have some dynamically generated css that I want to place in the page as well. I tried using wp_add_inline_style (to hook to my main css file added with wp_enqueue_style) however I can still see FOUC in this case. I would like an alternative like this, to echo some dynamic s...
Remove style tags from head
is there a filter for removing style-tags from the <head></head> area in wordpress? I want remove this style for instance: I already achieved to remove link-tags by using this wordpress filter and some regex: I guess i havbe to use wp_head somehow but I'm not sure how to use this as filter?
To hide style code in head from source code
When I look to source code of my website, i can see there: I have not it in header.php. What should I do to remove it from source code? My website on Wordpress.
The mandatory text (CDATA) inside tag 'head > style[amp-boilerplate]' is missing or incorrect
Why am I receiving this error? i use wordpress and using Automattic AMP plugin. The mandatory text (CDATA) inside tag 'head > style[amp-boilerplate]' is missing or incorrect. MANDATORY_AMP_TAG_MISSING_OR_INCORRECT line 1, column 473 The mandatory text (CDATA) inside tag 'noscript > style[amp-boilerplate]' is missing or incorrect. MANDATORY_AMP_TAG_...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.