ianakarina

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: Add “&display: swap” to the google fonts request #99953
    ianakarina
    Participant

    Well, I managed to do it by myself, even though I’m not a programmer. It would be nice to add it in future updates.
    Thanks in advance!

    // Enqueue google fonts with subsets separately
    	foreach( $gfonts as $i => $gfont ):
    		if ( strpos( $gfont, "&" ) === false):
    		   // do nothing
    		else:
    			wp_enqueue_style( 'fluida-googlefont' . $i, '//fonts.googleapis.com/css?display=swap&family=' . $gfont, null, _CRYOUT_THEME_VERSION );
    			unset( $gfonts[$i] );
    			unset( $roots[$i] );
    		endif;
    	endforeach;
    
    	// Merged google fonts
    	if ( count( $gfonts ) > 0 ):
    		wp_enqueue_style( 'fluida-googlefonts', '//fonts.googleapis.com/css?display=swap&family=' . implode( "|" , array_unique( array_merge( $roots, $gfonts ) ) ), null, _CRYOUT_THEME_VERSION );
    	endif;
Viewing 1 post (of 1 total)