Global Parent theme for all sites

Create a separate directory and a (sub) domain for your themes.
Lets say the domain is themes.example.com, and the directory is /extra/wp-themes/.

Now let all your installations use the new theme root. Or just do the same for plugins to manage all plugins from one place too.

Registering a new theme root is not possible with constants, you will need a plugin like this:

<?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 )
{
    if ( 'theme_root_uri' === current_filter() )
        return "http://themes.example.com";

    // If we made it so far we are in the 'theme_root' filter.
    $new_root="/extra/wp-themes";
    register_theme_directory( $new_root );
    return $new_root;
}

Be aware there is a bug in the WordPress’ theme updater that doesn’t let you update themes from the wordpress.org directory when you are using a custom theme directory. You have to run the updates for such themes either manually, or use my patch from Ticket #22501 until WordPress 3.6 is out.

Leave a Comment