How to generate a WordPress plugin install link How to generate a WordPress plugin install link wordpress wordpress

How to generate a WordPress plugin install link


I've found an answer. In wp-admin/import.php, there's a great example of how this work.

Here is my implementation:

$plugin_name = 'my_plugin_name';$install_link = '<a href="' . esc_url( network_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_name . '&TB_iframe=true&width=600&height=550' ) ) . '" class="thickbox" title="More info about ' . $plugin_name . '">Install ' . $plugin_name . '</a>';

Then just output that link tag anywhere in your admin pages.

If you want to get fancy and add the thickbox modal window effect, just use the function add_thickbox() and attach it to an action that's called in a typical admin request, such as:

add_action('admin_menu', 'my_plugin_add_thickbox');function my_plugin_add_thickbox() {    add_thickbox();}

That should do it!


$action = 'install-plugin';$slug = 'akismet';wp_nonce_url(    add_query_arg(        array(            'action' => $action,            'plugin' => $slug        ),        admin_url( 'update.php' )    ),    $action.'_'.$slug);

Use this. I found this and I am sure it will work.