Import: Fix plugin activation link after installing an importer on multisite.

When installing the importer via Ajax, the activation link should be the same as if the page were reloaded.

Props joelcj91 for initial patch.
Fixes #37943.

git-svn-id: https://develop.svn.wordpress.org/trunk@38704 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler 2016-10-03 06:41:37 +00:00
parent fd5d2a65ad
commit d3afcc4e33
2 changed files with 7 additions and 2 deletions

View File

@ -3619,16 +3619,20 @@ function wp_ajax_install_plugin() {
}
$install_status = install_plugin_install_status( $api );
$pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : '';
// If install request is coming from import page, do not return network activation link.
$plugins_url = ( 'import' === $pagenow ) ? admin_url( 'plugins.php' ) : network_admin_url( 'plugins.php' );
if ( current_user_can( 'activate_plugins' ) && is_plugin_inactive( $install_status['file'] ) ) {
$status['activateUrl'] = add_query_arg( array(
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $install_status['file'] ),
'action' => 'activate',
'plugin' => $install_status['file'],
), network_admin_url( 'plugins.php' ) );
), $plugins_url );
}
if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
if ( is_multisite() && current_user_can( 'manage_network_plugins' ) && 'import' !== $pagenow ) {
$status['activateUrl'] = add_query_arg( array( 'networkwide' => 1 ), $status['activateUrl'] );
}

View File

@ -1876,6 +1876,7 @@
wp.updates.installPlugin( {
slug: $button.data( 'slug' ),
pagenow: pagenow,
success: wp.updates.installImporterSuccess,
error: wp.updates.installImporterError
} );