Generating a WordPress plugin installation link url

Last in a series of functions that might prove useful to me in the future is the one to generate a valid WordPress plugin installation url like the one found in thePlugin > Add New search results screen [caption id=“attachment_1110” align=“aligncenter” width=“1024”]Installation link Installation link[/caption] I’ve used the function in a contextualized form to generate an helpful die message for a plugin missing requirements.

 * Generate an installation URL for a plugin like the ones found on the Add New Plugin search results screen.
 * @param  string $pluginSlug The plugin slug (e.g. "Hello Dolly" plugin slug is "hello-dolly")
 * @return string             The plugin installation url
function generatePluginInstallationLinkUrl($pluginSlug)
    $installUrl = admin_url('update.php?action=install-plugin&plugin=' . $pluginSlug);
    $installUrl = wp_nonce_url($installUrl, 'install-plugin_' . $pluginSlug);

    return $installUrl;

The function is stored in a gist for convenience.