Created
June 8, 2018 07:52
-
-
Save JoernSchoenyan/18d33759bf9161d9e982f55223793f2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Google Font Proxy Enabler | |
* Plugin URI: | |
* Description: Get Google Fonts from a proxy server | |
* Author: Jörn Schönyan | |
* Author URI: https://ifdata.de | |
* Version: 1.0 | |
* License: GPL v2.0 | |
*/ | |
/** This plugin is based on ideas from https://github.com/hzxie/Google-Font-Fix - Thanks Haozhe! */ | |
define('GFF_PLUGIN_PATH', plugin_dir_path(__FILE__)); | |
function google_apis_fix($buffer) { | |
return preg_replace('|(https*:)*//(.*).googleapis.com/|', 'https://your.proxy/fgap_mirror/', $buffer); | |
} | |
function gff_buffer_start() { | |
ob_start("google_apis_fix"); | |
} | |
function gff_buffer_end() { | |
while ( ob_get_level() > 0 ) { | |
ob_end_flush(); | |
} | |
} | |
add_action('init', 'gff_buffer_start'); | |
add_action('shutdown', 'gff_buffer_end'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Set up a proxy for Google Fonts like this: https://www.haotoday.com/use-apache-to-setup-a-reverse-proxy-for-google-fonts-in-wordpress/