‘Global’ settings page for multisite plugin

I’m working on a plugin that will be installed in a multisite instance.

How do I create a single settings page that is visible at the “Network admin” level only – most of the guides i’ve seen relate to a standard blog level plugin. Any links to information would be useful, otherwise I’ll just end up going through sitewide tags to see how it’s being done there.

[Update]

Looks like sitewide_tags uses add_site_option, get_site_option and update_site_option, and these functions use wp_sitemeta. However, from what I can see, there’s no support for register_setting, add_setting, etc, so you have to get and set your options manually.

4

As a reference

To create network or global settings, you need to do the following

  • Add a settings page

    add_submenu_page( 'settings.php'... # cf options.php for blog level`
    
  • Add a global option

    add_site_option($key,$value)
    
  • Update a global option

    update_site_option($key,$value)
    
  • Get a site option

    get_site_option($key)
    

Global settings are saved to the sitemeta table (individual blog settings are saved to <blog_id>_options table

  • I think the Settings API functions at the blog level – so uses the options table, not sitemeta. So, you can’t use option groups and the like at the network level (please comment if I’ve got this wrong)

Leave a Comment