Skip to content

Instantly share code, notes, and snippets.

@JoernSchoenyan
Created June 8, 2018 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoernSchoenyan/18d33759bf9161d9e982f55223793f2a to your computer and use it in GitHub Desktop.
Save JoernSchoenyan/18d33759bf9161d9e982f55223793f2a to your computer and use it in GitHub Desktop.
<?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');
@JoernSchoenyan
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment