Skip to content

Instantly share code, notes, and snippets.

@thefuxia
Created October 27, 2012 01:30
Show Gist options
  • Save thefuxia/3962587 to your computer and use it in GitHub Desktop.
Save thefuxia/3962587 to your computer and use it in GitHub Desktop.
theme-roots.php
<?php
/* Plugin Name: Local Theme Roots */
add_filter( 'theme_root_uri', 't5_switch_theme_root' );
add_filter( 'theme_root', 't5_switch_theme_root' );
/**
* Create a custom theme directory.
*
* @wp-hook theme_root
* @wp-hook theme_root_uri
* @author Thomas Scholz, http://toscho.de
* @param string $in URL or path
* @return string
*/
function t5_switch_theme_root( $in )
{
// local multi-sites end with 'mu.wp'. Example: t5.mu.wp.
if ( 0 !== stripos( strrev( $_SERVER['HTTP_HOST'] ), 'pw.um' ) )
{
return $in;
}
if ( 'theme_root_uri' === current_filter() )
{
return "http://themes.wp/";
}
$new_root = dirname( dirname( __DIR__ ) ) . '/wp-themes';
// If we made it so far we are in the 'theme_root' filter.
register_theme_directory( $new_root );
return $new_root;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment