```// CDN
function qiniu_cdn($buffer){
$cdnstr = '//
oh8ipvbpu.qnssl.com';
$buffer = str_replace(array(get_stylesheet_directory_uri()), $cdnstr . '/wp-content/themes/' . get_template(), $buffer);
$buffer = str_replace(array(includes_url( '/js/')), $cdnstr . '/wp-includes/js/', $buffer);
$buffer = str_replace(array(plugins_url()), $cdnstr . '/wp-content/plugins', $buffer);
$buffer = str_replace(array(wp_upload_dir()['baseurl']), $cdnstr . '/Upfiles', $buffer);
return $buffer;
}
// 打开缓冲区并送出缓冲区内容
function qiniu_cdn_flush(){
ob_start("qiniu_cdn");
if(ob_get_level() > 0) ob_flush();
}
// 清除缓冲区
function qiniu_cdn_clear(){
if(ob_get_level() > 0) {
ob_end_clean();
}
}
// 根据情况加载函数
if ( is_admin() ) {
if (ob_get_level() > 0) {
do_action('admin_init', 'qiniu_cdn_clear');
}
} else {
add_action('after_setup_theme', 'qiniu_cdn_flush');
}```