Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use install_plugins_nonmenu_tabs filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
February 3, 2023
5 minutes read

Welcome to the world of WordPress hooks! Today, we’re diving into the **install_plugins_nonmenu_tabs** filter. This filter is used to tweak the tabs on the Add Plugins screen that aren’t tied to any menu item. Let’s get started!

To use the `install_plugins_nonmenu_tabs` filter, you first need to register it using `add_filter`. You can place this code in the `functions.php` file of your active theme or in a custom WordPress plugin. Creating a custom plugin is always a good practice because it keeps your changes intact even when you update your theme.

Below, we have three live examples to help you understand how to use this hook effectively.

Example 1: Basic Usage

In this example, we define a function `weplugins_modify_install_plugins_nonmenu_tabs_defaults` that takes one parameter. We register this function using `add_filter`. The first parameter is the name of the hook (`install_plugins_nonmenu_tabs`), the second is the function name (`weplugins_modify_install_plugins_nonmenu_tabs_defaults`), the third is the priority, and the last is the number of arguments.

function weplugins_modify_install_plugins_nonmenu_tabs_defaults($nonmenu_tabs) { 
    // Update the $nonmenu_tabs variable according to your requirements and return it.
    return $nonmenu_tabs; 
}
// Add the filter
add_filter('install_plugins_nonmenu_tabs', 'weplugins_modify_install_plugins_nonmenu_tabs_defaults', 10, 1);

Example 2: Conditional Modification

In this example, the function conditionally modifies the `$nonmenu_tabs` variable.

function weplugins_modify_install_plugins_nonmenu_tabs_conditionally($nonmenu_tabs) { 
    // Modify the $nonmenu_tabs variable conditionally
    if (is_admin()) {
        $nonmenu_tabs[] = 'new_tab';
    }
    return $nonmenu_tabs; 
}
// Add the filter
add_filter('install_plugins_nonmenu_tabs', 'weplugins_modify_install_plugins_nonmenu_tabs_conditionally', 10, 1);

Example 3: Removing the Hook

Sometimes, you need to remove a registered hook. You can use `remove_filter` to achieve this. Make sure to provide the same callback function name, priority, and number of arguments.

function weplugins_modify_install_plugins_nonmenu_tabs_defaults($nonmenu_tabs) { 
    return $nonmenu_tabs; 
}
// Add the filter
add_filter('install_plugins_nonmenu_tabs', 'weplugins_modify_install_plugins_nonmenu_tabs_defaults', 10, 1);

// Remove the filter
remove_filter('install_plugins_nonmenu_tabs', 'weplugins_modify_install_plugins_nonmenu_tabs_defaults', 10, 1);

Access Premium WordPress Plugins

Parameters:

    Below is the parameter required to use this hook:

  • $nonmenu_tabs : (string[]) The tabs that don’t have a menu item on the Add Plugins screen.

Contact Us

If you need any customization or run into any issues, feel free to contact us. Our team at WePlugins is always ready to help you out!

Sandeep Kumar Mishra

Sandeep Kumar Mishra

Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.

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.