Automattic\WooCommerce\EmailEditor\Engine
Site_Style_Sync_Controller::get_email_safe_fonts
Get email-safe fonts
Method of the class: Site_Style_Sync_Controller{}
No Hooks.
Returns
Array. Email-safe fonts.
Usage
$Site_Style_Sync_Controller = new Site_Style_Sync_Controller(); $Site_Style_Sync_Controller->get_email_safe_fonts(): array;
Site_Style_Sync_Controller::get_email_safe_fonts() Site Style Sync Controller::get email safe fonts code WC 10.5.0
public function get_email_safe_fonts(): array {
if ( empty( $this->email_safe_fonts ) ) {
/**
* Pull email-safe fonts from theme.json (src/Engine/theme.json).
*
* @var array{settings?: array{typography?: array{fontFamilies?: array<array{name: string, slug: string, fontFamily: string}>}}} $theme_data
*/
$theme_data = (array) json_decode( (string) file_get_contents( __DIR__ . '/theme.json' ), true );
$font_families = $theme_data['settings']['typography']['fontFamilies'] ?? array();
if ( ! empty( $font_families ) ) {
foreach ( $font_families as $font_family ) {
$this->email_safe_fonts[ strtolower( $font_family['slug'] ) ] = $font_family['fontFamily'];
}
}
}
return $this->email_safe_fonts;
}