Как полностью удалить Google Fonts из кода WordPress с темой OceanWP

Чтобы полностью удалить Google Fonts из кода WordPress с темой OceanWP:

Если настройки не помогают, добавьте этот код в functions.php


// Полное отключение Google Fonts в OceanWP
add_filter('ocean_enqueue_google_fonts', '__return_false');
add_filter('ocean_body_font_family', '__return_empty_string');
add_filter('ocean_heading_font_family', '__return_empty_string');

// Удаление dns-prefetch для Google Fonts
add_filter('wp_resource_hints', function($urls, $relation_type) {
    if ('dns-prefetch' === $relation_type) {
        $urls = array_filter($urls, function($url) {
            return false === strpos($url, 'fonts.googleapis.com') && 
                   false === strpos($url, 'fonts.gstatic.com');
        });
    }
    return $urls;
}, 10, 2);

// Удаление уже зарегистрированных стилей Google Fonts
add_action('wp_enqueue_scripts', function() {
    global $wp_styles;
    if (!empty($wp_styles->queue)) {
        foreach ($wp_styles->queue as $key => $handle) {
            if (false !== strpos($handle, 'google') || 
                false !== strpos($handle, 'google-font')) {
                wp_dequeue_style($handle);
                wp_deregister_style($handle);
            }
        }
    }
}, 100);
guest
Другие сообщения форума
Закрыть меню
ZAPLATA.RU | Магазин готовых блогов Wordpress с автонаполнением
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.