From 1c8b13ddaaeaa20488e7e8dc9a5a3c03cb8a4111 Mon Sep 17 00:00:00 2001 From: Micah Wood Date: Tue, 28 Nov 2023 14:26:11 -0500 Subject: [PATCH] Update logic for onboarding redirects --- composer.json | 3 +- composer.lock | 41 +++++++++++++++++++++- includes/LoginRedirect.php | 71 ++++++++++++++++++++++++-------------- 3 files changed, 88 insertions(+), 27 deletions(-) diff --git a/composer.json b/composer.json index dab935afe..0482eff52 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,8 @@ "mustache/mustache": "^2.14", "wp-cli/wp-config-transformer": "^1.3", "newfold-labs/wp-module-onboarding-data": "^0.0.7", - "newfold-labs/wp-module-patterns": "^0.1.8" + "newfold-labs/wp-module-patterns": "^0.1.8", + "newfold-labs/wp-module-install-checker": "^1.0" }, "require-dev": { "wp-phpunit/wp-phpunit": "^6.2", diff --git a/composer.lock b/composer.lock index 604eb856d..b6a283718 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8faf86a6d756141200de800ab7eca372", + "content-hash": "c3ac49045042d9c8b527f0d45f30ed64", "packages": [ { "name": "mustache/mustache", @@ -105,6 +105,45 @@ }, "time": "2023-11-13T19:54:44+00:00" }, + { + "name": "newfold-labs/wp-module-install-checker", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/newfold-labs/wp-module-install-checker.git", + "reference": "586485f02a31f598f1d00a7d81acbb58a556cce4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/newfold-labs/wp-module-install-checker/zipball/586485f02a31f598f1d00a7d81acbb58a556cce4", + "reference": "586485f02a31f598f1d00a7d81acbb58a556cce4", + "shasum": "" + }, + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "NewfoldLabs\\WP\\Module\\InstallChecker\\": "src/" + } + }, + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Micah Wood", + "homepage": "https://wpscholar.com" + } + ], + "description": "A module that handles checking a WordPress installation to see if it is a fresh install and to fetch the estimated installation date.", + "support": { + "source": "https://github.com/newfold-labs/wp-module-install-checker/tree/1.0.0", + "issues": "https://github.com/newfold-labs/wp-module-install-checker/issues" + }, + "time": "2023-11-28T01:36:11+00:00" + }, { "name": "newfold-labs/wp-module-installer", "version": "1.1.2", diff --git a/includes/LoginRedirect.php b/includes/LoginRedirect.php index 945a407eb..bb556de48 100644 --- a/includes/LoginRedirect.php +++ b/includes/LoginRedirect.php @@ -1,9 +1,12 @@ get('isFreshInstallation') ) { + update_option( $redirect_option_name, false ); + + return $original_redirect; } - if ( ! $redirect_option ) { + + // 3 - If coming soon is off, then don't redirect (user has launched their site) + if ( ! Data::coming_soon() ) { + update_option( $redirect_option_name, false ); + return $original_redirect; } - // Finally, if we made it this far, then set the redirect URL to point to onboarding - return \admin_url( '/index.php?page=nfd-onboarding' ); + // If we made it here, then set the redirect URL to point to onboarding (and update the database option to prevent future redirects) + update_option( $redirect_option_name, false ); + + return $onboarding_redirect; } /**