How to display a message about updates in the plugin list

Problems with you code:

  1. You don’t need to check for $pagenow, that action will only fire in the Plugins screen.

  2. The action takes two arguments, present in your callback function, but absent in the action declaration. If you had WP_DEBUG enabled, you’d have seen the notice.

  3. An action hook doesn’t return values, you do your stuff and that’s all.

Working code:

$file   = basename( __FILE__ );
$folder = basename( dirname( __FILE__ ) );
$hook = "in_plugin_update_message-{$folder}/{$file}";
add_action( $hook, 'your_update_message_cb', 10, 2 ); // 10:priority, 2:arguments #

function your_update_message_cb( $plugin_data, $r )
{
    echo 'Hello World';
}

Of course, this hook doesn’t work if the plugin is inactive.