Skip to content

Instantly share code, notes, and snippets.

@rayhanuddin2019
Last active October 5, 2022 11:47
Show Gist options
  • Save rayhanuddin2019/c1053b96b5d1b67bfda9963eb9cb43f0 to your computer and use it in GitHub Desktop.
Save rayhanuddin2019/c1053b96b5d1b67bfda9963eb9cb43f0 to your computer and use it in GitHub Desktop.
manual plugin install
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=automatic-youtube-gallery' ), 'install-plugin_automatic-youtube-gallery' );
Below you’ll find a function that generates a plugin install link for WordPress. You can use this in the dashboard. This link acts the same way as the “Install plugin” buttons when searching for plugins within WordPress.
$url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin={plugin_slug}' ), 'install-plugin_{plugin_slug}' );
----------------- Second solution -------------------
$action = 'install-plugin';
$slug = 'akismet';
$url = wp_nonce_url(
add_query_arg(
array(
'action' => $action,
'plugin' => $slug
),
admin_url( 'update.php' )
),
$action.'_'.$slug
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment