• So I’m using WP Night Mode an otherwise fairly slick little plug-in that lets users switch the site to a dark theme, but many users report that it turns on and off unexpectedly. I suspect this is because the pages are getting cached in either mode at random, which in retrospect is kind of an obvious problem.

    So… any idea how I could fix this? Excluding Night Mode users from caching would be acceptable, if I could figure out how to do that. It sets a cookie, is there any relatively easy way to test for that?

    Or any other solution/suggestion would be greatly appreciated.

Viewing 1 replies (of 1 total)
  • Sa?a

    (@stodorovic)

    For testing, you could try to create simple PHP file and upload it into wp-content/plugins/wp-super-cache/plugins (I think that you need to uncheck option Don’t cache pages for known users). This file will be removed in update process, but I hope that we will fix some issues related to cookie and caching in next releases.

    <?php
    
    add_cacheaction( 'wp_cache_get_cookies_values', 'my_wp_night_mode_wpsc_cookies' );
    
    function my_wp_night_mode_wpsc_cookies( $string ) {
        global $super_cache_enabled;
    
        if ( ! empty( $_COOKIE['wpNightMode'] ) && $_COOKIE['wpNightMode'] === 'true' ) {
            $string             .= 'wp-night-mode-on' . ',';
            $super_cache_enabled = false; // Create only wp-cache file.
        }
    
        return $string;
    }
    

    One of good thing is ignoring ‘false’ value of cookie which isn’t possible with other solutions. If it works as should then I could try to help you to write better WPSC plugin.

    • This reply was modified 6 years, 1 month ago by Sa?a.
Viewing 1 replies (of 1 total)
  • The topic ‘WP Night Mode conflict (I think)’ is closed to new replies.