15 lines
655 B
PHP
15 lines
655 B
PHP
<?php
|
|
/**
|
|
* Early, local-only theme preference bootstrap.
|
|
*
|
|
* @package CHRNX
|
|
*/
|
|
|
|
/** 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
|
|
}
|
|
add_action( 'wp_head', 'chrnx_print_theme_preference_bootstrap', 0 );
|