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.
Related Posts:
- Prevent “main” WPMU site_url() being returned in functions
- Implementing DNS Prefetching with WordPress
- Passing variables to templates (alternatives to globalizing variables)
- Different functions file for each site in multisite installation?
- Delete pages and Create default pages for all new network sites
- Multisite, either change the name of sample-page or create new page
- Loop (iterate) through Multi-Site sub-sites (blogs)?
- Defining a global array in functions.php?
- restore_current_blog required after switch_to_blog, if I use that in a function?
- Run function when WordPress new multisite is created or ACF field is updated
- Create a new query in function.php to filter blog posts
- Conditional Gravity Forms filter in WordPress Multisite
- Multisite Ajax serialize return error [object Object]
- Creating new blog on multisite programatically without hacks?
- How to get correct URLs in network wide menu (Multisite)?
- Multisite 404 on pages – rewrite error breaks database
- Has is_archived() for sites in a multisite changed with WP 4.7?
- Function that outputs second theme url
- Passing global variable from header.php to functions.php
- How to Use Global Variables Inside Header and Footer
- dynamic site link for future migration in echo do_shortcode()
- Getting the teaser text without overriding global variables
- wp_get_attachment_image_src returns image on main domain, false on subdomain
- functions.php return custom text
- Dashboard blocker on network multisite for specific user roles
- Members only function, but allow account activation [solved]
- External api call and make global variable for any page visitor enters , page-home, page, single etc
- Competing Login Redirects – Need to be Combined?
- How to access custom class methods from any include without using global
- Adding a class to the body of an inactive site using multisite
- Setting a cookie in functions.php and it gets deleted when working on an other function
- Settings in functions.php used by a plugin
- Run function from parent on child site
- How do I access variables outside a function [closed]
- Ads Only at one website inside multisite network – code error
- Different ads on every website on multisite environment
- Custom User Role not working
- Missing feature image link function
- What’s the difference between home_url() and site_url()
- Remove “Category:”, “Tag:”, “Author:” from the_archive_title
- get_template_directory_uri pointing to parent theme not child theme
- How to customize the_archive_title()?
- How to set and use global variables? Or why not to use them at all
- remove empty paragraphs from the_content?
- What is the “with_front” rewrite key?
- Why use if function_exists?
- How to override parent functions in child themes?
- wp_enqueue_script was called incorrectly
- Add multiple custom fields to the general settings page
- Ajax call always returns 0
- 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
- WordPress Multisite – global categories
- How long does a deprecated function live in core?
- Solution to render Shortcodes in Admin Editor
- How to add a data attribute to a WordPress menu item
- What’s the difference between esc_html, esc_attr, esc_html_e, and so on?
- remove_action on after_setup_theme not working from child theme
- plugins_url vs plugin_dir_url
- Remove type attribute from script and style tags added by WordPress
- How to run a function every 5 minutes?
- Best way of passing PHP variable between partials?
- Upload Multiple Files With media_handle_upload
- How to display custom field in woocommerce orders in admin panel?
- Adding fields to the “Add New User” screen in the dashboard
- Issues with title-tag and document_title_parts
- How do I get the current edit page ID in the admin?
- How to check if a user exists by a given id
- Why isn’t is_page working when I put it in the functions.php file?
- Add tags to the section via functions.php
- Add image size if page template
- How to create a custom order status in woocommerce!
- Remove Actions/Filters added via Anonymous Functions
- Adding a second email address to a completed order in WooCommerce [closed]
- How to load parent_theme functions.php before child_theme?
- How to load scripts/styles specific for a page
- Programatically add options to “add new” custom field dropdown
- Is there any global functions.php file which works for any theme?
- Excluding iPad from wp_is_mobile
- Is there a is_user_logged_in() for multisite?
- When should you, and when should you not, use wp_list_pluck()?
- Get the ID of the page a menu item links to?
- Add container to nav_menu sub menu
- Difference between the_permalink() and get_permalink() function
- What’s the difference between WordPress random_int() and PHP built-in function random_int()?
- Child theme – Overriding ‘require_once’ in functions.php
- Link to user’s profile settings page?
- WordPress Enqueue for homepage only, functions.php, wp-framework
- get php variable from functions php and echo it in theme template files [closed]
- Get menu object from theme_location
- Is it ok to use a function to output the text domain name in a wordpress theme
- Displaying the number of updates available in the Admin area
- Trying to use add_action and do_action with parameters
- Use AJAX in shortcode
- Set JPEG compression for specific custom image sizes
- Can the new 4.8v text widget visual editor be removed?
- Include files in child theme functions file
- Memorizing syntax
- Custom page with variables in url. Nice url with add_rewrite_rule
- Define page template in wp_insert_post
- Which WP functions do you need to use esc_html() or esc_url() on?