WP_Font_Face_Resolver::get_fonts_from_style_variations(): array

In this article

Gets fonts defined in style variations.

Return

array Returns an array of font-families.

Source

public static function get_fonts_from_style_variations() {
	$variations = WP_Theme_JSON_Resolver::get_style_variations();
	$fonts      = array();

	if ( empty( $variations ) ) {
		return $fonts;
	}

	foreach ( $variations as $variation ) {
		if ( ! empty( $variation['settings']['typography']['fontFamilies']['theme'] ) ) {
			$fonts = array_merge( $fonts, $variation['settings']['typography']['fontFamilies']['theme'] );
		}
	}

	$settings = array(
		'typography' => array(
			'fontFamilies' => array(
				'theme' => $fonts,
			),
		),
	);

	return static::parse_settings( $settings );
}

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.