Most theme options were created and saved on PHP and I don’t know what is the proper way to apply those saved options to the CSS and JavaScript of the WordPress theme. Right now the CSS and JavaScript codes are all in the external files.
I was thinking of doing echo those options right away in the <script> or <style> block but maybe that isn’t a good practical way to do? 
Please advise.. 
Thanks in advanced!
- Most Wanted Bounty Winner
- Sold between 250 000 and 1 000 000 dollars
- Has been a member for 5-6 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Won a Competition
- Bought between 100 and 499 items
- Exclusive Author
- Referred between 200 and 499 users
Don’t put the theme options in the header. It’s not a good practice and it will just increase your header without any good reason.
You should do those changes directly inside the css files(for colors, backgrounds, etc..).
- Microlancer Beta Tester
- Sold between 250 000 and 1 000 000 dollars
- Most Wanted Bounty Winner
- Author was Featured
- Has been a member for 3-4 years
- Referred between 200 and 499 users
- Bought between 10 and 49 items
- Netherlands
We have an extra style.php file in which the options are echoed directly into the css. Make sure to only have the css that needs changing in that file, and to load it as last so it overwrites your default css rules.
Good luck 
redfactory said
We have an extra style.php file in which the options are echoed directly into the css. Make sure to only have the css that needs changing in that file, and to load it as last so it overwrites your default css rules. Good luck![]()
+1. 
redfactory said
We have an extra style.php file in which the options are echoed directly into the css. Make sure to only have the css that needs changing in that file, and to load it as last so it overwrites your default css rules. Good luck![]()
So, your style.php generate a style.css, right?
RubenBristian said
Don’t put the theme options in the header. It’s not a good practice and it will just increase your header without any good reason. You should do those changes directly inside the css files(for colors, backgrounds, etc..).
Then how could I apply those css changes to the css files dynamically? I just a bit confuse at this point..
- Most Wanted Bounty Winner
- Sold between 250 000 and 1 000 000 dollars
- Has been a member for 5-6 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Won a Competition
- Bought between 100 and 499 items
- Exclusive Author
- Referred between 200 and 499 users
Gareth_Gillman saidExactly! This is how i do it..
you would use the php file_open and write functions, this will enable the script to open the css file and save the contents to the file.
So nobody sets the headers for customstyles.php to
<?php header("Content-type: text/css"); ?> , adding it as any other external CSS to the head?
<link rel="styleheet" href="<?php bloginfo('stylesheet_directory'); ?>/customstyles.php" media="screen">- Sold between 100 000 and 250 000 dollars
- Won a Competition
- Author was Featured
- Item was Featured
- Referred between 500 and 999 users
- Author had a Free File of the Month
- Author had a File in an Envato Bundle
- Bought between 10 and 49 items
To echo custom rules inside a style block of header is not a bad practice and also has absolutely zero impact on performances/load times while to write an external css file with custom values requires an additional server request which is far more costly in terms of resources.
BF
