Action
uncanny-automator-pro
in_plugin_update_message-{$file}
Fires after a plugin has been updated, allowing custom messages to be displayed for specific plugin files.
add_action( 'in_plugin_update_message-{$file}', $callback, 10, 2 );
Description
Fires after the plugin update message is generated and before it's displayed for a specific plugin. Developers can use this hook to modify or extend the update message content, such as adding custom links or information. It's called for each plugin with an available update.
Usage
add_action( 'in_plugin_update_message-{$file}', 'your_function_name', 10, 2 );
Parameters
-
$plugin(mixed) - This parameter contains information about the plugin being updated.
-
$plugin(mixed) - This parameter contains information about the plugin being updated, including its current and new versions, and details about the update.
Examples
add_action( 'in_plugin_update_message-uncanny-automator-pro/uncanny-automator-pro.php', 'my_custom_plugin_update_message', 10, 2 );
/**
* Adds a custom message to the Uncanny Automator Pro update notification.
*
* This function demonstrates how to hook into the 'in_plugin_update_message-{$file}'
* action to add custom content to the plugin update messages displayed in the
* WordPress admin area.
*
* @param object $plugin The plugin data object. In this context, it's the data for Uncanny Automator Pro.
* @param object $plugin_info Duplicate of $plugin, provided by the hook.
*/
function my_custom_plugin_update_message( $plugin, $plugin_info ) {
// Check if it's a major version update to display a more prominent message.
// This requires fetching the currently installed version and the new version.
// For simplicity, let's assume we're targeting a specific version change.
$installed_version = get_site_transient( 'update_plugins' )->response['uncanny-automator-pro/uncanny-automator-pro.php']->new_version ?? '0.0.0';
$new_version = $plugin_info->new_version ?? '0.0.0';
// A very basic check for a major version increase (e.g., 2.x.x to 3.x.x)
if ( version_compare( $installed_version, $new_version, '<' ) && substr( $new_version, 0, 1 ) !== substr( $installed_version, 0, 1 ) ) {
echo '<p style="background-color: #ffffe0; border-left: 4px solid #ffec3d; padding: 10px; margin-bottom: 15px;">';
echo '<strong>Important: Major Update Available!</strong> ';
echo 'This is a significant release. Please review the <a href="https://uncannyautomator.com/blog/uncanny-automator-pro-version-history/" target="_blank">release notes</a> before updating.';
echo '</p>';
} else {
// For minor updates, you might add a quick tip or highlight a key feature.
echo '<p style="background-color: #e0ffe0; border-left: 4px solid #3dff3d; padding: 10px; margin-bottom: 15px;">';
echo '<strong>New in this version:</strong> Enjoy performance improvements and bug fixes. Check out the <a href="https://uncannyautomator.com/changelog/uncanny-automator-pro/" target="_blank">full changelog</a> for details.';
echo '</p>';
}
}
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
uncanny-automator-pro/src/core/admin/licensing/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.
*