Adding custom links and messages to plugins in WordPress

There are two custom bits of writing plugins that kept evading me. I never found out how to add custom links to the plugin list view, and how to add custom messages to the update prompt. See pic below:

Part of WordPress admin area

The good thing is that as of now, I know where to prod. Ghost's Export link is custom, and I used a very old version of WooCommerce to demonstrate adding custom messages.

For the first bit, you can use the plugin_action_links_(plugin_file_name) filter, pass it the $actions already there, $filename, $plugin_data and $context. Amend $actions (which is an array, add a html link to it), and return the new array. Done.

The second one is an action called in_plugin_update_message-(filename). This is actually not documented in the Codex (heh...). You can find it in wp-admin/includes/update.php:323 (as at WP 3.8.1). There's pretty good documentation in the file itself. Output arbitrary html here.


$filename is used in both instances. It refers to the path of the actual plugin file used from the plugins folder. In the case of WooCommerce, $filename is woocommerce/woocommerce.php, so the action hook becomes in_plugin_update_message-woocommerce/woocommerce.php.