Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* auto laod custom fonts */
- add_action(
- 'jeg_before_inline_dynamic_css',
- function () {
- $custom_fonts = get_theme_mod( 'jnews_additional_font', array() );
- if ( ! empty( $custom_fonts ) ) {
- $additional_fonts = '';
- foreach ( $custom_fonts as $font ) {
- $custom_variant = $font['font_weight'] . $font['font_style'];
- /* if selected font variant empty load all varint of custom font*/
- $font_src = array();
- if ( ! empty( $font['eot'] ) ) {
- $font_src[] = "url('" . wp_get_attachment_url( $font['eot'] ) . "#iefix') format('embedded-opentype')";
- }
- if ( ! empty( $font['woff'] ) ) {
- $font_src[] = "url('" . wp_get_attachment_url( $font['woff'] ) . "') format('woff')";
- }
- if ( ! empty( $font['ttf'] ) ) {
- $font_src[] = "url('" . wp_get_attachment_url( $font['ttf'] ) . "') format('truetype')";
- }
- if ( ! empty( $font['eot'] ) ) {
- $font_src[] = "url('" . wp_get_attachment_url( $font['svg'] ) . "') format('svg')";
- }
- $src = 'src: ' . implode( ',', $font_src ) . ' ;';
- $variants_src = " @font-face { font-family: '" . $font['font_name'] . "'; " . $src . " font-weight: {$font['font_weight']}; font-style: {$font['font_style']}; } ";
- $additional_fonts .= $variants_src;
- }
- echo '<style id="additional_fots" type="text/css" data-type="additional_fots">' . $additional_fonts . '</style>';
- }
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement