Skip to content

Commit d3afcc4

Browse files
committed
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
1 parent fd5d2a6 commit d3afcc4

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/wp-admin/includes/ajax-actions.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,16 +3619,20 @@ function wp_ajax_install_plugin() {
36193619
}
36203620

36213621
$install_status = install_plugin_install_status( $api );
3622+
$pagenow = isset( $_POST['pagenow'] ) ? sanitize_key( $_POST['pagenow'] ) : '';
3623+
3624+
// If install request is coming from import page, do not return network activation link.
3625+
$plugins_url = ( 'import' === $pagenow ) ? admin_url( 'plugins.php' ) : network_admin_url( 'plugins.php' );
36223626

36233627
if ( current_user_can( 'activate_plugins' ) && is_plugin_inactive( $install_status['file'] ) ) {
36243628
$status['activateUrl'] = add_query_arg( array(
36253629
'_wpnonce' => wp_create_nonce( 'activate-plugin_' . $install_status['file'] ),
36263630
'action' => 'activate',
36273631
'plugin' => $install_status['file'],
3628-
), network_admin_url( 'plugins.php' ) );
3632+
), $plugins_url );
36293633
}
36303634

3631-
if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
3635+
if ( is_multisite() && current_user_can( 'manage_network_plugins' ) && 'import' !== $pagenow ) {
36323636
$status['activateUrl'] = add_query_arg( array( 'networkwide' => 1 ), $status['activateUrl'] );
36333637
}
36343638

src/wp-admin/js/updates.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,7 @@
18761876

18771877
wp.updates.installPlugin( {
18781878
slug: $button.data( 'slug' ),
1879+
pagenow: pagenow,
18791880
success: wp.updates.installImporterSuccess,
18801881
error: wp.updates.installImporterError
18811882
} );

0 commit comments

Comments
 (0)