packages/kirki-framework/module-webfonts/src/Embed.php
public function the_css() {
		foreach ( $this->fonts_to_load as $font ) {
			$family  = str_replace( ' ', '+', trim( $font['family'] ) );
			$weights = join( ',', $font['weights'] );
			$url     = "https://fonts.googleapis.com/css?family={$family}:{$weights}&subset=cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai";

			$transient_id = 'kirki_gfonts_' . md5( $url );
			$contents     = get_site_transient( $transient_id );
			/**
			 * Note to code reviewers:
			 * There's no need to check nonces or anything else, this is a simple true/false evaluation.
			 */
			if ( ! empty( $_GET['action'] ) && 'kirki-reset-cache' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
				$contents = false;
			}
			if ( ! $contents ) {

				// Get the contents of the remote URL.
				$contents = Helper::get_remote_url_contents(
					$url,
					[
						'headers' => [
							/**
							 * Set user-agent to firefox so that we get woff files.
							 * If we want woff2, use this instead: 'Mozilla/5.0 (X11; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0'
							 */
							'user-agent' => 'Mozilla/5.0 (X11; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0',
						],
					]
				);

				/**
				 * Allow filtering the font-display property.
				 */
				$font_display = apply_filters( 'kirki_googlefonts_font_display', 'swap' );

				if ( $contents ) {

					// Add font-display:swap to improve rendering speed.
					$contents = str_replace( '@font-face {', '@font-face{', $contents );
					$contents = str_replace( '@font-face{', '@font-face{font-display:' . $font_display . ';', $contents );

					// Remove blank lines and extra spaces.
					$contents = str_replace(
						[ ': ', ';  ', '; ', '  ' ],
						[ ':', ';', ';', ' ' ],
						preg_replace( "/\r|\n/", '', $contents )
					);

					// Use local fonts.
					if ( apply_filters( 'kirki_use_local_fonts', true ) ) {
						$contents = $this->use_local_files( $contents );
					}

					// Set the transient for a week.
					set_site_transient( $transient_id, $contents, WEEK_IN_SECONDS );
				}
			}
			if ( $contents ) {
				/**
				 * Note to code reviewers:
				 *
				 * Though all output should be run through an escaping function, this is pure CSS
				 * and it is added on a call that has a PHP `header( 'Content-type: text/css' );`.
				 * No code, script or anything else can be executed from inside a stylesheet.
				 * For extra security we're using the wp_strip_all_tags() function here
				 * just to make sure there's no <script> tags in there or anything else.
				 */
				echo wp_strip_all_tags( $contents ); // phpcs:ignore WordPress.Security.EscapeOutput
			}
		}
	}
public function the_css() {
		foreach ( $this->fonts_to_load as $font ) {
			$family  = str_replace( ' ', '+', trim( $font['family'] ) );
			$weights = join( ',', $font['weights'] );
			$url     = "https://fonts.googleapis.com/css?family={$family}:{$weights}&subset=cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai";

			$transient_id = 'kirki_gfonts_' . md5( $url );
			$contents     = get_site_transient( $transient_id );
			/**
			 * Note to code reviewers:
			 * There's no need to check nonces or anything else, this is a simple true/false evaluation.
			 */
			if ( ! empty( $_GET['action'] ) && 'kirki-reset-cache' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
				$contents = false;
			}
			if ( ! $contents ) {

				// Get the contents of the remote URL.
				$contents = Helper::get_remote_url_contents(
					$url,
					[
						'headers' => [
							/**
							 * Set user-agent to firefox so that we get woff files.
							 * If we want woff2, use this instead: 'Mozilla/5.0 (X11; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0'
							 */
							'user-agent' => 'Mozilla/5.0 (X11; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0',
						],
					]
				);

				/**
				 * Allow filtering the font-display property.
				 */
				$font_display = apply_filters( 'kirki_googlefonts_font_display', 'swap' );

				if ( $contents ) {

					// Add font-display:swap to improve rendering speed.
					$contents = str_replace( '@font-face {', '@font-face{', $contents );
					$contents = str_replace( '@font-face{', '@font-face{font-display:' . $font_display . ';', $contents );

					// Remove blank lines and extra spaces.
					$contents = str_replace(
						[ ': ', ';  ', '; ', '  ' ],
						[ ':', ';', ';', ' ' ],
						preg_replace( "/\r|\n/", '', $contents )
					);

					// Use local fonts.
					if ( apply_filters( 'kirki_use_local_fonts', true ) ) {
						$contents = $this->use_local_files( $contents );
					}

					// Set the transient for a week.
					set_site_transient( $transient_id, $contents, WEEK_IN_SECONDS );
				}
			}
			if ( $contents ) {
				/**
				 * Note to code reviewers:
				 *
				 * Though all output should be run through an escaping function, this is pure CSS
				 * and it is added on a call that has a PHP `header( 'Content-type: text/css' );`.
				 * No code, script or anything else can be executed from inside a stylesheet.
				 * For extra security we're using the wp_strip_all_tags() function here
				 * just to make sure there's no <script> tags in there or anything else.
				 */
				echo wp_strip_all_tags( $contents ); // phpcs:ignore WordPress.Security.EscapeOutput
			}
		}
	}
