views:

14

answers:

1

I am developing a plugin for an MU site. The MU site has about a few hundred blogs, but there are three types of blogs and they are named as:

blogname/sportstype1 blogname/sportstype2 blogname/sportstype3 blogname/celebritytype1 blogname/celebritytype2 etc.

I need to make two functions, one for type1, and the other function for the rest (type2/3). I have a function I made, wanted to ask is this the right/best way to do this:

    $whatistype = <?php get_bloginfo('site_url'); ?>
    $type = <?php substr( $whatistype, -4);
    <?php if ( $type == "type1 ) 
{ include 'type1list.php'; 
   /* Or code */
}

else 

{ include 'typelistother.php
    /* Or code */
 }
?>

Also, I would want this to run only when a blog is created. I will check under the hood at Cets Default plugin, but would it be best to make this a plugin and activate sitewide or make into an MU-plugin? How would I go about making a plugin for the mu-folder (can't find much documentation on it).

A: 

I would create a MU plugin with a function that is hooked onto wpmu_new_blog.

function my_custom_new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta)
{
     // depending on if you're using subdomains or sub-directories,
     // match against $domain or $path respectively for 'type'
}
add_action('wpmu_new_blog'), 'my_custom_new_blog', 10, 6);

Just create a PHP file, name it what you like, throw in the standard WordPress plugin headers (not required, purely for information in the plugins admin screen) and then drop it in the root of wp-content/mu-plugins.

If you want to break up your code from a single file, place everything inside wp-content/mu-plugins/my-directory - anything in there won't be touched by WP - but keep your single PHP file still in the root, using it to load the rest of your code when it needs it.

TheDeadMedic
Hey, this helped a lot. Thanks a lot for the tutorial! DeadMedic, you might be single-handedly keeping us WP newbies afloat.
James