feat: add CHRNX shell and theme preference
This commit is contained in:
18 files changed
+633
-16
No files matched your search
@@ -15,5 +15,11 @@ function chrnx_enqueue_assets() {
|
||||
array(),
|
||||
CHRNX_VERSION
|
||||
);
|
||||
wp_enqueue_style(
|
||||
'chrnx-layout',
|
||||
get_theme_file_uri( 'assets/css/layout.css' ),
|
||||
array( 'chrnx-base' ),
|
||||
CHRNX_VERSION
|
||||
);
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'chrnx_enqueue_assets' );
|
||||
+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', 'theme-toggle' );
|
||||
$blocks = array( 'featured-stories', 'journal-stream', 'latest-podcast', 'podcast-meta', 'topic-hero', 'related-posts', 'subscribe-cta', 'theme-toggle', 'site-brand' );
|
||||
foreach ( $blocks as $block ) {
|
||||
$name = 'chrnx/' . $block;
|
||||
if ( WP_Block_Type_Registry::get_instance()->is_registered( $name ) ) {
|
||||
|
||||
+2
-1
@@ -13,7 +13,8 @@ function chrnx_setup() {
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
add_theme_support( 'responsive-embeds' );
|
||||
add_theme_support( 'editor-styles' );
|
||||
add_editor_style( 'assets/css/base.css' );
|
||||
add_editor_style( array( 'assets/css/base.css', 'assets/css/layout.css' ) );
|
||||
remove_action( 'wp_footer', 'the_block_template_skip_link' );
|
||||
|
||||
add_image_size( 'chrnx-card', 720, 480, true );
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
Reference in new issue
Block a user