wordpress-multisite

WordPress MultiSite, Plugins and Activation

WordPress offers for normal Plugins the hook register_activation_hook();. This is active right after the activation of a Plugin, so you can start small installation scripts. But if we are in a MultiSite environment (old: MultiUser) and put the Plugin in the folder wp-content/mu-plugins, then the hook doesn't do anything, because the Plugin is automatically activated. But there are few ways you can still have a kind of activation hook. One is this option:

if ( ! class_exists( 'my_mu_plugin' ) ) {

    if ( function_exists( 'add_action' ) ) {
        add_action( 'plugins_loaded' ,  array( 'my_mu_plugin', 'get_object' ) );
    }
 
    class my_mu_plugin {

        static private $classobj = NULL;

        public function get_object () {
            if ( NULL === self :: $classobj ) {
                self :: $classobj = new self;
            }
            return self :: $classobj;
        }
 
        public function __construct () {
            // Fake-Activation-Hook
            $this->activation();
        }
 
        private function activation () {
            if ( 'activated' == get_blog_option( 1, 'my_mu_plugin_activated' ) ) {
                // Do Stuff during activation
                ...
 
                // Update Option
                update_blog_option( 1, 'my_mu_plugin_activated', 'activated' );
            }
        }

    }

}

We are doing the following: We check whether a certain option is set in blog 1, if not, then run through an activation function, otherwise do nothing - Blog 1 simple so that the install script is only in blog 1 in use. If you want to use it in all the blogs then simply use the function get_option(). Easy, right?

Guest Post

This post is written by Thomas Herzog - hughwillfayle.de and is a guest post on WP Engineer about WordPress.
Thank you very much from my part to Thomas. Please see his nice plugins on the official WordPress repository.
If you also like to have your interesting post published on our website, please let us know on our contact page. Of course we will appreciate your contribution!

Remove WordPress Multisite Feature – ToDo List!

You can activate the Multisite functionality of WordPress relatively quick and it is well explaind in the backend how to do it. But not always you like to keep it as a multi site installation and therefore you have to do some measures to remove the Network function again.

Not easy and probably not an every day task - so that's why I created a small todo list in order not to forget a step to restore to the default installation.
Continue reading …

WordPress 3.0 Multisite Settings

Exclusively 2 Screenshots of the new WordPress 3.0 Multisite Settings. You can find them under Options->Network:
WordPress 3.0 Network settings step 1
After you set the settings, you receive in a second step the content for wp-config.php and .htaccess. Additionally you have to create the subfolder blogs.dir in wp-content , where you put the media-files for each blog.

WordPress 3.0 Network settings step 2

Since WordPress 3.0 is still in development, there might be many changes until the final release.