loli.net CDN for Wordpress 替换 Google 字体 Gravatar 头像

C 2018-9-22 3567

本插件可在中国大陆一键加速Wordpress


<?php
/*
  Plugin Name: loli.net CDN
  Description: Design for China
  Version: 1
*/
add_action('wp_loaded',function(){ob_start(function($html){return preg_replace_callback('/<(link|script|img)([^<>]+)>/i',function($find){return preg_replace(array('/\.googleapis\.com/','/\/\/(.*?)\.gravatar\.com/'),array('.loli.net','//gravatar.loli.net'),$find[0]);},$html);});});
add_action('shutdown',function(){if(ob_get_level()>0){ob_end_flush();}});

打包:loli-net-cdn/loli-net-cdn.php

灵感:WP Acceleration for China(lomu.me)


最新回复 (0)