• Hi I am using this code but even with jquery it won’t live update the css, even on publish. I am using a dynamic css stylesheet rather than another bloat of css inline as WordPress adds its own as well does any plugin and theme.

    add_action('parse_request', 'parse_dynamic_css_request');
    function parse_dynamic_css_request($wp) {
    $ss_dir = get_stylesheet_directory(); // Shorten code, save 1 call
    ob_start(); // Capture all output (output buffering)
    require($ss_dir . '/designer.css.php'); // Generate CSS
    $css = ob_get_clean(); // Get generated CSS (output buffering)
    file_put_contents($ss_dir . '/designer.css', $css, LOCK_EX); // Save it
    }
    
    function designer_customize_register( $wp_customize ) {

    I am using customizer functions to create e.g. colors and it all works well and updates the designer.css stylesheet that I have enqueued.
    Is it possible to see live changes? It shows up if I update and clear the browser cache but that is not the aim I want it to be dynamic or is this only going to work using inline css?
    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    For the customizer preview to reflect current customizer changes, you need to use Selective Refresh. That’s really all I know about this topic, I don’t have direct experience using it. Hopefully it’s enough to get you started in the right direction.

    Thread Starter nanny7

    (@nanny7)

    thanks I am using transport refresh if that is what you mean. That still doesn’t work with the browser cache stopping live preview unfortunately.

    Moderator bcworkz

    (@bcworkz)

    Transport refresh is not the same thing.

    settings edited in the Customizer get sent to the preview via the refresh transport by default, meaning that in order for a setting change to be applied, the entire preview has to reload: this refresh can be very slow and is anything but “live”.

    …and can be impacted by browser caching.

    Selective refresh uses JS to dynamically update portions of the preview’s DOM, so caching is not a factor. More info in addition to what I linked previously.

    Thread Starter nanny7

    (@nanny7)

    Thank I will take a look ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘customizer dynamic stylesheet not showing live edits’ is closed to new replies.