From f4fd3e5c8c1f8c33e3e21c59f34383f2efa8593b Mon Sep 17 00:00:00 2001
From: David Stone <david@nnucomputerwhiz.com>
Date: Mon, 16 Dec 2024 22:48:12 -0700
Subject: [PATCH] Avoid IO with every request

---
 wp-multisite-waas.php | 42 +++++++-----------------------------------
 1 file changed, 7 insertions(+), 35 deletions(-)

diff --git a/wp-multisite-waas.php b/wp-multisite-waas.php
index d418c1b..860282e 100644
--- a/wp-multisite-waas.php
+++ b/wp-multisite-waas.php
@@ -5,8 +5,8 @@
  * Plugin URI: https://wpmultisitewaas.org
  * Text Domain: wp-ultimo
  * Version: 2.3.3
- * Author: Arindo Duque & NextPress
- * Author URI: https://nextpress.co/
+ * Author: WP Multisite Community
+ * Author URI: https://github.com/superdav42/wp-multisite-waas
  * Network: true
  * License: GPL2
  * License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -39,40 +39,12 @@ if ( defined('WP_SANDBOX_SCRAPING') && WP_SANDBOX_SCRAPING ) {
 	require_once ABSPATH . 'wp-admin/includes/plugin.php';
 	if ( is_plugin_active( 'wp-ultimo/wp-ultimo.php' ) ) {
 		// old plugin still installed and active with the old name and path
-		// and the user is trying to activate this plugin. We must return here, or we'll get name conflicts.
-		return;
-	}
+		// and the user is trying to activate this plugin. So deactivate and return.
+		deactivate_plugins( 'wp-ultimo/wp-ultimo.php', true, true);
 
-}
-
-// Check if old name is installed and we should upgrade.
-require_once ABSPATH . 'wp-admin/includes/plugin.php';
-if ( is_plugin_active( 'wp-ultimo/wp-ultimo.php' ) ) {
-	deactivate_plugins( 'wp-ultimo/wp-ultimo.php', true, true);
-
-	wp_admin_notice( __( 'The WP Ultimo plugin has been deactivated because it conflicts with WP Multisite WaaS', 'wp-ultimo' ),  array(
-		'id'                 => 'message',
-		'additional_classes' => array( 'updated' ),
-		'dismissible'        => true,
-	) );
-	if ( file_exists(WP_CONTENT_DIR . '/sunrise.php')) {
-		$possible_sunrises = array(
-			WP_PLUGIN_DIR . '/wp-multisite-waas/sunrise.php',
-			WPMU_PLUGIN_DIR . '/wp-multisite-waas/sunrise.php',
-		);
-
-		foreach ( $possible_sunrises as $new_file ) {
-
-			if ( ! file_exists( $new_file ) ) {
-				continue;
-			}
-
-			$copy_results = @copy( $new_file, WP_CONTENT_DIR . '/sunrise.php' ); // phpcs:ignore
-
-			if ( ! $copy_results ) {
-				continue;
-			}
-			break;
+		if ( file_exists(WP_CONTENT_DIR . '/sunrise.php')) {
+			// We must override the old sunrise file or more name conflicts will occur.
+			copy(__DIR__ . '/sunrise.php', WP_CONTENT_DIR . '/sunrise.php');
 		}
 		return;
 	}