Skip to content

Commit 425ff7b

Browse files
use font map lookup instead of ucwords conversion to ensure slug-to-name consistency and fix case-sensitive Google font detection
1 parent 751a173 commit 425ff7b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

functions.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,15 @@ function memberlite_get_font( $font_type, $nicename = NULL ) {
8383
// Get the selected fonts from theme options.
8484
$r = get_theme_mod( 'memberlite_' . $font_type, $memberlite_defaults[ 'memberlite_' . $font_type ] );
8585

86-
// If we're returning the font name, convert the slug to a human-readable name.
86+
// If we're returning the font name, look up the exact display name from the font list.
8787
if ( ! empty( $nicename ) ) {
88-
$r = ucwords( str_replace( '-', ' ', $r ) );
88+
$lower_slug = strtolower( $r );
89+
foreach ( Memberlite_Customize::get_all_fonts() as $slug => $name ) {
90+
if ( strtolower( $slug ) === $lower_slug ) {
91+
$r = $name;
92+
break;
93+
}
94+
}
8995
}
9096

9197
return $r;
@@ -100,7 +106,7 @@ function memberlite_load_local_webfonts() {
100106
$body_font = strtolower( memberlite_get_font( 'body_font' ) );
101107

102108
// If it's not a Google font, ignore.
103-
$google_fonts = array_keys( Memberlite_Customize::get_google_fonts() );
109+
$google_fonts = array_map( 'strtolower', array_keys( Memberlite_Customize::get_google_fonts() ) );
104110
if ( ! in_array( $header_font, $google_fonts ) && ! in_array( $body_font, $google_fonts ) ) {
105111
return;
106112
}

0 commit comments

Comments
 (0)