| @@ -8,11 +8,14 @@ | ||
| 8 | 8 | |
| 9 | 9 | defined('ABSPATH') || die('No direct access.'); |
| 10 | 10 | |
| 11 | 11 | use Extendify\Agent\Controllers\ChatHistoryController; |
| 12 | +use Extendify\PartnerData; | |
| 12 | 13 | use Extendify\Shared\DataProvider\ResourceData; |
| 13 | 14 | use Extendify\Shared\Services\AutoUpdate\AutoUpdate; |
| 15 | +use Extendify\Shared\Services\LaunchUpdate\LaunchUpdater; | |
| 14 | 16 | use Extendify\Shared\Services\Sanitizer; |
| 17 | +use Extendify\SiteVisibility; | |
| 15 | 18 | |
| 16 | 19 | /** |
| 17 | 20 | * The controller for interacting with WordPress. |
| 18 | 21 | */ |
| @@ -156,9 +159,16 @@ | ||
| 156 | 159 | \update_option('extendify_check_for_image_imports', true, false); |
| 157 | 160 | \delete_transient('extendify_import_images_check_delay'); |
| 158 | 161 | |
| 159 | 162 | \update_option('extendify_onboarding_completed', gmdate('Y-m-d\TH:i:s\Z')); |
| 163 | + // Anything already in the chat reads as an onboarding offer the user answered. | |
| 164 | + ChatHistoryController::clear(); | |
| 165 | + LaunchUpdater::clearAttempts(); | |
| 160 | 166 | |
| 167 | + if (PartnerData::setting('useComingSoon')) { | |
| 168 | + SiteVisibility::markUnpublished(); | |
| 169 | + } | |
| 170 | + | |
| 161 | 171 | \do_action('extendify_after_launch'); |
| 162 | 172 | |
| 163 | 173 | return new \WP_REST_Response('ok'); |
| 164 | 174 | } |
| @@ -163,23 +173,43 @@ | ||
| 163 | 173 | return new \WP_REST_Response('ok'); |
| 164 | 174 | } |
| 165 | 175 | |
| 166 | 176 | /** |
| 167 | - * Runs every time the launch page loads: resets launch state (a no-op on a | |
| 168 | - * fresh site, the expected reset on an existing one) and enables auto-updates. | |
| 177 | + * Apply pending theme / PUC-plugin upgrades before Launch runs (see | |
| 178 | + * LaunchUpdater::run, which never throws). | |
| 169 | 179 | * |
| 170 | 180 | * @return \WP_REST_Response |
| 171 | 181 | */ |
| 182 | + public static function runUpdates() | |
| 183 | + { | |
| 184 | + return new \WP_REST_Response(LaunchUpdater::run()); | |
| 185 | + } | |
| 186 | + | |
| 187 | + /** | |
| 188 | + * Runs on every launch page load, so it must not discard site state. | |
| 189 | + * | |
| 190 | + * @return \WP_REST_Response | |
| 191 | + */ | |
| 172 | 192 | public static function preLaunch() |
| 173 | 193 | { |
| 174 | - \delete_option('extendify_onboarding_completed'); | |
| 175 | - ChatHistoryController::clear(); | |
| 176 | - | |
| 177 | 194 | if (AutoUpdate::isEnabled()) { |
| 178 | 195 | AutoUpdate::enableAutoUpdateForPlugin(EXTENDIFY_PLUGIN_BASENAME); |
| 179 | 196 | AutoUpdate::addToAutoUpdateList('auto_update_themes', 'extendable'); |
| 180 | 197 | AutoUpdate::enableAutoUpdateForCore(); |
| 181 | 198 | } |
| 199 | + | |
| 200 | + return new \WP_REST_Response(['success' => true]); | |
| 201 | + } | |
| 202 | + | |
| 203 | + /** | |
| 204 | + * Discards the launched state after the user confirms the restart. | |
| 205 | + * | |
| 206 | + * @return \WP_REST_Response | |
| 207 | + */ | |
| 208 | + public static function resetLaunchState() | |
| 209 | + { | |
| 210 | + \delete_option('extendify_onboarding_completed'); | |
| 211 | + ChatHistoryController::clear(); | |
| 182 | 212 | |
| 183 | 213 | return new \WP_REST_Response(['success' => true]); |
| 184 | 214 | } |
| 185 | 215 | } |