wp 博客 手工资源动静分离

Xiu: 模板函数 (functions.php)


header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, api_key, Authorization");
header('Access-Control-Allow-Methods: GET, POST, PUT');

// custom functions


define('CDN_HOST','//52tw.me.cdn.81tw.com');

add_filter('the_content','z_cdn_content');
function z_cdn_content($content){
  return str_replace(home_url().'/wp-content/uploads', CDN_HOST.'/wp-content/uploads', $content);
}

add_filter('wp_get_attachment_url','z_get_attachment_url',10,2);
function z_get_attachment_url($url, $post_id){
  return str_replace(home_url(), CDN_HOST, $url);
  }

add_filter('stylesheet_directory_uri','z_cdn_stylesheet_directory_uri',10,3);
function z_cdn_stylesheet_directory_uri($stylesheet_dir_uri, $stylesheet, $theme_root_uri) {
   return str_replace(home_url(), CDN_HOST, $stylesheet_dir_uri);
 }
add_filter('template_directory_uri','z_cdn_template_directory_uri',10,3);
function z_cdn_template_directory_uri($template_dir_uri, $template, $theme_root_uri)
{
   return str_replace(home_url(), CDN_HOST, $template_dir_uri);
}

未经允许不得转载:天威 » wp 博客 手工资源动静分离

相关推荐

    暂无内容!

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址