384 posts Keep Walking
  • Has been a member for 3-4 years
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Bought between 100 and 499 items
  • Referred between 100 and 199 users
  • Exclusive Author
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!

3251 posts Nice Guy
  • Forum Superstar
  • Most Wanted Bounty Winner
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 6-7 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Won a Competition
  • Bought between 100 and 499 items
  • Exclusive Author
+6 more
RubenBristian 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
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Microlancer Beta Tester
  • Most Wanted Bounty Winner
  • Has been a member for 4-5 years
  • Referred between 200 and 499 users
  • Bought between 10 and 49 items
+1 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
  • Europe
  • Exclusive Author
  • Has been a member for 1-2 years
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. :)

439 posts
  • Bought between 50 and 99 items
  • Europe
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 5 000 and 10 000 dollars
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?

384 posts Keep Walking
  • Has been a member for 3-4 years
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Bought between 100 and 499 items
  • Referred between 100 and 199 users
  • Exclusive Author
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..

454 posts
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Microlancer Beta Tester
  • Referred between 1 and 9 users
  • United Kingdom
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.

3251 posts Nice Guy
  • Forum Superstar
  • Most Wanted Bounty Winner
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 6-7 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Won a Competition
  • Bought between 100 and 499 items
  • Exclusive Author
+6 more
RubenBristian 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..
2429 posts
  • Has been a member for 4-5 years
  • Exclusive Author
  • Europe
  • Bought between 10 and 49 items
  • Referred between 100 and 199 users
  • Sold between 100 and 1 000 dollars
  • Microlancer Beta Tester
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">
488 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Won a Competition
  • Referred between 1000 and 1999 users
  • Author had a Free File of the Month
  • Author had a File in an Envato Bundle
  • Bought between 10 and 49 items
+3 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