Skip to content

Commit

Permalink
Simplify server side
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed May 19, 2021
1 parent 25e0ffc commit 999fddf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,16 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) {

// Font Family.
if ( $has_font_family_support ) {
$has_font_family = isset( $block_attributes['style']['typography']['fontFamily'] );
$font_family = $block_attributes['style']['typography']['fontFamily'];
// Apply required class and style.
if ( $has_font_family ) {
$font_family = $block_attributes['style']['typography']['fontFamily'];
if ( isset( $font_family ) ) {
if ( strpos( $font_family, 'var:preset|font-family' ) !== false ) {
// Get the name from the string and add proper styles.
$index_to_splice = strrpos( $font_family, '|' ) + 1;
$font_family_name = substr( $font_family, $index_to_splice );
$styles[] = sprintf( 'font-family: var(--wp--preset--font-family--%s);', $font_family_name );
} else {
$styles[] = sprintf( 'font-family: %s;', $block_attributes['style']['typography']['fontFamily'] );
$styles[] = sprintf( 'font-family: %s;', $font_family );
}
}
}
Expand Down

0 comments on commit 999fddf

Please sign in to comment.