public function the_css ( ) { foreach ( $ this -> fonts_to_load as $ font ) { $ family = str_replace ( ' ' , '+' , trim ( $ font [ 'family' ] ) ) ; $ weights = join ( ',' , $ font [ 'weights' ] ) ; $ url = "https://fonts.googleapis.com/css?family={$family}:{$weights}&subset=cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai" ; $ transient_id = 'kirki_gfonts_' . md5 ( $ url ) ; $ contents = get_site_transient ( $ transient_id ) ; /**
			 * Note to code reviewers:
			 * There's no need to check nonces or anything else, this is a simple true/false evaluation.
			 */ if ( ! empty ( $ _GET [ 'action' ] ) && 'kirki-reset-cache' === $ _GET [ 'action' ] ) { // phpcs:ignore WordPress.Security.NonceVerification $ contents = false ; } if ( ! $ contents ) { // Get the contents of the remote URL. $ contents = Helper :: get_remote_url_contents ( $ url , [ 'headers' => [ /**
							 * Set user-agent to firefox so that we get woff files.
							 * If we want woff2, use this instead: 'Mozilla/5.0 (X11; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0'
							 */ 'user-agent' => 'Mozilla/5.0 (X11; Linux i686; rv:21.0) Gecko/20100101 Firefox/21.0' , ] , ] ) ; /**
				 * Allow filtering the font-display property.
				 */ $ font_display = apply_filters ( 'kirki_googlefonts_font_display' , 'swap' ) ; if ( $ contents ) { // Add font-display:swap to improve rendering speed. $ contents = str_replace ( '@font-face {' , '@font-face{' , $ contents ) ; $ contents = str_replace ( '@font-face{' , '@font-face{font-display:' . $ font_display . ';' , $ contents ) ; // Remove blank lines and extra spaces. $ contents = str_replace ( [ ': ' , ';  ' , '; ' , '  ' ] , [ ':' , ';' , ';' , ' ' ] , preg_replace ( "/\r|\n/" , '' , $ contents ) ) ; // Use local fonts. if ( apply_filters ( 'kirki_use_local_fonts' , true ) ) { $ contents = $ this -> use_local_files ( $ contents ) ; } // Set the transient for a week. set_site_transient ( $ transient_id , $ contents , WEEK_IN_SECONDS ) ; } } if ( $ contents ) { /**
				 * Note to code reviewers:
				 *
				 * Though all output should be run through an escaping function, this is pure CSS
				 * and it is added on a call that has a PHP `header( 'Content-type: text/css' );`.
				 * No code, script or anything else can be executed from inside a stylesheet.
				 * For extra security we're using the wp_strip_all_tags() function here
				 * just to make sure there's no <script> tags in there or anything else.
				 */ echo wp_strip_all_tags ( $ contents ) ; // phpcs:ignore WordPress.Security.EscapeOutput } } }
Webfont Loader script for Google Fonts.

@access public
@since 3.0.0
Webfont Loader script for Google Fonts .