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.
Built from https://develop.svn.wordpress.org/trunk@38704


git-svn-id: http://core.svn.wordpress.org/trunk@38647 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2016-10-03 06:42:29 +00:00
parent b570b4b18c
commit bd03add624
4 changed files with 9 additions and 4 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
} );

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-alpha-38703';
$wp_version = '4.7-alpha-38704';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.