Last active
April 1, 2025 22:23
-
-
Save brianleejackson/91246131b4d7e6732073d380c3536de0 to your computer and use it in GitHub Desktop.
Disable Inter variable font in WooCommerce https://stackoverflow.com/a/79110690
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'wp_theme_json_data_theme', 'disable_inter_font', 100 ); | |
function disable_inter_font( $theme_json ) { | |
$theme_data = $theme_json->get_data(); | |
$font_data = $theme_data['settings']['typography']['fontFamilies']['theme'] ?? array(); | |
// The font name to be removed | |
$font_name = 'Inter'; | |
// Check if 'Inter' font exists | |
foreach ( $font_data as $font_key => $font ) { | |
if ( isset( $font['name'] ) && $font['name'] === $font_name ) { | |
// Remove the font | |
unset($font_data[$font_key]); | |
// Update font data | |
$theme_json->update_with( array( | |
'version' => 1, | |
'settings' => array( | |
'typography' => array( | |
'fontFamilies' => array( | |
'theme' => $font_data, | |
), | |
), | |
), | |
) ); | |
break; | |
} | |
} | |
return $theme_json; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment