Dark Mode Fixed

Or at least I hope so. Pretty sure.

The important part: Dark Mode should now consistently stay on (or off) between pages, and between visits (ON setting remembered for 1 month). I’ve removed the “Dark mode quick access” thing at the top of the page, because it was a little bit ugly, and shouldn’t be needed now that the setting stays set.

Technical details: Feel free to skip if this doesn’t interest you.

I’m using WP Night Mode to add that feature, but by default, another plugin, WP Super Cache doesn’t know how to handle it. This was the source of all the problems. However WP Super Cache does have a built in feature for excluding logged-in users. So taking advice from someone who reported a similar issue, I edited WP Night Mode so that its cookie is named “wordpress_logged_in_DarkMode”. This fools WP Super Cache into thinking the user is logged in, so they are excluded form the cache. This is a hack, obviously, but it seems to be working. There’s supposed to a better way to do this so that Dark Mode users would get their own separate cache, but frankly I don’t know by way around WordPress well enough to understand how to get that working. So this will have to do. It’s not perfect, it does mean Dark Mode users will experience slightly slower page loads, but for now at least it I’m happy to have it not be completely broken.

New poll, if you’d like to let me know how it’s working.

Loading Likes...

3 Replies to “Dark Mode Fixed”

  1. So far, so good, on a very quick tryout it appeared to follow me across the site (new), and hasn’t come back on (yet) since I turned it back off, but I’m not answering the poll to say it’s behaving till it’s stayed off for about a week.

    • Hmm, I wouldn’t have throught that was necessary, since the cookie has a new name now. But if anyone else is still having trouble that would be the first thing to try I guess.

Leave a Reply

Your email address will not be published. Required fields are marked *

Characters: 0
0

DMCA / Report Abuse