In this tutorial, we will learn how to add a network settings page for your WordPress theme or plugin, add settings fields to this page, and update these fields.

Add network settings page – register menu

If you haven’t already added settings page for your WordPress theme or plugin in a regular non-multisite install, there are different hooks you can use but the proper one is admin_menu, now for a network you’ll notice that WordPress prefixes most of these hooks with network_ in the beginning and so we will be after network_admin_menu hook to register our page with add_submenu_page function.

Since the title says “settings”, we will be adding our page to settings menu, which has file of settings.php, but you can always add to different parent menus such as sites.php, tools.php, etc. Here’s some class to get us started:

Great! Now if you properly place the above class declaration code into a file and call it, it will register us the custom network admin settings page, which will print out some basic dummy text.

Add network settings page – parse content

From this step we will be after parsing the settings contents and fields to our custom settings page. Now as if you don’t know there is a handy tool for registering and processing custom settings in the WordPress plugin API, but I’ll do this tutorial in the boring way which will consist of basically 1 or 2 fields processed with native PHP and of course WordPress API.

Now that you’re determined to put together couple settings for your admin settings page, it should make sense that these settings should be global (the same on all over the network) since the plugin is network-wide active, unlike when it is active for a given blog where you probably want the settings to be saved just to that blog instance. Therefore, we will be using update_site_option and get_site_option to process/get our settings, which will save the settings to the network meta and therefore they will be global.

Add network settings page – wrap up

Follows the wrap-up of our basic class code used to make 2 example fields of settings, update them and get their settings.