Outsource this function into a Plugin
If you want a specific function available across multiple themes, it is best to have it in a Plugin, and activate it networkwide.
Find the function
Locate the function in the theme where it is available. You now have two possibilities:
- Delete the function from the current theme
- Make a duplicate of this function to be used for other themes (recommended)
Create the plugin
Create a file in your plugins directory, f711-custom-menu-function.php
or whatever you want your plugin to be called.
Inside this file you create the plugin header:
/*
Plugin Name: F711 Menu Function
Plugin URI: http://yourdomain.com
Description: Using the menu function across different themes in my network
Version: 1.0
Author: Dave_O
Author URI: http://wordpress.stackexchange.com/users/58774/dave-o
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Domain Path: /languages
Text Domain: f711-menu-function
*/
Now your Plugin is ready to use.
Populating your plugin
Copy the menu function of your theme, and give it a specific prefix, for example like this:
function f711_dokan_header_user_menu() {
// insert your functionality from the original function here
}
Activate your plugin
This is selfexplanatory. Just be sure to activate it networkwide
Using it in different themes
Now you can call f711_dokan_header_user_menu()
in all the themes available in your network, using the exact same function.
Cleanup
Take your original theme where the function comes from, and alter the header to use the new plugin function. Afterwards you can remove the old themespecific function to avoid redundancies.