From 9096c26f308299bd9546a3115c493ee3d3dbc683 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 27 Jan 2025 21:04:30 +0100 Subject: [PATCH] Fix class name --- dist/cms.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/dist/cms.js b/dist/cms.js index 7cf51c5..45fdeb8 100644 --- a/dist/cms.js +++ b/dist/cms.js @@ -13,26 +13,24 @@ function usesBlockTheme() { */ function getWordPressTheme() { const theme = { - theme: 'unknown', - parent_theme: '', + theme: '', + child_theme: '', }; try { const bodyClass = document.body.classList; const parentTheme = Array.from( bodyClass ).find( c => c.startsWith( 'wp-theme-' ) ); + + if ( parentTheme ) { + theme.theme = parentTheme.replace( 'wp-theme-', '' ); + } + const childTheme = Array.from( bodyClass ).find( c => c.startsWith( 'wp-child-theme-' ) ); if ( childTheme ) { - theme.theme = childTheme; - - // If there is a child theme, there should always be a parent theme. - if ( parentTheme ) { - theme.parent_theme = parentTheme; - } - } else if ( parentTheme ) { - // There is no child theme, only a parent theme. - theme.theme = parentTheme; + theme.child_theme = childTheme.replace( 'wp-child-theme-', '' ); } + } catch ( e ) {} return theme; }