=== Datoden Dark Mode ===
Contributors: datoden
Tags: dark mode, night mode, light mode, accessibility, color scheme
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 3.0.19
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Dark and light mode for the whole website with Datoden's own engine – nothing is loaded from other servers.

== Description ==

In the WordPress admin the plugin is shown as "DT-darkmode" in the DT-addons menu (Datoden's menu).

DT-darkmode gives your visitors a dark mode that works on any theme.

* A round button lets visitors choose Follow system, Light mode or Dark mode. The choice is remembered and applied before the page is painted, so it never flashes.
* The engine reads your theme's stylesheets and writes a dark version of them – hover states, media queries and CSS variables included. Inline colours and small dark icons are converted too.
* Brand colours such as coloured buttons are kept. Images and videos are never changed.
* Everything runs from the plugin itself: no external requests, no tracking.
* Settings with a live preview: default mode, button on/off and position.
* The same button in the WordPress admin, so the admin can be dark too.
* The button's texts are ready in ten languages and follow the visitor's language.

= Pro add-on =

In the separate paid add-on Datoden Dark Mode Pro (from Datoden, not part of this plugin): dark mode on the login page, a contrast report, menu items that switch the mode, an accent colour for the button and your own texts on the button per language.

= Free Datoden account (optional) =
Everything in the plugin works without an account. Connect the website to a free Datoden account and you also get website monitoring: Datoden checks your website every five minutes and emails you right away if it goes down, and before the SSL certificate or the domain expires. All your connected websites are shown in one place in Datoden, and Datoden's apps (Rapport, Schema, PDF, Bild, Font and Vektor) are included. Nothing is sent to Datoden until you click Connect; after that the website sends its address and the names and versions of its DT plugins once a day. You can disconnect at any time. See External services below for exactly what is sent.

== Frequently Asked Questions ==

= Can I keep part of the page as it is? =
Yes. Add the attribute `data-dt-dark-ignore` to the element.

= I use a cache plugin =
Clear the cache after changing the settings.

== Screenshots ==

1. A website in light mode with the light/dark button in the corner.
2. The same website in dark mode – brand colours and images are kept.
3. Dark mode on a phone.

== External services ==

This plugin can connect to Datoden (https://datoden.com), a service run by Responsit AB, Sweden. The connection is optional – everything in the plugin works without it. Nothing is sent to Datoden until an administrator clicks "Start DT-website-guard" (or "Connect") in the WordPress admin and approves the connection on datoden.se or datoden.com. You can disconnect at any time with "Disconnect" (or by turning DT-website-guard off) on the DT-website-guard page; then nothing more is sent.

What is sent to Datoden, and when (only while the website is connected, except the connection itself):

* When you connect: the website address, the administrator's language (Swedish or English), the WordPress address that Datoden returns to and a random check value. After you approve on Datoden, the website sends the one-time code it got back, together with the website address and the language, and receives a website key that is stored in your database.
* Once a day (WordPress cron), and when an administrator opens a DT plugin page and the last contact is more than six hours old: the website key, the language, and the folder names, versions and active state of the installed Datoden plugins (for example datoden-cookie-consent). The answer can contain short messages from Datoden and updated wording for the DT plugins' texts, which are shown on the plugins' pages.
* When an administrator opens the DT-website-guard page or a DT plugin page (at most every five minutes), or clicks "Check again": the website key, to get the latest result of Datoden's monitoring (up or down, response time, and the expiry dates of the SSL certificate and the domain). "Check again" also asks Datoden to check the website once more.
* When the DT-website-guard page is shown and the DT-website-guard plugin is installed: the list of Datoden's plugins and their versions is fetched from datoden.se, at most every six hours. No data about the website is sent.
* When you click "My websites": the website key, the language and the email address of the logged-in WordPress user, so that Datoden can sign you in directly if it is the same address as your Datoden account.
* When you save, use or delete a settings profile: the website key, and when saving the settings of DT-cookie and DT-darkmode (no personal data; website-specific values such as the logo and the privacy page are left out). They are stored in or read from your Datoden account.
* When you disconnect: the website key, so that Datoden can remove it.
* While connected, Datoden visits the public website every five minutes (like any visitor) to check that it is up, reads its SSL certificate and looks up the domain's public registration data to find when it expires. The plugin shows the dates as Datoden reports them; the website does not contact any other service for this.

Datoden terms: https://datoden.com/terms/
Datoden privacy policy: https://datoden.com/privacy-policy/

== Source code ==

Everything in this plugin is the original, human-readable source code. The PHP, JavaScript and CSS files are written by hand and are neither minified nor generated by a build tool, so there is no build step: the files in the plugin folder are the source and can be read and edited directly.

== Changelog ==

= 3.0.19 =
WordPress.org review: activation never deactivates the plugin itself; long lines in dt-colormode.js split up; the return from Datoden (Connect) is also checked with a nonce (core 3.0.8); the readme describes the source code.

= 3.0.18 =
Long pages keep the same background all the way down in dark mode. When the page has its own background on body (such as the admin area's light grey), no base colour is set on html – it made the background change shade where body ends.

= 3.0.17 =
Cut-out product images are no longer inverted in dark mode: only single-coloured dark icons and logos are turned light. A dark sofa on a transparent background used to turn white on grey.

= 3.0.16 =
Dark mode no longer flashes light on page changes: the stored dark stylesheet is kept last in the head until the page is ready – theme colours further down in <head> (e.g. the header background) used to override it, so the header showed white for a moment after every click.

= 3.0.15 =
Datoden-core 3.0.7: the plugins' settings are checked with a single database query when the page loads – missing or non-autoloaded settings used to cost one query each on every page.

= 3.0.14 =
* Dark icons are detected reliably even when a browser extension protects the canvas; icon buttons keep a dark background.

= 3.0.13 =
* Dark SVG icons without width/height are detected in Firefox too, and when the site is viewed with or without www.

= 3.0.12 =
* Icon buttons no longer flash white while the page loads in dark mode.

= 3.0.11 =
* Icons with their own background colour (e.g. a round button behind plus/minus) stay visible in dark mode.

= 3.0.10 =
* Dark icons used as background images (e.g. Collapse-O-Matic plus/minus) are found even when they appear after the page has loaded.

= 3.0.9 =
* Review fixes in all plugins: prefixed JavaScript names, the WordPress 6.9 template enhancement output buffer (older WordPress: the buffer is closed explicitly), cache paths from content_url(). Dark Mode: block theme palettes are converted per use. SVG Support: steps back while the SVG Support plugin is active. Code Snippets: the WPCode switch button is shown for all imported snippets.

= 3.0.8 =
* Datoden-core 3.0.5: the plugin icon shows its symbol at full size, cut by the corner with the Datoden logo.

= 3.0.7 =
* Datoden-core 3.0.4: plugin icons without the white background – the cut corner is transparent and the Datoden logo uses the icon's light colour.

= 3.0.6 =
* Datoden-core 3.0.3: new plugin icon design – a cut white corner with the Datoden logo.

= 3.0.5 =
* Datoden-core 3.0.2: the plugin's own icon (the same as on WordPress.org) is shown in the DT-addons overview and in the header of the plugin's page.

= 3.0.4 =
* Datoden-core 3.0.1: the header on the plugin's page shows the plugin's name as on WordPress.org.

= 3.0.3 =
* Dark mode is recalculated when an existing style element on the page gets new content, for example a theme's colours in the Customizer's live preview.

= 3.0.2 =
* Rules that mention [data-dt-dark-keep] are not recoloured, so previews in other DT plugins show their real colours.

= 3.0.1 =
* Two WordPress installations on the same domain (e.g. / and /shop/) no longer share the dark style cached in the browser.

= 3.0.0 =
* New name on WordPress.org: Datoden Dark Mode (shown as DT-darkmode in the DT-addons menu). The free plugin contains no locked Pro features – they are only in the separate Datoden Dark Mode Pro. Websites with the earlier version are moved to the new folder automatically; settings are kept.

= 2.0.2 =
* Plugin Check: redirects to Datoden use wp_safe_redirect, and the descriptions on the Datoden plugins overview are translated with WordPress' own function. Datoden-core 2.0.1.

= 2.0.1 =
* Firefox with Dark Reader: the page flickered and Light mode stayed dark. Dark Reader is now turned off on pages where DT-darkmode is on (darkreader-lock), its styles are not converted, and the dark stylesheet is only rewritten when something changed.

= 2.0.0 =
* New prefix datoden_ instead of dt_ (WordPress.org). Settings and data are moved automatically on the first load; the old [dt_…] shortcodes, hooks and REST routes keep working. Works together with older DT plugins until they are updated. Datoden-core 2.0.0.

= 1.11.11 =
* Ready for WordPress.org: Plugin Check rules (sanitising, nonces, WordPress file functions), no inline scripts in admin pages, DT-core 1.17.22.

= 1.11.10 =
* DT-core 1.17.21: shared core cleaned up (unused code removed) – the same core in every plugin, no change in behaviour.

= 1.11.9 =
* Cleanup: unused code removed – no change in behaviour.

= 1.11.8 =
* DT-core 1.17.12: the menu heading is called DT-addons and the overview section Datoden plugins.

= 1.11.7 =
* DT-core 1.17.11: the Pro features require a licence – the website must be connected to Datoden and have a purchased licence or be activated by Datoden. Without a licence the base plugin runs without Pro, with a notice saying why (three days to connect after installing or updating).

= 1.11.6 =
* DT-core 1.17.10: DT-website-guard includes itself in the list sent to Datoden – Control the website, Health and Updates show again in My websites, and DT-website-guard gets its updates from Datoden.

= 1.11.5 =
* DT-core 1.17.9: the menu heading is called Datoden Addons (DT-datoden-addons wrapped onto two lines).

= 1.11.4 =
* DT-core 1.17.8: the menu heading is called DT-datoden-addons (without the Pro badge); the first row in the menu and the overview are still called DT-website-guard.

= 1.11.3 =
* DT-core 1.17.7: the DT-website-guard overview shows every DT plugin – the ones that are not installed with Install (downloaded from Datoden) and Read more; deactivated ones with Activate.

= 1.11.2 =
* DT-addons is now called DT-website-guard (the menu, the overview, the plugins list and the texts in every DT plugin). The folder and the settings stay the same (dt-addons), so updates and everything saved work as before. DT-core 1.17.6.

= 1.11.1 =
* DT-core 1.17.5: the card about what Pro adds is shown at the top of the sidebar (only without Pro) – in every DT plugin.

= 1.11.0 =
* Free and Pro in one: Pro is now an add-on to DT-darkmode instead of a separate version that replaces it. DT-darkmode (the base plugin, free on WordPress.org) stays installed and active, keeps the settings and is updated from there; DT-darkmode Pro adds the Pro features and requires DT-darkmode. Upgrade, go back or remove Pro – settings and data stay. If DT-darkmode is newer than Pro, DT-darkmode runs without the Pro features until Pro has been updated. DT-core 1.17.0.

= 1.10.1 =
* Fix: critical error when DT-darkmode Pro was installed while an older free version was active. Pro now turns the free version off immediately and starts from the next request.

= 1.10.0 =
* Free and Pro: built as a free version (WordPress.org) and DT-darkmode Pro (Datoden). Pro takes over the free version and keeps the settings, is updated from Datoden while connected and shows Pro in the header. Nothing stops working when switching either way. DT-core 1.16.0.

= 1.9.33 =
* DT-core 1.15.1: the header (logo, Datoden badge, buttons, language switch, Saved) and the Made by Datoden line are rendered by the core – the plugin only provides its name, version, description and any tabs. The collapse/expand arrow always sits at the far right of the card.

= 1.9.32 =
* DT-core 1.14.0: the header, the DT-addons menu and everything else shared (dt-hub.php, dt-autosave.js, dt-admin.css and Datoden images) live in the dt-core/ folder. Of all active DT plugins only the newest copy is used – updating one plugin with a newer core gives every plugin the new header, and all pages load the same files (cached once by the browser).

= 1.9.31 =
* Shared header script: in DT-addons, Messages go below Install or update in the sidebar.

= 1.9.30 =
* The tab row sits at the top of the main column – above the main cards only, so the sidebar starts at the top beside it.

= 1.9.29 =
* Tabs (e.g. Languages | Menus in DT-language) are a full-width row right below the header, above the cards – no longer small inside the header, so they are not missed.

= 1.9.28 =
* Every card – also in the main column and the cards above it – collapses and expands with a click on its heading. The arrow sits right after the heading, so switches and buttons on the right stay visible when the card is collapsed.

= 1.9.27 =
* Sidebar cards collapse and expand with a click on their heading – remembered per card. Collapsed Messages shows the count. In DT-addons the Datoden account is at the top of the sidebar (DT-hub 1.13.2).

= 1.9.26 =
* Closed messages stay closed after reloading the page.

= 1.9.25 =
* Messages are shown in the sidebar (Messages card) instead of the header.

= 1.9.24 =
* Dark mode: WordPress' dark blue buttons and links in the admin now use a light Datoden blue that is easy to read.

= 1.9.23 =
* The first item under DT-addons in the menu is called DT-addons instead of Overview.

= 1.9.22 =
* No more light flash between admin pages in dark mode. The Datoden menu is now called DT-addons; the overview has a larger DT-website-guard panel.

= 1.9.21 =
* The login page follows the same light/dark mode as the admin, with the mode button.

= 1.9.20 =
* Undo/Redo tooltips say what will be undone or redone. Undo, Redo and Saved are always in the same place, greyed out when there is nothing to do.

= 1.9.19 =
* Header: subtle dividers between the groups of controls.

= 1.9.18 =
* Undo now works everywhere, also right after a change, for added/removed rows, the form builder and the code editor.

= 1.9.17 =
* Undo / Redo in the header of every DT plugin. The save status keeps its width; other messages are shown on top so nothing moves.

= 1.9.16 =
* Header rearranged: version next to the plugin name, buttons top right, Saved after the language switch, the Datoden logo links to Datoden's apps.

= 1.9.15 =
* The Datoden overview page has the same header as the plugins.

= 1.9.14 =
* Dark mode: buttons, links and text in Datoden blue on DT pages are now light enough to read.

= 1.9.13 =
* Dark mode: the header shows the light Datoden logo (datoden-logo-darkmode.svg).

= 1.9.12 =
* The sidebar toggle moved into the header; when hidden the content uses the full width. The collapsed header shows the Datoden logo.

= 1.9.11 =
* The sidebar now lines up with the content (no extra gap at the top).

= 1.9.10 =
* The sidebar toggle sits in the top right corner with a sidebar icon.

= 1.9.9 =
* Header buttons: keep the header at the top while scrolling (pin) and collapse it so only Saved and the language switch show. The sidebar can be collapsed to a small button. The language switch is greyed out on pages without texts to translate.

= 1.9.8 =
* The settings page uses the same colours as the other DT plugins: the button colour only shows in the preview.

= 1.9.7 =
* The plugin header now stays at the top when you scroll. Saved status and the SV | EN language switch moved from the admin bar into the header, below the badges.

= 1.9.6 =
* Unified names: the plugin is now called DT-darkmode - datoden (lowercase after DT, like all DT plugins). The folder, settings and shortcodes are unchanged.

= 1.9.5 =
* Saved in the admin bar no longer gets a different background on hover.

= 1.9.4 =
* Saved / Saving… is shown in the admin bar at the top, to the left of the SV | EN language switch (also on mobile) – no longer in the plugin's page header.

= 1.9.3 =
* Messages in the page header: WordPress and plugin notices, messages from Datoden and the Datoden account row (DT-website-guard, Datoden apps) now sit in the page header, to the left of Saved, instead of pushing the page down. Long messages show two lines – click for the full text.

= 1.9.2 =
* Autosave: the settings are saved as soon as something changes – the Save button is removed. The status (Saved / Saving… / Could not save) is shown in the page header, as in DT-slideshow.

= 1.9.1 =
* The fields with per-language texts are tagged, so that Text fields in the admin bar (DT-language 1.3.0) can highlight them.

= 1.9.0 =
* The button's texts (Follow system, Light mode, Dark mode and the button's name for screen readers) can be changed per language under Texts on the button. Ready-made texts for ten languages. With DT-language the languages follow DT-language's list – a new language appears here at once – and you switch language with SV | EN in the admin bar.

= 1.8.8 =
* The button's labels are Swedish only on Swedish pages; every other language (for example via DT-language) gets English instead of Swedish.

= 1.8.7 =
* Colour pickers are never darkened: the WordPress colour picker (Iris, in the Customizer and on settings pages), the block editor colour picker, colour swatches and input type=color always show real colours.

= 1.8.6 =
* The text colour on accent colours (for example --dtss-accent-ink) is kept in dark mode, so a yellow button keeps its dark text.

= 1.8.5 =
* Style sheets written for dark mode can be marked with data-dt-dark-ready and are left as they are.

= 1.8.4 =
* Accent background variables (e.g. --signal-hover-bg) also keep their exact shade, so hovered buttons match their border.

= 1.8.3 =
* Brand and accent colours (custom properties named accent, brand, signal, primary or logo) keep their exact shade in dark mode.

= 1.8.2 =
* Dark mode in the block editor: toolbar and sidebar buttons are visible.

= 1.8.1 =
* Dark mode in the admin: selected tiles and other highlighted boxes on Datoden pages are dark too.

= 1.8.0 =
* The mode switcher (Follow system, Light, Dark) in the WordPress admin too – same engine and same choice as on the website. Can be turned off.

= 1.7.6 =
* Contrast report: says that it finds common contrast problems but is not a full accessibility review.

= 1.7.5 =
* Custom accent colour: the colour picker opens again.

= 1.7.4 =
* Contrast report styles are loaded the WordPress way. Activation no longer changes other plugins' settings or deactivates other dark mode plugins.

= 1.7.3 =
* Settings profiles with a free Datoden account: save the settings and use them on your other websites.

= 1.7.2 =
* Clean-up on uninstall, readme with External services and screenshots.

= 1.7.1 =
* Contrast report: measures the background where the text is actually shown, skips hidden text and text on images, and waits for lazy-loaded images.

= 1.7.0 =
* Contrast report: checks that all text on a page is easy to read in light and dark mode (WCAG 2.1). Runs in your browser.

= 1.6.8 =
* Shared Datoden module updated.

= 1.6.7 =
* Messages from Datoden are shown at the top when the website is connected, and can be closed.

= 1.6.6 =
* Website monitoring as an on/off switch at the top of the Datoden overview.

= 1.6.5 =
* Website monitoring explained in plain words: what you get, three steps to start, and a "Start Website monitoring – free" button.

= 1.6.4 =
* A cleaner Datoden overview: the DT plugins as tiles and a tidier account card.

= 1.6.3 =
* The Datoden overview lists the DT plugins as cards.

= 1.6.2 =
* My websites opens your Datoden account directly through a secure one-time link when it is safe; otherwise you sign in and land on the right page.

= 1.6.1 =
* Shows "Connected to Datoden" next to the version and a shortcut to My websites in Datoden when the website is connected.

= 1.6.0 =
* DT names in code and files: the menu classes are dt-colormode-toggle/-dark/-light/-system and the attribute is data-dt-dark-ignore. The old dd- names still work.

= 1.5.7 =
* Small text change in the Datoden overview.

= 1.5.6 =
* The menu icon updates right away after an update.

= 1.5.5 =
* Menu icon: the Datoden "d".

= 1.5.4 =
* Simpler menu icon (the Datoden favicon).

= 1.5.3 =
* Datoden symbol as the menu icon.

= 1.5.2 =
* The monitoring status updates sooner after connecting.

= 1.5.1 =
* The connect button links straight to Datoden.

= 1.5.0 =
* Free website monitoring with a Datoden account: an email right away if the website goes down, and before the SSL certificate or domain expires.

= 1.4.2 =
* In English the connect button and links go to datoden.com.

= 1.4.1 =
* The connect button stays when the account box is closed.

= 1.4.0 =
* Optional free Datoden account: connect or disconnect under Datoden in the admin menu.

= 1.3.0 =
* Drag and drop installation moved to its own plugin, DT-Drop. DT-darkmode only handles dark mode.

= 1.2.0 =
* Drag and drop everywhere: logged in as an administrator you can drop a plugin or theme ZIP anywhere on the website or in the admin to install or update it.

= 1.1.0 =
* New "Datoden" menu with an overview of installed DT plugins and a drag and drop area to install or update them.
* The DT-darkmode settings moved to Datoden → DT-darkmode.

= 1.0.1 =
* Installing on a site that already runs the Datoden colour mode code line (WPCode) takes over its settings and removes the line; Darkify is deactivated.
* Common cache plugins are cleared automatically on save.

= 1.0.0 =
* First version.

== Upgrade Notice ==

= 2.0.0 =
Install all DT plugins together; settings are moved automatically.
