Skip to content

Instantly share code, notes, and snippets.

@timwhitlock
Created August 21, 2010 11:18
Show Gist options
  • Save timwhitlock/542166 to your computer and use it in GitHub Desktop.
Save timwhitlock/542166 to your computer and use it in GitHub Desktop.
Simple tools for deploying Wordpress assets on a CDN
<?php
/**
Plugin Name: CDN Tools
Plugin URI: http://web.2point1.com/tag/wp-cdn
Description: Simple tool for deploying Wordpress assets on a CDN
Version: 0
Author: Tim Whitlock
Author URI: http://twitter.com/timwhitlock
*/
/**
* Gets the base URL for all themes on CDN
*/
function wp_cdn_theme_root_uri( $themes_baseurl, $site_baseurl, $theme_dir ){
if( strpos( $themes_baseurl, WP_CDN_ROOT ) === false ){
$path = str_replace( $site_baseurl, '', $themes_baseurl );
$themes_baseurl = WP_CDN_ROOT . $path;
}
return $themes_baseurl;
}
// add filters
if( defined('WP_CDN_ROOT') ){
add_filter('theme_root_uri', 'wp_cdn_theme_root_uri', 0, 3 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment