Multisite Themes

12.02.2010

POSTED IN Plugins, WordPress

Multisite Themes is a very simple plugin that I created to help administrators of WordPress Multi Site setups define different themes for different sites.

Why?

I was providing clients with wpmu/wpms sites and I needed a way to make only certain themes available to certain site admins.

“This is already doable when you edit a blog in the admin.”

Technically it’s not. Remember, a site is different than a blog
A site contains blogs.
A site can be at Domain1.com while you have another site at Domain2.com, both with different sub-blogs underneath of them.

Instructions

I’ll hopefully have this up on the WordPress Plugin Database soon, but until then you can save the below txt document as a php file and upload to your plugins folder, activate and you’re good to go.

To add a theme that is site specific, simply make a folder called ms-themes in your wp-content directory.
In the ms-themes directory you create another folder with the same id as the site you want to add the theme to.

Example for Site with id of 7:
http://www.yourdomain.com/wp-content/ms-themes/7/

Any themes placed in the /7/ directory will be available for site_id 7.

Future Plans

  • Done:  I plan to automagically create the ms-themes directory.
  • Have option to automatically create site directories.
  • Output display for easy recognition of what a site’s ID is.

Known Bugs

No known bugs. If you have a problem, please contact me through my contact page.

Download

Download from the WordPress Plugin Directory: http://wordpress.org/extend/plugins/multisite-themes/

Donate

Please make any donations to a charity of your choice in my name (Dustin Dempsey). Let me know if you do.

13 Responses to “Multisite Themes”

  1. Dustin.

    This is simple and great, I’m sure, but I can’t get it to work with the beta of WP3.0.

    I can’t even get the register_theme_directory function to work. So I dunno if it’s a beta bug still present or something I’m doing wrong, but I’m going nuts!

    Have you tested this yourself with the latest beta of WP3.0??

    Would love to know ;)

    Cheers,

    -Alister

  2. admin says:

    Alister, thanks for the message.

    I’ll double check, let me make sure that I have the latest 3.0 and that everything is in order.

    Thanks.
    Dustin

  3. admin says:

    Alister,
    Just tested with 3.0-BETA1 and it’s working as expected.

    Please check to see if /wp-content/ms-themes/ directory was created and you have a directory corresponding to the WordPress “network” you want to add the themes to.

    example: /wp-content/ms-themes/7/theme-folder/
    for the network with the id of “7″, “theme folder” will be available.

    note, that if you’re using this plugin in an environment where you only have one “network” (formally known as a site with WPMU) it will have no benefit. You will need multiple networks.

    Let me know if you have any more questions.

  4. Giofilo says:

    Hi Alister,

    It’s possible to have site-specific plugins and not only themes? Maybe can I modify your plugin in any way?

    Thank you,
    Giovanni
    Italy

  5. pescadito says:

    Hi Dustin, i tried your code without succeful, but it’s a nice start point to have local themes.
    It appear that it only write two files, one index.php in ms-themes, and the another only in first (mamely: /ms-sites/1/ ) directory. It doesn’t take in account the others blogs (2,3,etc).
    So it only work when you put the themes in /1/ directory, even if this plugins is activated for the others blog (nro 2 or 3, etc).

    Have you any idea to comment us??

  6. Berteh says:

    i tested your plugin multisite-user-management. nice concept thanks.

    Please simply update code for WP3.0: you don’t need for the wp-mu directory test, so default install works nicely. Plugins works nicely from super admin that way.

    simply drop first code block: if(basename( dirname( __FILE__ ) ) != ‘mu-plugins’ ) {…}

    thanks!
    B.

  7. admin says:

    There is a plugin for WordPress MU called local mu plugins that should do this for you.

  8. admin says:

    This plugin isn’t made for blog specific themes as you can do that out of the box with WordPress. This is meant for different themes per different networks.

  9. admin says:

    I’m sorry, I’m not the author of the Multisite User Management plugin.

  10. I made some edits to your script to update for Wordpress 3.0! Nice work with the original conept! Thanks!

    id . “/index.php”;

    // text for ms-themes index.php
    $filetext = “”;

    // get date and define text for site specific index.php with redirect
    $date = date(’l jS \of F Y h:i:s A’);
    $filetextsite = “domain’); \n ?>”;

    // check if directory exists and create it if it does not
    // add index.php file to the directory so it cannot be indexed
    if ( ! is_dir($dir) ) {
    mkdir($dir);
    file_put_contents($filename, $filetext);
    } elseif (!file_exists($filename)) {
    file_put_contents($filename, $filetext);
    }

    // register theme directory for current site
    register_theme_directory($dir . ‘/’ . $blog_id);

    //create index.php in site folder for redirect and to prevent directory from being indexed
    if ( is_dir($dir . ‘/’ . $current_site->id) && !file_exists($filenamesite) ) {
    file_put_contents($filenamesite, $filetextsite);
    }
    }

    ?>

  11. My original post didn’t come through to well! Sorry about that. Essentailly, just wanted to let you know for Wordpress 3.0, change

    global $current_site;

    to

    global $blog_id;

    and change

    register_theme_directory($dir . ‘/’ . $current_site->id);

    to

    register_theme_directory($dir . ‘/’ . $blog_id);

    and everything works out really well! Thanks for your work on this! I hope you keep working on it!

    Best,
    Justin

  12. spybubble says:

    Thansk for the great plugin..im adding it to all my wordpress sites.. keep up the great work!

  13. PuffyThePirateBoy says:

    Great plugin with a clean and nice implementation. Been testing it with WordPress 3.1-RC2 and it seems to be working as expected.

(Required)
(Required)


Currently Accepting New Projects

Contact us today to get your next website or web app developed!
Inquire on our contact page!

Welcome

Welcome to Playforward's online portfolio. We let our work speak for itself! Take a look around and if you need assistance, please check out the services we offer and contact us to get started.