498 posts Keep Walking
  • Has been part of the Envato Community for over 4 years
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $250,000+ on Envato Market
  • Had an item that became a weekly top seller
+4 more
UXbarn
says

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.. :confused:

Thanks in advanced!

3802 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Had an item that was trending
  • Has been part of the Envato Community for over 7 years
+12 more
KrownThemes
says

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..).

381 posts
  • Had an item that became a weekly top seller
  • Elite Author: Sold more than $75,000 on Envato Market
  • Won a Most Wanted contest
  • Has sold $500,000+ on Envato Market
+7 more
redfactory
says

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 :)

13 posts
  • Has been part of the Envato Community for over 2 years
  • Sells items exclusively on Envato Market
xiaSKULL
says

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. :)

438 posts
  • Has been part of the Envato Community for over 3 years
  • Has sold $5,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
Pixelous
says

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?

498 posts Keep Walking
  • Has been part of the Envato Community for over 4 years
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $250,000+ on Envato Market
  • Had an item that became a weekly top seller
+4 more
UXbarn
says

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..

1073 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+5 more
Gareth_Gillman
says

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.

3802 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $750,000+ on Envato Market
  • Had an item that was trending
  • Has been part of the Envato Community for over 7 years
+12 more
KrownThemes
says

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.
Exactly! This is how i do it..
2468 posts
  • Has been part of the Envato Community for over 6 years
  • Has sold $100+ on Envato Market
  • Has referred 100+ members
  • Has been a beta tester for an Envato feature
+3 more
digitalimpact
says

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">
501 posts
  • Has referred 1000+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Became a Top 20 Author of the Month
+10 more
pixelentity
says

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

by
by
by
by
by
by