mu-plugins

What is the main difference in how mu-plugins and plugins work. When I put my custom written plugin in the mu-folder it does not work, and I’m wondering what the difference is.

Thanks

-Brad

  • btray77
    • Site Builder, Child of Zeus

    I just read on another website that the big difference was hooks and I was wondering if you have any ideas on how I can change from a hook to action or what is required.

    Here’s what the plugin is using now:

    function runit_activate()
    {
    wp_schedule_event( time(), 'hourly', 'runit_hourly' );
    update_option( "permalink_structure", '/%postname%/' );
    update_option( "enable_xmlrpc", '1' );
    update_option( "display_pnp", '0' );
    update_option( "use_pagination", '1' );
    update_option( "wpsc_products_per_page", '20' );
    update_option( "wpsc_page_number_position", '3' );
    }

    // Turn off the hourly event if we deactivate the plugin.
    function runit_deactivate()
    {
    wp_clear_scheduled_hook( 'runit_hourly' );
    }
    register_activation_hook(__FILE__, 'runit_activate');
    register_deactivation_hook(__FILE__, 'runit_deactivate');

  • Andrew
    • Champion of Loops

    Hiya,

    Really the only difference between the two is how the plugins are loaded. Plugins placed in mu-plugins are automatically loaded and plugins placed in /plugins/ have to be activated.

    The problem with your plugin is that it’s firing function via the activation hooks which are not triggered for plugins in mu-plugins (because plugins are automatically loaded).

    Thanks,

    Andrew

  • drmike
    • DEV MAN’s Mascot

    Andrew, there’s not a work around for thew activation hooks, is there? I know we’re putting the database and option creation commands in the New Blog Default plugin that we use but it would be easier just to change the hook if we can get away with it.

    Always seems like we mistype something when we add lines to NBD.

  • drmike
    • DEV MAN’s Mascot

    Anything that needs to be activated, we just load into the New Blog Defaults plugin, get it done on blog creation and not worry about it:

    http://mu.wordpress.org/forums/topic/10494

    There is code within wp that will check to see if a table has been created and, if not, go ahead and create those tables. Andrew’s Blog Activity plugin is an example of this I believe but in other cases, the wp-shortstat plugin for example, it doesn’t work. We go the New Blog Default method for those.

  • drmike
    • DEV MAN’s Mascot

    It’s really an educational issue that needs to come down from Matt. I think I’ve seen a total of like 3 plugins that use wp’s charset setting when setting up database tables. I see this on other platforms but not many.

    Of course I put all of our servers into UTF8 as a default ages ago. Makes for some damn huge databases and it’s a bitch to export to outside servers if a client leaves but it solves many other problems.