Using WordPress ‘in_plugin_update_message-{$file}’ PHP action

The in_plugin_update_message-{$file} WordPress PHP action fires at the end of the update message container in each row of the plugins list table. The dynamic portion of the hook name, $file, refers to the path of the plugin’s primary file relative to the plugins directory.

Usage

add_action('in_plugin_update_message-{$file}', 'my_custom_function', 10, 2);

function my_custom_function($plugin_data, $response) {
    // your custom code here
}

Parameters

  • $plugin_data (array) – An array of plugin metadata. See get_plugin_data() and the ‘plugin_row_meta’ filter for the list of possible values.
  • $response (object) – An object of metadata about the available plugin update, including plugin ID, slug, basename, new version, URL, package URL, icons, banners, RTL banners, required WordPress version, tested WordPress version, and required PHP version.

More information

See WordPress Developer Resources: in_plugin_update_message-{$file}

Examples

Note: Make sure to replace my-plugin-name/my-plugin-name.php with the actual path of your plugin’s primary file relative to the plugins directory.

Display an upgrade notice message

Display an upgrade notice message just after the new version message.

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

Display a custom update message

Display a custom message below the plugin update information in the plugins list table.

add_action('in_plugin_update_message-my-plugin-name/my-plugin-name.php', 'custom_update_message', 10, 2);

function custom_update_message($plugin_data, $response) {
    echo '<br><strong>Note:</strong> Please backup your database before updating.';
}

Display the required PHP version

Show the required PHP version in the update message.

add_action('in_plugin_update_message-my-plugin-name/my-plugin-name.php', 'display_required_php_version', 10, 2);

function display_required_php_version($plugin_data, $response) {
    echo '<br><strong>Required PHP Version:</strong> ' . $response->requires_php;
}

Display compatibility information

Show compatibility information based on the tested WordPress version.

add_action('in_plugin_update_message-my-plugin-name/my-plugin-name.php', 'display_compatibility_info', 10, 2);

function display_compatibility_info($plugin_data, $response) {
    $tested = $response->tested;
    echo '<br><strong>Compatibility:</strong> This plugin has been tested up to WordPress ' . $tested;
}

Display a warning if the current PHP version is not supported

Show a warning message if the current PHP version is not supported by the plugin update.

add_action('in_plugin_update_message-my-plugin-name/my-plugin-name.php', 'php_version_warning', 10, 2);

function php_version_warning($plugin_data, $response) {
    if (version_compare(PHP_VERSION, $response->requires_php, '<')) {
        echo '<br><strong>Warning:</strong> Your PHP version is not supported. Please update PHP before updating this plugin.';
    }
}

Display a custom message if the plugin is not tested with the current WordPress version

Show a custom message if the plugin update has not been tested with the current WordPress version.

add_action('in_plugin_update_message-my-plugin-name/my-plugin-name.php', 'untested_wordpress_warning', 10, 2);

function untested_wordpress_warning($plugin_data, $response) {
    if (version_compare(get_bloginfo('version'), $response->tested, '>')) {
        echo '<br><strong>Warning:</strong> This plugin update has not been tested with your current WordPress version. Proceed with caution.';
    }
}