views:

40

answers:

1

I'm working on a WordPress 3.0 multi-site installation. Each new blog will use the same theme with slight modifications (a custom Thesis install, if it matters). I'm trying to automate the set-up process for each new blog as much as possible.

To that end, I'd like to automatically add widgets to my custom sidebars and widget-enabled footers. It'd be even better if the widgets could have pre-set parameters/content, that I or the blog owner could then go into the Widgets panel and edit.

I've searched high and low and haven't been able to figure out a way to make this work. Any and all suggestions are welcome. Thanks so much!

+1  A: 

I have been able to do this by working with schema.php. You can find this file by locating it in wp-admin/includes/schema.php. In this file you will find all the database rows which are installed during installation. Therefore this is a 3-step process.

1)First install one completely correct. Then look at your database and find the rows that it creates. Usually these will be created in the _options table. Then find the schema.php file and scroll to line 320 // 3.0 'page_for_posts' => 0, 'page_on_front' => 0,

2)Follow the same syntax or your entire installation will crash. Then just copy paste from your _options table. The syntax is as follows: page_for_posts="option_name" and 0="option_value".

When you are finished matching all your new rows in the schema.php install a new site. The new site will automatically install all your new rows into the database.

3)(This applies if you are using plugins)Finally, when you are sure you have all the plugins you need. Go back to schema.php and find row 238 'active_plugins' => array(), change array(), to -> (copy and paste row "active_plugins" - the option_value' part)

Therefore all your plugins will be installed instantly when your sites are created.

To summarize...1)finish one site completely 2)Find your new database rows 3)edit schema.php and upgrade.php correctly 4)install a new site.

**as always make sure you backup your site and always TEST TEST TEST

Let me know if this is confusing. I use it for my job and it took me a couple weeks of discover to get this working perfectly. If you have more question and you want to ask me directly you can email me. Look at my bio.

EDIT: You also can automate posts and pages through wp-admin/include/upgrade.php - this way you can install your widgets/widget code on install as well :)

bvandrunen
Thanks so much, @bvandrunen. I'll give that a shot in the next few days. I was really hoping to find a solution that didn't involve hacking the core, but I certainly haven't found anything yet. Widgets are the single biggest annoyance for me when moving a local install up to a live site - re-instating them all by hand and re-creating their settings feels like busywork. I wish there were an 'export/import widgets' function akin to the export/import posts... Ah well. Maybe in 4.0 :-)
McGirl
@McGril, that would be a great function and would have saved myself a great amount of time as well. Let me know if you have questions. For my company I set up a process where we have automated the entire installation process for all new client sites (after installation then we customize it) - but this saves us over an hour or more by having it all done at setup. Hope everything goes well :)
bvandrunen