Advertisement
firoze

Update css dynamically

Jul 27th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. // Update css dynamically
  2. <?php
  3.  
  4. /** Write to options.css file **/
  5.  
  6. function css_generator(){
  7. ob_start();
  8. require_once( 'file.php' );
  9. file_put_contents( "options.css",ob_get_clean());
  10. }
  11. css_generator();
  12.  
  13.  
  14. // Object Oriented Method
  15. /* class dyNamic_css{
  16. public function css_generator(){
  17. ob_start();
  18. require_once( 'file.php' );
  19. file_put_contents( 'options.css',ob_get_clean());
  20. }
  21. }
  22. $output = new dyNamic_css;
  23. $output -> css_generator();
  24. */
  25.  
  26.  
  27.  
  28.  
  29. /*
  30. $ss_dir = get_stylesheet_directory(); // Shorten code, save 1 call
  31. ob_start(); // Capture all output (output buffering)
  32. require($ss_dir . '/library/css/dynamic.css.php'); // Generate CSS
  33. $css = ob_get_clean(); // Get generated CSS (output buffering)
  34. file_put_contents($ss_dir . '/library/css/static.css', $css, LOCK_EX); // Save it
  35. */
  36.  
  37. ?>
  38.  
  39.  
  40.  
  41. // usages in wordpress (use in framework or cmb2)
  42. function my_style_css(){
  43. ob_start();
  44. require_once( get_stylesheet_directory().'/css/filestyle.php' );
  45. file_put_contents( get_stylesheet_directory()."/css/options.css",ob_get_clean());
  46. }
  47. my_style_css();
  48.  
  49.  
  50. // OR use without any function method
  51. ob_start();
  52. require_once( get_stylesheet_directory().'/css/filestyle.php' );
  53. file_put_contents( get_stylesheet_directory()."/css/options.css",ob_get_clean());
  54.  
  55.  
  56.  
  57.  
  58. // Note:if break any file or any part of template then call always this code at the beneath of all codes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement