Using WordPress ‘install_plugins_pre_{$tab}’ PHP action

The install_plugins_pre_{$tab} WordPress PHP action fires before each tab on the Install Plugins screen is loaded. The dynamic portion of the hook name, $tab, allows for targeting individual tabs.

Usage

add_action( 'install_plugins_pre_{$tab}', 'your_custom_function' );

function your_custom_function() {
    // your custom code here
}

Parameters

  • $tab (string) – The specific tab name to target.

More information

See WordPress Developer Resources: install_plugins_pre_{$tab}

Examples

Add a custom message before the Featured tab on the Install Plugins screen.

add_action( 'install_plugins_pre_featured', 'show_featured_tab_message' );

function show_featured_tab_message() {
    echo '**Welcome to the Featured plugins tab!**';
}

Add a custom message before the Popular tab on the Install Plugins screen.

add_action( 'install_plugins_pre_popular', 'show_popular_tab_message' );

function show_popular_tab_message() {
    echo '**Check out these popular plugins!**';
}

Add a custom message before the Recommended tab on the Install Plugins screen.

add_action( 'install_plugins_pre_recommended', 'show_recommended_tab_message' );

function show_recommended_tab_message() {
    echo '**These plugins are recommended for you.**';
}

Display a message before the Favorites tab is loaded

Add a custom message before the Favorites tab on the Install Plugins screen.

add_action( 'install_plugins_pre_favorites', 'show_favorites_tab_message' );

function show_favorites_tab_message() {
    echo '**Here are your favorite plugins.**';
}

Display a message before the Upload tab is loaded

Add a custom message before the Upload tab on the Install Plugins screen.

add_action( 'install_plugins_pre_upload', 'show_upload_tab_message' );

function show_upload_tab_message() {
    echo '**You can upload a plugin here.**';
}