wp/wp-includes/fonts/class-wp-font-face-resolver.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    35 
    35 
    36 		return static::parse_settings( $settings );
    36 		return static::parse_settings( $settings );
    37 	}
    37 	}
    38 
    38 
    39 	/**
    39 	/**
       
    40 	 * Gets fonts defined in style variations.
       
    41 	 *
       
    42 	 * @since 6.7.0
       
    43 	 *
       
    44 	 * @return array Returns an array of font-families.
       
    45 	 */
       
    46 	public static function get_fonts_from_style_variations() {
       
    47 		$variations = WP_Theme_JSON_Resolver::get_style_variations();
       
    48 		$fonts      = array();
       
    49 
       
    50 		if ( empty( $variations ) ) {
       
    51 			return $fonts;
       
    52 		}
       
    53 
       
    54 		foreach ( $variations as $variation ) {
       
    55 			if ( ! empty( $variation['settings']['typography']['fontFamilies']['theme'] ) ) {
       
    56 				$fonts = array_merge( $fonts, $variation['settings']['typography']['fontFamilies']['theme'] );
       
    57 			}
       
    58 		}
       
    59 
       
    60 		$settings = array(
       
    61 			'typography' => array(
       
    62 				'fontFamilies' => array(
       
    63 					'theme' => $fonts,
       
    64 				),
       
    65 			),
       
    66 		);
       
    67 
       
    68 		return static::parse_settings( $settings );
       
    69 	}
       
    70 
       
    71 	/**
    40 	 * Parse theme.json settings to extract font definitions with variations grouped by font-family.
    72 	 * Parse theme.json settings to extract font definitions with variations grouped by font-family.
    41 	 *
    73 	 *
    42 	 * @since 6.4.0
    74 	 * @since 6.4.0
    43 	 *
    75 	 *
    44 	 * @param array $settings Font settings to parse.
    76 	 * @param array $settings Font settings to parse.