Creating a Dynamic CSS file from theme options

Community Forums Forums General Discussion Creating a Dynamic CSS file from theme options

This topic is: not resolved

This topic contains 1 reply, has 2 voices, and was last updated by  cehwitham 1 year, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #35827

    MarkODonnell
    Participant

    I am creating a child theme with some theme options. I want those theme options to generate a dynamic css file (style.php, not style.css). I want to generate that file whenever the theme options are updated using code that looks something like the following:

    ob_start(); // Capture all output (output buffering)
    require($ss_dir . ‘/dynamic.php’); // Generate CSS
    $css = ob_get_clean( ); // Get generated CSS (output buffering) file_put_contents($ss_dir . ‘/mstw-tr-style.css’, $css, LOCK_EX); // Save it

    Of course the dynamic.php will reference the theme options, so they will have to be stored and available.
    What’s the right hook to use (right after the options have been stored)?

    Thanks.

    http://
    #39058

    cehwitham
    Participant
    Post count: 396

    Would the WordPress theme customizer allow you to do what you need? It would certainly help with the options interface.

    http://wp.smashingmagazine.com/2013/03/05/the-wordpress-theme-customizer-a-developers-guide/

    Chris


    Twitter: cehwitham Web: cehwitham.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.