- Timestamp:
- 09/25/2023 09:27:51 PM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/fonts/class-wp-font-face-resolver.php
r56500 r56688 51 51 foreach ( $font_families as $definition ) { 52 52 53 // Skip if font-family "name" is not defined.54 if ( empty( $definition['name'] ) ) {55 continue;56 }57 58 53 // Skip if "fontFace" is not defined, meaning there are no variations. 59 54 if ( empty( $definition['fontFace'] ) ) { … … 61 56 } 62 57 63 $font_family = $definition['name']; 58 // Skip if "fontFamily" is not defined. 59 if ( empty( $definition['fontFamily'] ) ) { 60 continue; 61 } 62 63 $font_family_name = static::maybe_parse_name_from_comma_separated_list( $definition['fontFamily'] ); 64 65 // Skip if no font family is defined. 66 if ( empty( $font_family_name ) ) { 67 continue; 68 } 64 69 65 70 // Prepare the fonts array structure for this font-family. 66 if ( ! array_key_exists( $font_family , $fonts ) ) {67 $fonts[ $font_family ] = array();71 if ( ! array_key_exists( $font_family_name, $fonts ) ) { 72 $fonts[ $font_family_name ] = array(); 68 73 } 69 74 70 $fonts[ $font_family ] = static::convert_font_face_properties( $definition['fontFace'], $font_family);75 $fonts[ $font_family_name ] = static::convert_font_face_properties( $definition['fontFace'], $font_family_name ); 71 76 } 72 77 } 73 78 74 79 return $fonts; 80 } 81 82 /** 83 * Parse font-family name from comma-separated lists. 84 * 85 * If the given `fontFamily` is a comma-separated lists (example: "Inter, sans-serif" ), 86 * parse and return the fist font from the list. 87 * 88 * @since 6.4.0 89 * 90 * @param string $font_family Font family `fontFamily' to parse. 91 * @return string Font-family name. 92 */ 93 private static function maybe_parse_name_from_comma_separated_list( $font_family ) { 94 if ( str_contains( $font_family, ',' ) ) { 95 $font_family = explode( ',', $font_family )[0]; 96 } 97 98 return trim( $font_family, "\"'" ); 75 99 } 76 100
Note: See TracChangeset
for help on using the changeset viewer.