Skip to content

Instantly share code, notes, and snippets.

@bigdigital
Last active February 17, 2017 08:29
Show Gist options
  • Save bigdigital/933314dc80fb849482b801bdb300af45 to your computer and use it in GitHub Desktop.
Save bigdigital/933314dc80fb849482b801bdb300af45 to your computer and use it in GitHub Desktop.
Change default Google font URL in The7 theme
function my_dt_make_web_font_uri( $font, $effect = '' ) {
if ( !$font ) {
return false;
}
// add web font effect
if ( function_exists('dt_get_web_fonts_effects') ) {
if ( array_key_exists( $effect, dt_get_web_fonts_effects() ) ) {
$effect = '&effect=' . esc_attr( $effect );
} else {
$effect = '';
}
} else {
$effect = '';
}
//Here you can set own google mirror
return '//fonts.useso.com/css?family=' . str_replace( ' ', '+', $font ) . $effect;
}
/**
* Web fonts override.
*
*/
function presscore_enqueue_web_fonts() {
$fonts = array();
$options = _optionsframework_get_clean_options();
foreach ( $options as $option ) {
if ( 'web_fonts' === $option['type'] ) {
// Replace & coz in db value sanitized with esc_attr().
$fonts[] = str_replace( '&', '&', of_get_option( $option['id'] ) );
}
}
$fonts_compressor = new Presscore_Web_Fonts_Compressor();
$compressed_fonts = $fonts_compressor->compress_fonts( presscore_filter_web_fonts( $fonts ) );
wp_enqueue_style( 'dt-web-fonts', my_dt_make_web_font_uri( $compressed_fonts ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment