docs/files/class-my-theme-kirki.php
public function enqueue_fonts() {

		// Check if we need to exit early.
		if ( empty( self::$fields ) || ! is_array( self::$fields ) ) {
			return;
		}

		foreach ( self::$fields as $field ) {

			// Process typography fields.
			if ( isset( $field['type'] ) && 'typography' === $field['type'] ) {

				// Check if we've got everything we need.
				if ( ! isset( $field['kirki_config'] ) || ! isset( $field['settings'] ) ) {
					continue;
				}
				$value = self::get_option( $field['kirki_config'], $field['settings'] );
				if ( isset( $value['font-family'] ) ) {
					$url              = '//fonts.googleapis.com/css?family=' . str_replace( ' ', '+', $value['font-family'] );
					$value['variant'] = ( isset( $value['variant'] ) ) ? $value['variant'] : '';
					$url             .= ( empty( $value['variant'] ) ) ? '' : ':' . $value['variant'];

					$key = md5( $value['font-family'] . $value['variant'] );

					// Check that the URL is valid. we're going to use transients to make this faster.
					$url_is_valid = get_transient( $key );

					// If transient does not exist.
					if ( false === $url_is_valid ) {
						$response = wp_remote_get( 'https:' . $url );
						if ( ! is_array( $response ) ) {

							// The url was not properly formatted,
							// cache for 12 hours and continue to the next field.
							set_transient( $key, null, 12 * HOUR_IN_SECONDS );
							continue;
						}

						// Check the response headers.
						if ( isset( $response['response'] ) && isset( $response['response']['code'] ) ) {
							if ( 200 === $response['response']['code'] ) {

								// URL was ok. Set transient to true and cache for a week.
								set_transient( $key, true, 7 * 24 * HOUR_IN_SECONDS );
								$url_is_valid = true;
							}
						}
					}

					// If the font-link is valid, enqueue it.
					if ( $url_is_valid ) {
						wp_enqueue_style( $key, $url, array(), '1.0' );
					}
				}
			}
		}
	}
public function enqueue_fonts() {

		// Check if we need to exit early.
		if ( empty( self::$fields ) || ! is_array( self::$fields ) ) {
			return;
		}

		foreach ( self::$fields as $field ) {

			// Process typography fields.
			if ( isset( $field['type'] ) && 'typography' === $field['type'] ) {

				// Check if we've got everything we need.
				if ( ! isset( $field['kirki_config'] ) || ! isset( $field['settings'] ) ) {
					continue;
				}
				$value = self::get_option( $field['kirki_config'], $field['settings'] );
				if ( isset( $value['font-family'] ) ) {
					$url              = '//fonts.googleapis.com/css?family=' . str_replace( ' ', '+', $value['font-family'] );
					$value['variant'] = ( isset( $value['variant'] ) ) ? $value['variant'] : '';
					$url             .= ( empty( $value['variant'] ) ) ? '' : ':' . $value['variant'];

					$key = md5( $value['font-family'] . $value['variant'] );

					// Check that the URL is valid. we're going to use transients to make this faster.
					$url_is_valid = get_transient( $key );

					// If transient does not exist.
					if ( false === $url_is_valid ) {
						$response = wp_remote_get( 'https:' . $url );
						if ( ! is_array( $response ) ) {

							// The url was not properly formatted,
							// cache for 12 hours and continue to the next field.
							set_transient( $key, null, 12 * HOUR_IN_SECONDS );
							continue;
						}

						// Check the response headers.
						if ( isset( $response['response'] ) && isset( $response['response']['code'] ) ) {
							if ( 200 === $response['response']['code'] ) {

								// URL was ok. Set transient to true and cache for a week.
								set_transient( $key, true, 7 * 24 * HOUR_IN_SECONDS );
								$url_is_valid = true;
							}
						}
					}

					// If the font-link is valid, enqueue it.
					if ( $url_is_valid ) {
						wp_enqueue_style( $key, $url, array(), '1.0' );
					}
				}
			}
		}
	}
public function enqueue_fonts ( ) { // Check if we need to exit early. if ( empty ( self :: $ fields ) || ! is_array ( self :: $ fields ) ) { return ; } foreach ( self :: $ fields as $ field ) { // Process typography fields. if ( isset ( $ field [ 'type' ] ) && 'typography' === $ field [ 'type' ] ) { // Check if we've got everything we need. if ( ! isset ( $ field [ 'kirki_config' ] ) || ! isset ( $ field [ 'settings' ] ) ) { continue ; } $ value = self :: get_option ( $ field [ 'kirki_config' ] , $ field [ 'settings' ] ) ; if ( isset ( $ value [ 'font-family' ] ) ) { $ url = '//fonts.googleapis.com/css?family=' . str_replace ( ' ' , '+' , $ value [ 'font-family' ] ) ; $ value [ 'variant' ] = ( isset ( $ value [ 'variant' ] ) ) ? $ value [ 'variant' ] : '' ; $ url .= ( empty ( $ value [ 'variant' ] ) ) ? '' : ':' . $ value [ 'variant' ] ; $ key = md5 ( $ value [ 'font-family' ] . $ value [ 'variant' ] ) ; // Check that the URL is valid. we're going to use transients to make this faster. $ url_is_valid = get_transient ( $ key ) ; // If transient does not exist. if ( false === $ url_is_valid ) { $ response = wp_remote_get ( 'https:' . $ url ) ; if ( ! is_array ( $ response ) ) { // The url was not properly formatted, // cache for 12 hours and continue to the next field. set_transient ( $ key , null , 12 * HOUR_IN_SECONDS ) ; continue ; } // Check the response headers. if ( isset ( $ response [ 'response' ] ) && isset ( $ response [ 'response' ] [ 'code' ] ) ) { if ( 200 === $ response [ 'response' ] [ 'code' ] ) { // URL was ok. Set transient to true and cache for a week. set_transient ( $ key , true , 7 * 24 * HOUR_IN_SECONDS ) ; $ url_is_valid = true ; } } } // If the font-link is valid, enqueue it. if ( $ url_is_valid ) { wp_enqueue_style ( $ key , $ url , array ( ) , '1.0' ) ; } } } } }
Enqueue google fonts.

@access public
@return null
Enqueue google fonts .