Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-plugin-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public static function check_plugin_dependencies_during_ajax() {
);
}

if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
if ( isset( $status['activateUrl'] ) && is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
$status['activateUrl'] = add_query_arg( array( 'networkwide' => 1 ), $status['activateUrl'] );
}

Expand Down
24 changes: 22 additions & 2 deletions tests/phpunit/tests/ajax/wpAjaxCheckPluginDependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ public function test_should_not_return_activate_url_for_user_without_capability(
* Tests that no activation URL is returned for a plugin that is already active.
*
* @ticket 65819
*
* @group ms-excluded
* @ticket 66346
*/
public function test_should_not_return_activate_url_for_active_plugin() {
wp_set_current_user( self::$admin_id );
Expand All @@ -290,6 +289,27 @@ public function test_should_not_return_activate_url_for_active_plugin() {
$this->assertArrayNotHasKey( 'activateUrl', $response['data'], 'No activation URL should be returned.' );
}

/**
* Tests that no activation URL is returned for a plugin that is network-activated.
*
* @ticket 66346
*
* @group ms-required
*/
public function test_should_not_return_activate_url_for_network_active_plugin() {
wp_set_current_user( self::$admin_id );

$this->set_installed_plugins( array( 'dependent/dependent.php' => '' ) );
update_site_option( 'active_sitewide_plugins', array( 'dependent/dependent.php' => time() ) );

$_POST['slug'] = 'dependent';

$response = $this->make_request();

$this->assertTrue( $response['success'], 'The request should succeed.' );
$this->assertArrayNotHasKey( 'activateUrl', $response['data'], 'No activation URL should be returned.' );
}

/**
* Tests that a plugin whose dependencies are all active returns success.
*
Expand Down
Loading