Fix error when upgrading

This commit is contained in:
David Stone
2024-12-11 00:23:14 -07:00
parent 93fdbf2153
commit 8dfce69d31
2 changed files with 37 additions and 35 deletions

View File

@ -2,10 +2,8 @@
// WP Ultimo Starts # // WP Ultimo Starts #
/** /**
* WP Multisite WaaS Sunrise * WP Multisite WaaS Sunrise
* Plugin URI: https://wpultimo.com * Plugin URI: https://wpmultisitewaas.org
* Version: 2.0.0.6 * Version: 2.0.0.7
* Author: Arindo Duque
* Author URI: https://wpultimo.com
* License: GPLv2 * License: GPLv2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html * License URI: http://www.gnu.org/licenses/gpl-2.0.html
* *

View File

@ -35,25 +35,27 @@
// Exit if accessed directly // Exit if accessed directly
defined('ABSPATH') || exit; defined('ABSPATH') || exit;
if (!defined('WP_ULTIMO_PLUGIN_FILE')) { if ( defined('WP_SANDBOX_SCRAPING') && WP_SANDBOX_SCRAPING ) {
define('WP_ULTIMO_PLUGIN_FILE', __FILE__); require_once ABSPATH . 'wp-admin/includes/plugin.php';
} elseif ( WP_ULTIMO_PLUGIN_FILE !== __FILE__) { if ( is_plugin_active( 'wp-ultimo/wp-ultimo.php' ) ) {
return; // Different plugin loaded. // 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;
} }
}
// Check if old name is installed and we should upgrade. // Check if old name is installed and we should upgrade.
if ( function_exists('is_plugin_active') && is_plugin_active( 'wp-ultimo/wp-ultimo.php' ) ) { 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); deactivate_plugins( 'wp-ultimo/wp-ultimo.php', true, true);
add_action(
'admin_notices', wp_admin_notice( __( 'The WP Ultimo plugin has been deactivated because it conflicts with WP Multisite WaaS', 'wp-ultimo' ), array(
function() { 'id' => 'message',
echo '<div class="error"><p>'; 'additional_classes' => array( 'updated' ),
echo esc_html__( 'The WP Multisite WaaS plugin has been deactivated as it has been renamed WP Multisite WaaS', 'wp-ultimo' ); 'dismissible' => true,
echo '</p></div>'; ) );
} if ( defined('SUNRISE') && SUNRISE && file_exists(WP_CONTENT_DIR . '/sunrise.php')) {
);
if ( defined('SUNRISE' && SUNRISE) && file_exists(WP_CONTENT_DIR . '/sunrise.php')) {
$possible_sunrises = array( $possible_sunrises = array(
WP_PLUGIN_DIR . '/wp-multisite-waas/sunrise.php', WP_PLUGIN_DIR . '/wp-multisite-waas/sunrise.php',
WPMU_PLUGIN_DIR . '/wp-multisite-waas/sunrise.php', WPMU_PLUGIN_DIR . '/wp-multisite-waas/sunrise.php',
@ -70,15 +72,16 @@ if ( function_exists('is_plugin_active') && is_plugin_active( 'wp-ultimo/wp-ulti
if ( ! $copy_results ) { if ( ! $copy_results ) {
continue; continue;
} }
wu_log_add( 'sunrise', __( 'Sunrise upgrade attempt succeeded.', 'wp-ultimo' ) );
break; break;
} }
return; return;
} }
} }
if (!defined('WP_ULTIMO_PLUGIN_FILE')) {
define('WP_ULTIMO_PLUGIN_FILE', __FILE__);
}
/** /**
* Require core file dependencies * Require core file dependencies
*/ */
@ -102,20 +105,21 @@ WP_Ultimo\Autoloader::init();
*/ */
WP_Ultimo\Hooks::init(); WP_Ultimo\Hooks::init();
if ( ! function_exists('WP_Ultimo')) {
/** /**
* Initializes the WP Ultimo class * Initializes the WP Ultimo class
* *
* This function returns the WP_Ultimo class singleton, and * This function returns the WP_Ultimo class singleton, and
* should be used to avoid declaring globals. * should be used to avoid declaring globals.
* *
* @since 2.0.0
* @return WP_Ultimo * @return WP_Ultimo
* @since 2.0.0
*/ */
function WP_Ultimo() { // phpcs:ignore function WP_Ultimo() { // phpcs:ignore
return WP_Ultimo::get_instance(); return WP_Ultimo::get_instance();
} // end WP_Ultimo; } // end WP_Ultimo;
}
// Initialize and set to global for back-compat // Initialize and set to global for back-compat
$GLOBALS['WP_Ultimo'] = WP_Ultimo(); $GLOBALS['WP_Ultimo'] = WP_Ultimo();