Dequeue Google Fonts
-
Hi,
My site hosts Google Fonts locally. But I can′t find a way to dequeue Hestia′s calls to fonts.googleapis.com. I′m using Orfeo child theme.
Google Fonts are registered and enqueued in inc/views/inline/class-hestia-inline-manager.php:
/**
* Register the fonts that are selected in customizer.
*/
public function register_google_font() {/**
* Headings font family.
*/
$hestia_headings_font = get_theme_mod( ‘hestia_headings_font’, apply_filters( ‘hestia_headings_default’, false ) );
if ( ! empty( $hestia_headings_font ) ) {
$this->enqueue_google_font( $hestia_headings_font );
}/**
* Body font family.
*/
$hestia_body_font = get_theme_mod( ‘hestia_body_font’, apply_filters( ‘hestia_body_font_default’, false ) );
if ( ! empty( $hestia_body_font ) ) {
$this->enqueue_google_font( $hestia_body_font );
}
}/**
* Enqueues a Google Font
*
* @since 1.1.38
*
* @param string $font font string.
*/
private function enqueue_google_font( $font ) {// Get list of all Google Fonts
$google_fonts = hestia_get_google_fonts();// Make sure font is in our list of fonts
if ( ! $google_fonts || ! in_array( $font, $google_fonts, true ) ) {
return;
}// Sanitize handle
$handle = trim( $font );
$handle = strtolower( $handle );
$handle = str_replace( ‘ ‘, ‘-‘, $handle );// Sanitize font name
$font = trim( $font );$base_url = ‘//fonts.googleapis.com/css’;
// Apply the chosen subset from customizer
$subsets = ”;
$get_subsets = get_theme_mod( ‘hestia_font_subsets’, array( ‘latin’ ) );
if ( ! empty( $get_subsets ) ) {
$font_subsets = array();
foreach ( $get_subsets as $get_subset ) {
$font_subsets[] = $get_subset;
}
$subsets .= implode( ‘,’, $font_subsets );
}// Weights
$weights = apply_filters( ‘hestia_font_weights’, array( ‘300’, ‘400’, ‘500’, ‘700’ ) );// Add weights to URL
if ( ! empty( $weights ) ) {
$font .= ‘:’ . implode( ‘,’, $weights );
}$query_args = array(
‘family’ => urlencode( $font ),
);
if ( ! empty( $subsets ) ) {
$query_args[‘subset’] = urlencode( $subsets );
}
$url = add_query_arg( $query_args, $base_url );// Enqueue style
wp_enqueue_style( ‘hestia-google-font-‘ . $handle, $url, array(), false );
}————–
I′ve added the code below in Orfeo functions.php after ‘after_setup_theme’, with no success:
function tm_dequeue_google_fonts() {
wp_dequeue_style( ‘hestia-google-font-‘ );
}
add_action( ‘wp_print_styles’, ‘tm_dequeue_google_fonts’ );Maybe the code above is wrong and/or in the wrong place. Maybe got to unlink the function? This is how Orfeo enqueues Hestia′s style:
* Enqueue parent style
*
* @since 1.0.0
*/
function orfeo_parent_css() {
wp_enqueue_style( ‘orfeo_parent’, trailingslashit( get_template_directory_uri() ) . ‘style.css’, array( ‘bootstrap’ ), ORFEO_VERSION );
wp_style_add_data( ‘orfeo_parent’, ‘rtl’, ‘replace’ );
wp_style_add_data( ‘hestia_style’, ‘rtl’, ‘replace’ );
}
endif;
add_action( ‘wp_enqueue_scripts’, ‘orfeo_parent_css’, 10 );I have no technical knowledge. Someone knows how to stop the calls to fonts.googleapis.com?
Thanks,
Julia
The page I need help with: [log in to see the link]
- The topic ‘Dequeue Google Fonts’ is closed to new replies.