≡ Menu

Thesis 1.8.x – Master Header and Stylesheet for Thesis Multisite

So I recently started playing around with WP Multisite to get ready for a project I’ll be doing down the road.  With Thesis 1.8.4 they’ve added better support for multisite, but there were a few things that were missing for my purposes.

Basically the model I’ve been testing is an organization site where each user has their own sub-site where they can put up various information, post their own blog etc.


So to that effect I want to keep the overall design and nav elements the same.  This is where Thesis doesn’t handle things automatically.  With 1.8.4 Thesis gives you a master control custom_functions.php so you can change aspects of your entire network in one shot (wicked!) however, the master custom.css does not affect all the network sites.

So I had to re-add the master custom.css file back into each of the sites.

function master_thesis_custom_stylesheet() {
    $handle = 'master_custom';
    $src = get_stylesheet_directory_uri() . '/custom/custom.css';
    $media = 'screen, projection';
    wp_register_style($handle, $src, $deps, false, $media);
add_action('wp_enqueue_scripts', 'master_thesis_custom_stylesheet');

My next step was to change the header of all sites to be the same as the base site.  This I accomplished by using the same code Thesis uses to generate the header, with one subtle difference.

function master_thesis_default_header() {
remove_action('thesis_hook_header', 'thesis_default_header');
add_action('thesis_hook_header', 'master_thesis_default_header');

The switch_to_blog() function temporarily switches all details of the site (with some exceptions) to the master site and the restore_current_blog() changes it back to the current one.  That way the site name, url etc. that the thesis_title_and_tagline() function uses is from the master site.

Finally, using the same technique as I did with the header I added in a master nav menu* to the site:

function master_thesis_nav_menu() {
remove_action('thesis_hook_before_header', 'thesis_nav_menu');
add_action('thesis_hook_before_header', 'master_thesis_nav_menu');

If you’re after a left nav instead:

function master_left_menu() {
    echo "<li id=\"nav_menu-main\" class=\"widget widget_nav_menu\">\n";
    wp_nav_menu(array('menu' => 'Left Nav','menu_class' => 'menu','container' => 'div'));
    echo "</li>\n";
add_action('thesis_hook_before_sidebar_1', 'master_left_menu');

* You need to create the menu as a wp_menu in the base site first.

Comments on this entry are closed.