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 or block but maybe that isn’t a good practical way to do?
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.
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.
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.
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.
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
so if i have 200 lines of custom css code, should i add it to the header of each file?
I also use a dynamic style tag in the header for style options. Putting stuff in a special file (like the css.php example file )only complicates things because that means a new set of queries for wordpress to make to generate a new file + another file to request/load from server. Is not worth the cost, in my opinion.
For custom CSS styling I generate + minify css file and save it on server only when user clicks on ‘Save Changes’ button in theme options, so there are no additional WP queries made on each page view.
Hmm. It looks like a kind of trade-off between the two methods right?
At first, I thought echoing custom style block directly to the header may not be a good way because the page would look too messy and, you know, kind of unorganized way to do so. But I never realized the fact of the performance as @pixelentity mentioned. That’s very great to know.
I just tried the method of “special” style file like style.php and that works perfectly too.
This is quite questionable for which one is better…
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
Exactly what i wanted to say. STAY AWAY FROM EXTERNAL PHP FILES. They have huge impact on performance and if they have the folder wp-content set to 777 or any folder that is parent to the php file it will not execute on some servers. Trust me, we used it with fortune and three and we had issues, so we added the extra styles in the header, that loads faster and less support on the matter. In short - NO TO EXTERNAL PHP
For custom CSS styling I generate + minify css file and save it on server only when user clicks on ‘Save Changes’ button in theme options, so there are no additional WP queries made on each page view.
For custom CSS styling I generate + minify css file and save it on server only when user clicks on ‘Save Changes’ button in theme options, so there are no additional WP queries made on each page view.
How many customers had issues with this? I can bet that many did not have the permission set for the file/folder and windows servers will bust the writing process + get_files_content restriction in effect, those are a few problems that i can say for sure that you have with this.