denied_caps(), true ) ) { return $caps; } if ( is_multisite() && is_super_admin( $user_id ) ) { return $caps; } if ( 'install_plugins' === $cap && $this->is_details_view() ) { return $caps; } return array( 'do_not_allow' ); } /** * Whether this request only displays plugin details. * * @return bool */ private function is_details_view() { global $pagenow; if ( ! is_admin() || 'plugin-install.php' !== $pagenow ) { return false; } $method = isset( $_SERVER['REQUEST_METHOD'] ) ? strtoupper( sanitize_key( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only routing check. $tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : ''; return 'GET' === $method && 'plugin-information' === $tab; } }