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!