feat: add CHRNX shell and theme preference

This commit is contained in:
chrnx committed 2026-08-11 16:54:17 -05:00
1 parent aad237b211
commit f371db4cb5
18 files changed
+633 -16

No files matched your search

+7 -3
View File
@@ -7,8 +7,12 @@
/** Print the no-flash theme resolution before stylesheet links. */
function chrnx_print_theme_preference_bootstrap() {
?>
<script id="chrnx-theme-preference-bootstrap">(function(){var t=null,m;try{var s=localStorage.getItem('chrnx-theme');if(s==='light'||s==='dark'){t=s;}}catch(e){}if(!t){try{m=matchMedia('(prefers-color-scheme: dark)').matches;t=m?'dark':'light';}catch(e){t='dark';}}document.documentElement.dataset.theme=t;document.documentElement.style.colorScheme=t;}());</script>
<?php
$script = "(function(){var t=null,m;try{var s=localStorage.getItem('chrnx-theme');if(s==='light'||s==='dark'){t=s;}}catch(e){}if(!t){try{m=matchMedia('(prefers-color-scheme: dark)').matches;t=m?'dark':'light';}catch(e){t='dark';}}document.documentElement.dataset.theme=t;document.documentElement.style.colorScheme=t;document.documentElement.classList.add('chrnx-theme-enhanced');}());";
// wp_get_inline_script_tag applies WordPress's standard CSP attribute filter.
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Core escapes tag attributes and script is a fixed literal.
echo wp_get_inline_script_tag(
$script,
array( 'id' => 'chrnx-theme-preference-bootstrap' )
);
}
add_action( 'wp_head', 'chrnx_print_theme_preference_bootstrap', 0 );