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

How to use in_plugin_update_message-file action in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
May 20, 2023
5 minutes read

WordPress hooks are like magical spells that allow us to extend and modify the default behavior of WordPress without touching the core files. One such hook is the in_plugin_update_message-file action. It’s a dynamic hook used to add custom update messages for plugins in the WordPress admin area. Let’s explore how to use this hook effectively.

Example 1: Display Custom Update Message

Sometimes, you might want to display a custom message when a plugin update is available. Here’s how you can do it.

    function weplugins_plugin_update_message( $plugin_data, $new_data ) {
        if ( isset( $plugin_data['update'] ) && $plugin_data['update'] && isset( $new_data->upgrade_notice ) ) {
            printf(
                '<div class="update-message"><p><strong>%s</strong>: %s</p></div>',
                $new_data->new_version,
                wpautop( $new_data->upgrade_notice )
            );
        }
    }
    add_action( 'in_plugin_update_message-my-plugin-name/my-plugin-name.php', 'weplugins_plugin_update_message', 10, 2 );
    

Example 2: Execute Custom Functionality on Update Message

In this example, we define a function to execute custom functionality whenever the update message is triggered.

    function weplugins_execute_on_in_plugin_update_message_file_event($plugin_data, $response){
        // Your custom code to execute during the update message event.
    }
    add_action( "in_plugin_update_message-file", "weplugins_execute_on_in_plugin_update_message_file_event" , 10, 2);
    

Example 3: Remove a Hook Callback

If you need to remove a previously registered hook, here’s how you can achieve that.

    remove_action( "in_plugin_update_message-file", "weplugins_execute_on_in_plugin_update_message_file_event", 10, 2 );
    

Ensure that you provide the same callback function name, priority, and number of arguments when removing the hook callback.

Access Premium WordPress Plugins

If you need any customization or face any issues using this hook, feel free to Contact Us. Our team at WePlugins is always ready to assist you.

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.