diff --git a/functions.php b/functions.php index 7deaa16..22ec15e 100644 --- a/functions.php +++ b/functions.php @@ -1,82 +1,115 @@ is_main_query() ) { /** * Display all the Speakers in one single page * * See https://gitpull.it/T162 * See https://gitpull.it/T178 */ if ( is_tax( 'membertype' ) ) { $query->set( 'nopaging', true ); /** * Increase Podcasts per page * * See https://gitpull.it/T160 * See https://gitpull.it/T178 * */ } elseif( is_post_type_archive( 'podcast' ) || is_tax( 'podcastfilter' ) ) { $query->set( 'posts_per_archive_page', 16 ); } } } ); // Allow SVG upload in Border Radio website // https://gitpull.it/T591 add_filter( 'upload_mimes', function( $mimes ) { $mimes['svg'] = 'image/svg+xml'; return $mimes; } ); + +/** + * Local Google Font cache + */ +define( 'GOOGLE_FONT_CACHE', 'gfont-proxy.border-radio.it' ); + +/** + * Convert a Google Font domain to your local proxy cache + * + * See https://gitpull.it/T776 + */ +function convert_google_font_to_local_proxy_cache( $url ) { + return str_replace( 'fonts.googleapis.com', 'gfont-proxy.border-radio.it', $url ); +} + +/** + * Avoid Google Fonts in your stylesheets + * + * https://gitpull.it/T186 + */ +add_filter( 'style_loader_src', 'convert_google_font_to_local_proxy_cache' ); + +/** + * Avoid Google Fonts in your DNS prefetch + * + * https://gitpull.it/T186 + */ +add_filter( 'wp_resource_hints', function( $urls ) { + foreach( $urls as & $url ) { + $url = convert_google_font_to_local_proxy_cache( $url ); + } + return $urls; +} );