File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -13,26 +13,24 @@ function usesBlockTheme() {
1313 */
1414function getWordPressTheme ( ) {
1515 const theme = {
16- theme : 'unknown ' ,
17- parent_theme : '' ,
16+ theme : '' ,
17+ child_theme : '' ,
1818 } ;
1919 try {
2020 const bodyClass = document . body . classList ;
2121
2222 const parentTheme = Array . from ( bodyClass ) . find ( c => c . startsWith ( 'wp-theme-' ) ) ;
23+
24+ if ( parentTheme ) {
25+ theme . theme = parentTheme . replace ( 'wp-theme-' , '' ) ;
26+ }
27+
2328 const childTheme = Array . from ( bodyClass ) . find ( c => c . startsWith ( 'wp-child-theme-' ) ) ;
2429
2530 if ( childTheme ) {
26- theme . theme = childTheme ;
27-
28- // If there is a child theme, there should always be a parent theme.
29- if ( parentTheme ) {
30- theme . parent_theme = parentTheme ;
31- }
32- } else if ( parentTheme ) {
33- // There is no child theme, only a parent theme.
34- theme . theme = parentTheme ;
31+ theme . child_theme = childTheme . replace ( 'wp-child-theme-' , '' ) ;
3532 }
33+
3634 } catch ( e ) { }
3735 return theme ;
3836}
You can’t perform that action at this time.
0 commit comments