Skip to content

Commit

Permalink
Fix class name
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Jan 27, 2025
1 parent 24e7111 commit 9096c26
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions dist/cms.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9096c26

Please sign in to comment.