I work in a multisite environment where all of the sites are related. A lot of recent developments have required me to copy and paste certain functions into many different theme folders, which causes problems if I need to update them everywhere.
What would be the best way to have a global “functions.php” file? My thoughts are either to include a file in the themes folder and include it, or create a plugin and network enable the plugin.
What you are looking for is a “MU-Plugin”– “Must-Use Plugin”.. Originally these were called “Multi-User Plugins” and were intended for exactly your purpose– to provide a way for site admins to enable functionality on all sites of an installation.
Create a directory at
/wp-content/mu-plugins/
and put your PHP file(s) in it. WordPress will load the files automatically. MU-PLugins are “are automatically enabled on all sites in the installation” and cannot be deactivated except by physically removing the file.Be sure to read the “Caveats” part of the Codex page.