Опубликовано Оставить комментарий

Сниппет для отключения Google Fonts (тема Storefront)

Dequeue Google Fonts based on URL (вместо плагина Disable and Remove Google Fonts) https://github.com/fontsplugin/disable-google-fonts/blob/master/disable-remove-google-fonts.php

 /**
 * Dequeue Google Fonts based on URL.
 */

function drgf_dequeueu_fonts() {
	global $wp_styles;

	if ( ! ( $wp_styles instanceof WP_Styles ) ) {
		return;
	}

	foreach ( $wp_styles->registered as $style ) {
		$handle = $style->handle;
		$src    = $style->src;

		if ( false !== strpos( $src, 'fonts.googleapis' ) ) {
				wp_dequeue_style( $handle );
		}
	}
}

add_action( 'wp_enqueue_scripts', 'drgf_dequeueu_fonts', 9999 );
add_action( 'wp_print_styles', 'drgf_dequeueu_fonts', 9999 );

//********************************************************************************Dequeue Google Fonts based on URL

Дополнительно можно почитать

https://www.tunetheweb.com/blog/should-you-self-host-google-fonts/ (перевод — https://habr.com/ru/company/vdsina/blog/490366/)

https://developers.google.com/web/tools/workbox/guides/common-recipes

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *