From aa1067a3fd0c76f00da383a8df04d1348571b344 Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Mon, 19 Aug 2024 19:00:47 +0530 Subject: [PATCH] feat: add onboarding redirection --- assets/js/src/welcome-notice.js | 7 +++++++ inc/Admin.php | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/assets/js/src/welcome-notice.js b/assets/js/src/welcome-notice.js index df170f8..6d3ff4e 100644 --- a/assets/js/src/welcome-notice.js +++ b/assets/js/src/welcome-notice.js @@ -8,6 +8,7 @@ function handleWelcomeNotice( $ ) { installing, done, activationUrl, + onboardingUrl, ajaxUrl, nonce, otterRefNonce, @@ -41,12 +42,18 @@ function handleWelcomeNotice( $ ) { installSpinner.addClass( 'dashicons-yes' ); installText.text( done ); setTimeout( hideAndRemoveNotice, 1500 ); + window.location.href = onboardingUrl; }; $( installBtn ).on( 'click', async () => { installSpinner.removeClass( 'hidden' ); installBtn.attr( 'disabled', true ); + if ( otterStatus === 'active' ) { + window.location.href = onboardingUrl; + return; + } + if ( otterStatus === 'installed' ) { await activateOtter(); return; diff --git a/inc/Admin.php b/inc/Admin.php index b56eb3a..41010d3 100644 --- a/inc/Admin.php +++ b/inc/Admin.php @@ -278,6 +278,14 @@ public function render_welcome_notice() { admin_url( 'plugins.php' ) ) ), + 'onboardingUrl' => esc_url( + add_query_arg( + array( + 'onboarding' => 'true', + ), + admin_url( 'site-editor.php' ) + ) + ), 'activating' => __( 'Activating', 'neve-fse' ) . '…', 'installing' => __( 'Installing', 'neve-fse' ) . '…', 'done' => __( 'Done', 'neve-fse' ), @@ -429,6 +437,10 @@ private function should_show_welcome_notice(): bool { private function get_otter_status(): string { $status = 'not-installed'; + if ( is_plugin_active( 'otter-blocks/otter-blocks.php' ) ) { + return 'active'; + } + if ( file_exists( ABSPATH . 'wp-content/plugins/otter-blocks/otter-blocks.php' ) ) { return 'installed'; }