| 开发者 |
jtzl
yoren |
|---|---|
| 更新时间 | 2026年3月10日 20:11 |
| PHP版本: | 8.2 及以上 |
| WordPress版本: | 6.9 |
| 版权: | GPL-2.0-or-later |
| 版权网址: | 版权信息 |
prefers-color-scheme: dark media queryprefers-color-scheme media query to detect when a visitor's operating system is set to dark mode. When detected, dark mode styles are automatically applied without any JavaScript or server-side processing.
Technical Features:
jtzl_dark_mode_enabled - Enable/disable dark mode on specific pagesjtzl_dark_mode_css_variables - Customize dark mode colorsjtzl_dark_mode_custom_css - Add custom CSS rulesjtzls-dark-mode folder to the /wp-content/plugins/ directoryNo. JTZL's Dark Mode works automatically without any settings or configuration.
The plugin uses the CSS prefers-color-scheme: dark media query, which detects your operating system's color scheme preference. This is a privacy-respecting, client-side-only approach.
No. The plugin includes media preservation rules that ensure images, videos, iframes, and embedded content display without color distortion.
Yes. Use the jtzl_dark_mode_enabled filter hook:
add_filter( 'jtzl_dark_mode_enabled', function( $enabled ) { if ( is_page( 'landing-page' ) ) { return false; } return $enabled; } );
Yes. Use the jtzl_dark_mode_css_variables filter hook to override default CSS variables:
add_filter( 'jtzl_dark_mode_css_variables', function( $variables ) { $variables['--id-bg-primary'] = '#0d1117'; $variables['--id-text-primary'] = '#f0f0f0'; return $variables; } );
Available CSS variables:
--id-bg-primary - Primary background color--id-bg-secondary - Secondary background color--id-text-primary - Primary text color--id-text-secondary - Secondary text color--id-border-color - Border color--id-link-color - Link color--id-link-hover - Link hover color
Note: CSS variables only apply to Block themes. Classic themes use filter inversion.Yes. JTZL's Dark Mode uses different styling strategies optimized for each theme type:
No. Dark mode styling is applied only to the public-facing frontend of your site.
Yes. Use the jtzl_dark_mode_custom_css filter hook:
add_filter( 'jtzl_dark_mode_custom_css', function( $css ) { return $css . '@media (prefers-color-scheme: dark) { .my-element { color: #fff; } }'; } );
Yes. Launch a live preview in WordPress Playground: https://playground.wordpress.net/?blueprint-url=https://wordpress.org/plugins/wp-json/plugins/v1/plugin/jtzls-dark-mode/blueprint.json