The MU forums have moved to WordPress.org

How to change the theme directory? Need some advice here! (13 posts)

  1. joseph21
    Member
    Posted 10 years ago #

    Hello,

    I don't have any substantial knowledge in PHP yet, but I've tried digging up the codes, trying to find where to change the themes directory for wpmu. Its got to be somewhere in themes.php ??

    I tried changing the $stylesheets ... defined in themes.php but it seems like there's some more codes that needs to be revised in order to change the themes directory?

    Could somebody please help.

    Thanks.

  2. joseph21
    Member
    Posted 10 years ago #

    Anybody?

  3. andrea_r
    Moderator
    Posted 10 years ago #

    What on earth are you trying to do???

  4. mysorehead
    Member
    Posted 10 years ago #

    If you want to change the location of the themes directory you can use a filter

    eg.

    add_filter('theme_root', 'rgo_group_blog_theme');

    function rgo_group_blog_theme($thedir) {
    if ( is_group_blog() ) {
    return ABSPATH . "wp-content/mu-plugins/group_themes";
    } else {
    return $thedir;
    }
    }

    Hope this helps
    Richard

  5. zappoman
    Member
    Posted 10 years ago #

    WOW! That's cool! I would never have guessed this existed. I've got a couple of blended installs of wordpressmu and other instances of wordpress and I was getting really annoyed updating themes in multiple places.

    Yeehaa!!!

    You rock MySoreHead!

  6. zappoman
    Member
    Posted 10 years ago #

    Hee hee! I wrote a plugin to make this easier...

    See my blog here.

    http://heftagaub.wordpress.com/2007/05/27/common-themes-directory-for-multiple-instances-of-wordpress/

  7. mysorehead
    Member
    Posted 10 years ago #

    Glad to help
    Richard

  8. joseph21
    Member
    Posted 10 years ago #

    Thanks mysorehead!! you're the best, do I need to say you are my hero? I can put a link back to your site.

    BTW, where do we place that line of code? I'm thinking about making a drop down list, wherein we will have the choice to pick from available theme folders?

    Like for example if I have Space, Flowers, and City folders in the theme directory, the drop down list will show those as items availalbe for selection.. and when Space is chosen it will show the available themes.

    Is this possible? I'm willing to put a link back to your site or to anybody who could help!

    TKS!

  9. mysorehead
    Member
    Posted 10 years ago #

    joseph21,
    The code was taken from one of my plugins (unreleased) and won't work for you, it was only meant to be illustrative.

    This code goes in a plugin in the mu-plugins folder, for your purposes you would have to look at the best way to do what you want to do. Whether you alter the core code or try to make a plugin. I've not had to alter core code yet and if you alter core code you need to keep good records for when you upgrade but...

    Depending on how you return your drop done list of space, flowers and city your code would be something like, assuming a variable like 'theme_type"

    add_filter('theme_root', 'world_themes');

    function world_themes($thedir) {
    switch ( $_REQUEST["theme_type"] ) {
    case "space":
    return ABSPATH . "wp-content/themes/space";
    break;

    case "flowers":
    return ABSPATH . "wp-content/themes/flowers";
    break;

    case "city":
    return ABSPATH . "wp-content/themes/city";
    break;

    default:
    return $thedir;
    }
    }

    You would need to leave the default theme in its normal place in case things go wrong.

    Good luck.

    Richard

  10. zappoman
    Member
    Posted 10 years ago #

    Joseph and Richard, check out the plugin I put up on my blog... it let's you set the path in your options menu... you could easily mod this into a drop down list instead of a text box.

    Also note: there is a small bug in the theme picker that will not honor this filter setting for displaying screenshots, it will always go back to the old dir/url... but I fixed that problem in my plugin without make a core change by installing an ob_start php filter to fix up the offending lines.

  11. joseph21
    Member
    Posted 9 years ago #

    @Richard Thanks for codes.

    @Brad/Zappoman I think your site is blocked by visitors in our country, so I used a proxy web just to access your site. I tried placing the common-themes.php into my wpmu site wp-content/plugins/common-themes.php but when I activated the plugin it gave me this error:

    Plugin could not be activated because it triggered a fatal error.

    Though I could see the Theme Root Options but when I go Presentation the page was blank.

    I think I still need to configure something in the codes?

    Thanks!

  12. zappoman
    Member
    Posted 9 years ago #

    Joseph21,

    I guess I only tested this in stand alone wordpress because I wanted to point it to my wordpressmu themes. I will test the with wpmu as you've described... although I think it would make more sense, if you want to use it with wpmu to put this plugin in the mu-plugins directory; otherwise every user would have to enable it by hand...

  13. joseph21
    Member
    Posted 9 years ago #

    Hi Zappoman, I can't wait to be the first one to test your plugin! Please tell us if you have make it work with MU. :)

    Thanks.

About this Topic

  • Started 10 years ago by joseph21
  • Latest reply from joseph21