feat: add CHRNX theme preference and marks
This commit is contained in:
11 files changed
+469
-3
No files matched your search
+1
-1
@@ -74,7 +74,7 @@ function chrnx_get_editorial_card_markup( $post_id, $heading_level = 3, $class_n
|
||||
|
||||
/** Register all block metadata directories that exist. */
|
||||
function chrnx_register_editorial_blocks() {
|
||||
$blocks = array( 'featured-stories', 'journal-stream', 'latest-podcast', 'podcast-meta', 'topic-hero', 'related-posts', 'subscribe-cta' );
|
||||
$blocks = array( 'featured-stories', 'journal-stream', 'latest-podcast', 'podcast-meta', 'topic-hero', 'related-posts', 'subscribe-cta', 'theme-toggle' );
|
||||
foreach ( $blocks as $block ) {
|
||||
$name = 'chrnx/' . $block;
|
||||
if ( WP_Block_Type_Registry::get_instance()->is_registered( $name ) ) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?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 );
|
||||
Reference in new issue
Block a user