Skip to content

Commit

Permalink
feat: add onboarding redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
HardeepAsrani committed Aug 19, 2024
1 parent 1c5a6b4 commit aa1067a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions assets/js/src/welcome-notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function handleWelcomeNotice( $ ) {
installing,
done,
activationUrl,
onboardingUrl,
ajaxUrl,
nonce,
otterRefNonce,
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions inc/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down Expand Up @@ -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';
}
Expand Down

0 comments on commit aa1067a

Please sign in to comment.