Action uncanny-continuing-education-credits

in_plugin_update_message-{$file}

Fires after a plugin's update message is retrieved, allowing modification before display.

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

Description

Fires after the plugin update message is generated for a specific plugin file. Developers can use this action to inject custom content, modify the existing update message, or perform actions related to plugin updates before they are displayed to the user.


Usage

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

Parameters

$plugin (mixed)
This parameter represents information about the plugin that has an available update.
$plugin (mixed)
This parameter contains information about the specific plugin for which an update message is being displayed.

Examples

<?php
/**
 * Example: Add a custom message to a specific plugin's update notice.
 *
 * This hook is triggered when WordPress is displaying update messages for a plugin.
 * The {$file} part of the hook name is dynamically replaced with the plugin's file path
 * (e.g., 'my-plugin/my-plugin.php').
 *
 * In this example, we'll target a hypothetical plugin named 'my-custom-updater/my-custom-updater.php'
 * and add a friendly reminder about checking the changelog before updating.
 */
add_action( 'in_plugin_update_message-my-custom-updater/my-custom-updater.php', 'my_custom_plugin_update_message', 10, 2 );

/**
 * Callback function for the in_plugin_update_message hook.
 *
 * @param array $plugin The plugin data.
 * @param object $args   The arguments passed to the hook.
 */
function my_custom_plugin_update_message( $plugin, $args ) {
	// Ensure we have the necessary data and it's not a multisite network admin context
	// where the message might already be handled differently or doesn't need this extra addition.
	if ( ! is_multisite() || ! is_network_admin() ) {
		// Add a specific message before the default "Update now." link.
		echo ' <span style="color: #cc0000; font-weight: bold;">' . esc_html__( 'Please review the changelog before updating.', 'your-text-domain' ) . '</span>';
	}
}
?>

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/includes/EDD_SL_Plugin_Updater.php:327

' %1$s%2$s%3$s',
				'<a target="_blank" class="update-link" href="' . esc_url( wp_nonce_url( $update_link, 'upgrade-plugin_' . $file ) ) . '">',
				esc_html__( 'Update now.', 'easy-digital-downloads' ),
				'</a>'
			);
		}

		do_action( "in_plugin_update_message-{$file}", $plugin, $plugin );

		echo '</p></div></td></tr>';
	}

	/**
	 * Gets the plugins active in a multisite network.
	 *

Scroll to Top