This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
network_admin_plugin_action_links_plugin_file filter
The dynamic portion of the hook name, $plugin_file, refers to the path to the plugin file, relative to the plugins directory.
To use the network_admin_plugin_action_links_plugin_file filter, first you have to register it using add_filter. You can write this code into functions.php of your activated theme or in a custom WordPress Plugin.
We at WePlugins, always prefer to create a custom WordPress Plugin while using hooks so nothing breaks when you update your WordPress Theme in the future.
In the below live example, we have defined a function modify_network_admin_plugin_action_links_plugin_file_defaults which takes 4 parameters and we registered using add_filter. The first parameter network_admin_plugin_action_links_plugin_file is the name of the hook, the second parameter modify_network_admin_plugin_action_links_plugin_file_defaults is the name of the function which needs to be called, the third parameter is the priority of calling the hook if the same hook is used multiple times, and the last parameter is the number of arguments (if any) to be passed in the registered function.
Sometimes, you have to remove a registered hook so you can use remove_filter to remove network_admin_plugin_action_links_plugin_file filter.
Parameters
- $actions: (string[]) An array of plugin action links. By default this can include ‘activate’, ‘deactivate’, and ‘delete’.
- $plugin_file: (string) Path to the plugin file relative to the plugins directory.
- $plugin_data: (array) An array of plugin data. See get_plugin_data() and the ‘plugin_row_meta’ filter for the list of possible values.
- $context: (string) The plugin context. By default this can include ‘all’, ‘active’, ‘inactive’, ‘recently_activated’, ‘upgrade’, ‘mustuse’, ‘dropins’, and ‘search’.
Below are the 4 parameters required to use this hook.
Live Examples
Example 1: Basic Usage
Below is an example of how you can use this hook.
function weplugins_modify_network_admin_plugin_action_links_plugin_file_defaults($actions, $plugin_file, $plugin_data, $context) { // Update the $actions variable according to your website requirements and return this variable. // You can modify the $actions variable conditionally too if you want. return $actions; } // add the filter add_filter("network_admin_plugin_action_links_plugin_file", "weplugins_modify_network_admin_plugin_action_links_plugin_file_defaults", 10, 4);
Example 2: Removing a Hook
To remove a hook callback, use the example below.
remove_filter("network_admin_plugin_action_links_plugin_file", "weplugins_modify_network_admin_plugin_action_links_plugin_file_defaults", 10, 4);
Please make sure to provide the same callback function name, priority, and number of arguments while removing the hook callback.
Example 3: Conditional Modification
Sometimes you may want to modify the $actions array based on certain conditions. Here’s how to do it:
function weplugins_modify_network_admin_plugin_action_links_conditionally($actions, $plugin_file, $plugin_data, $context) { if ($plugin_file === 'example-plugin/example-plugin.php') { // Add a custom action link $actions[] = '<a href="admin.php?page=example-settings">Settings</a>'; } return $actions; } // add the filter add_filter("network_admin_plugin_action_links_plugin_file", "weplugins_modify_network_admin_plugin_action_links_conditionally", 10, 4);
Contact Us
If you’re having any trouble using this hook or need customization, please contact us. We’d be happy to assist you.
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.