Would you believe that this is another simple one? Those walks home may be time consuming but I can work through things.
Easiest method to do this is add in additional options to each blog and set up some flags.
Let's say you created a CSS editor and you want to only allow certain folks use it. The first thing you need to do is set up a option record within the blog to make this a option for the blog:
- Open up wp-admin/upgrade-schema.php for editing.
- Go down until you hit the function populate_options.
- See all those add_option lines? What we need to do is add in our own with a default. For example, we'll add in the following line:
add_option('edit_css', 0);
This way when a new blog is created, it will already have the flag set in there to be negative.
But what to do with blogs already created? We're going to have to fake an upgrade.
- Open up wp-includes/version.php for editing.
- See that line that lists the current database version number? Add '1' to it. For example if it's currently 3845, edit it to show as 3846. Be sure to save the file afterwards. (The software checks against the version numbers. If they match, it assumes it's already been done.)
- Open up wp-admin/upgrade-functions.php for editing and go about a third of the way down. You should see a bit like the following:
if ( $wp_current_db_version < 3308 )
upgrade_160();
What we need to do is add our own in there. Since in this case we're just adding in a single add_option we're just take care of it right there and not worry about any other functions.
if ( $wp_current_db_version < 4000 )
add_option( "edit_css", 0 );
Save it afterwards.
- Run the upgrade from the Site Admin menu.
All your blogs should now have this flag set as default.
How to activate this flag? When you get a user who has paid their ten bucks or whatever, just go into Dashboard -> Site Admin -> Blogs -> Find their blog and edit it. Using thte example above, your should now have a field with 'Edit Css' in front of it. Change it to 1 and save.
How to use the flag? In case of a plugin, it's just a matter of wrapping the add_menu lines within a get_option check. For example:
if (get_option("edit_css")) {
add_options_page('Anarchy Options', 'Anarchy', 'manage_options', basename(dirname(__FILE__)) .'/anarchy-options.php', 'anarchy_options_page');
}
Hope this helps,
-drmike