Filter
uncanny-automator
uap_in_plugin_update_message
Filters the update message displayed for the plugin, allowing customization of the upgrade notice.
add_filter( 'uap_in_plugin_update_message', $callback, 10, 2 );
Description
Fires before an upgrade notice message is displayed for Uncanny Automator. Developers can filter the `$upgrade_notice` string to modify or entirely replace the default message, allowing for custom update notifications or promotional content directly within the WordPress plugin update screen.
Usage
add_filter( 'uap_in_plugin_update_message', 'your_function_name', 10, 2 );
Parameters
-
$upgrade_notice(mixed) - This parameter holds the upgrade notice message for the plugin.
-
$args(mixed) - This parameter holds the HTML content that will be displayed as an upgrade notice for the plugin.
Return Value
The filtered value.
Examples
// Example: Add a custom class to the upgrade notice if a specific condition is met.
add_filter( 'uap_in_plugin_update_message', 'my_custom_automator_upgrade_notice', 10, 2 );
function my_custom_automator_upgrade_notice( $upgrade_notice, $args ) {
// Check if the $args contains information about a specific plugin or version.
// For demonstration purposes, let's assume $args might contain a 'plugin_name' key.
if ( isset( $args['plugin_name'] ) && 'uncanny-automator-pro' === $args['plugin_name'] ) {
// Append a custom class to the upgrade notice div.
// We need to ensure we're modifying the correct part of the HTML.
// The existing logic wraps the upgrade notice in <p> tags.
// We'll assume $upgrade_notice is the string generated by the plugin.
// A safer approach might involve DOM manipulation if the structure was more complex,
// but for simple string modification, this is feasible.
// Find the div with class 'ua_plugin_upgrade_notice' and add a class.
$modified_notice = str_replace(
'<div class="ua_plugin_upgrade_notice">',
'<div class="ua_plugin_upgrade_notice my-custom-upgrade-highlight">',
$upgrade_notice
);
return $modified_notice;
}
// If the condition is not met, return the original upgrade notice.
return $upgrade_notice;
}
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/class-automator-load.php:621
public function in_plugin_update_message( $args, $response ) {
$upgrade_notice = '';
if ( isset( $response->upgrade_notice ) && ! empty( $response->upgrade_notice ) ) {
$upgrade_notice .= '<div class="ua_plugin_upgrade_notice">';
$upgrade_notice .= sprintf( '<strong>%s</strong>', esc_html__( 'Heads up!', 'uncanny-automator' ) );
$upgrade_notice .= preg_replace( '~[([^]]*)](([^)]*))~', '<a href="${2}">${1}</a>', $response->upgrade_notice );
$upgrade_notice .= '</div>';
}
echo wp_kses_post(
apply_filters(
'uap_in_plugin_update_message',
$upgrade_notice ? '</p>' . wp_kses_post( $upgrade_notice ) . '<p class="dummy">' : '',
$args
)
);
}