Skip to content

Commit

Permalink
Update notice
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Nov 30, 2023
1 parent 1bff20e commit 7e270a9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
6 changes: 6 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 @@ -47,6 +48,11 @@ function handleWelcomeNotice( $ ) {
installSpinner.removeClass( 'hidden' );
installBtn.attr( 'disabled', true );

if ( otterStatus === 'active' ) {
window.location.href = onboardingUrl;
return;
}

if ( otterStatus === 'installed' ) {
await activateOtter();
return;
Expand Down
42 changes: 35 additions & 7 deletions inc/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,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', 'raft' ) . '…',
'installing' => __( 'Installing', 'raft' ) . '…',
'done' => __( 'Done', 'raft' ),
Expand All @@ -86,23 +94,30 @@ public function render_welcome_notice() {

$notice_html .= '<h1 class="notice-title">';
/* translators: %s: Otter Blocks */
$notice_html .= sprintf( __( 'Power up your website building experience with %s!', 'raft' ), '<span>Otter Blocks</span>' );
$notice_html .= sprintf( __( 'Get started with Raft in minutes, with %s', 'raft' ), '<span>Otter\'s FSE Onboarding</span>' );

$notice_html .= '</h1>';

$notice_html .= '<p class="description">' . __( 'Otter is a Gutenberg Blocks page builder plugin that adds extra functionality to the WordPress Block Editor (also known as Gutenberg) for a better page building experience without the need for traditional page builders.', 'raft' ) . '</p>';
$notice_html .= '<p class="description">' . __( 'Change your site’s appearance, setup your templates, add new pages and much more, with Otter’s innovative Onboarding process.', 'raft' ) . '</p>';

$notice_html .= '<div class="actions">';

/* translators: %s: Otter Blocks */
$notice_html .= '<button id="raft-install-otter" class="button button-primary button-hero">';
$notice_html .= '<span class="dashicons dashicons-update hidden"></span>';
$notice_html .= '<span class="text">';
$notice_html .= 'installed' === $otter_status ?

if ( 'active' === $otter_status ) {
/* translators: %s: Otter Blocks */
$notice_html .= __( 'Try it out!', 'raft' );
} elseif ( 'installed' === $otter_status ) {
/* translators: %s: Otter Blocks */
sprintf( __( 'Activate %s', 'raft' ), 'Otter Blocks' ) :
$notice_html .= sprintf( __( 'Activate %s', 'raft' ), 'Otter Blocks' );
} else {
/* translators: %s: Otter Blocks */
sprintf( __( 'Install & Activate %s', 'raft' ), 'Otter Blocks' );
$notice_html .= sprintf( __( 'Install & Activate %s', 'raft' ), 'Otter Blocks' );
}

$notice_html .= '</span>';
$notice_html .= '</button>';

Expand Down Expand Up @@ -162,9 +177,18 @@ public function set_otter_ref() {
* @return bool
*/
private function should_show_welcome_notice(): bool {
// Already using Otter.
// Already using Otter & has finished onboarding.
if ( is_plugin_active( 'otter-blocks/otter-blocks.php' ) ) {
return false;
if ( class_exists( '\ThemeIsle\GutenbergBlocks\Plugins\FSE_Onboarding' ) ) {
$status = get_option( \ThemeIsle\GutenbergBlocks\Plugins\FSE_Onboarding::OPTION_KEY, array() );
$slug = get_stylesheet();

if ( ! empty( $status[ $slug ] ) ) {
return false;
}
} else {
return false;
}
}

// Notice was dismissed.
Expand Down Expand Up @@ -224,6 +248,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 7e270a9

Please sign in to comment.