Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Otter onboarding to Neve FSE #144

Merged
merged 5 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/img/neve-fse-img13.webp
Binary file not shown.
Binary file added assets/img/neve-fse-img14.webp
Binary file not shown.
4 changes: 3 additions & 1 deletion assets/js/src/design-pack-notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { createRoot } from '@wordpress/element';

import DesignPackNotice from './components/DesignPackNotice';

const container = document.getElementById( 'neve-fse-design-pack-notice' );
const container = document.createElement( 'div' );
container.id = 'neve-fse-design-pack-notice';
document.body.appendChild( container );

if ( container ) {
createRoot( container ).render( <DesignPackNotice /> );
Expand Down
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
57 changes: 55 additions & 2 deletions inc/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function setup_admin_hooks() {

add_action( 'enqueue_block_editor_assets', array( $this, 'add_fse_design_pack_notice' ) );
add_action( 'wp_ajax_neve_fse_dismiss_design_pack_notice', array( $this, 'remove_design_pack_notice' ) );
add_action( 'activated_plugin', 'after_otter_activation' );
add_action( 'wp_ajax_neve_fse_set_otter_ref', array( $this, 'set_otter_ref' ) );
}

Expand Down Expand Up @@ -104,8 +105,6 @@ public function add_fse_design_pack_notice() {
),
'designPackNoticeData'
);

echo '<div id="neve-fse-design-pack-notice"></div>';
}

/**
Expand Down Expand Up @@ -279,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' ) . '&hellip;',
'installing' => __( 'Installing', 'neve-fse' ) . '&hellip;',
'done' => __( 'Done', 'neve-fse' ),
Expand Down Expand Up @@ -430,13 +437,59 @@ 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';
}

return $status;
}

/**
* Run after Otter Blocks activation.
*
* @param string $plugin Plugin name.
*
* @return void
*/
public function after_otter_activation( $plugin ) {
if ( 'otter-blocks/otter-blocks.php' !== $plugin ) {
return;
}

if ( ! class_exists( '\ThemeIsle\GutenbergBlocks\Plugins\FSE_Onboarding' ) ) {
return;
}

$status = get_option( \ThemeIsle\GutenbergBlocks\Plugins\FSE_Onboarding::OPTION_KEY, array() );
$slug = get_stylesheet();

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

// Dismiss after two days from activation.
$activated_time = get_option( 'neve_fse_install' );

if ( ! empty( $activated_time ) && time() - intval( $activated_time ) > ( 2 * DAY_IN_SECONDS ) ) {
update_option( Constants::CACHE_KEYS['dismissed-welcome-notice'], 'yes' );
return;
}

$onboarding = add_query_arg(
array(
'onboarding' => 'true',
),
admin_url( 'site-editor.php' )
);

wp_safe_redirect( $onboarding );
exit;
}

/**
* Update Otter reference key.
*
Expand Down
7 changes: 7 additions & 0 deletions inc/Block_Patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ private function setup_properties() {
'layout/columns-image-and-text',
'layout/portfolio-columns',
'layout/columns-image-and-text-inv',
'layout/hero-with-feature-columns',
'layout/columns-testimonials-inv',
'layout/columns-with-services-text',
'layout/contact-section',
'layout/hero-with-text',
'layout/map-section',
'layout/faq-section',

// Post patterns.
'loops/post-loop-1',
Expand Down
60 changes: 60 additions & 0 deletions inc/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,66 @@ public function setup() {
)
);

add_theme_support(
'otter-onboarding',
array(
'logo' => NEVE_FSE_URL . 'assets/img/neve-fse-logo.svg',
'templates' => array(
'archive' => array(
'archive-list' => array(
'file' => NEVE_FSE_DIR . 'library/archive/archive-list.php',
'title' => __( 'Archive List', 'neve-fse' ),
),
'archive-cover' => array(
'file' => NEVE_FSE_DIR . 'library/archive/archive-cover.php',
'title' => __( 'Archive Cover', 'neve-fse' ),
),
),
'single' => array(
'single-post-cover-boxed' => array(
'file' => NEVE_FSE_DIR . 'library/single/single-post-cover-boxed.php',
'title' => __( 'Single Post Cover Boxed', 'neve-fse' ),
),
'single-post-cover' => array(
'file' => NEVE_FSE_DIR . 'library/single/single-post-cover.php',
'title' => __( 'Single Post Cover', 'neve-fse' ),
),
),
'front-page' => array(
'front-page-alt' => array(
'file' => NEVE_FSE_DIR . 'library/front-page/front-page-2.php',
'title' => __( 'Homepage 2', 'neve-fse' ),
),
'front-page-alt-2' => array(
'file' => NEVE_FSE_DIR . 'library/front-page/front-page-3.php',
'title' => __( 'Homepage 4', 'neve-fse' ),
),
),
),
'page_templates' => array(
'about-page' => array(
'file' => NEVE_FSE_DIR . 'library/templates/about-page.php',
'title' => __( 'About Page', 'neve-fse' ),
'template' => 'template-plain',
),
'contact-page' => array(
'file' => NEVE_FSE_DIR . 'library/templates/contact-page.php',
'title' => __( 'Contact Page', 'neve-fse' ),
'template' => 'template-plain',
),
'portfolio-page' => array(
'file' => NEVE_FSE_DIR . 'library/templates/portfolio-page.php',
'title' => __( 'Portfolio Page', 'neve-fse' ),
'template' => 'template-plain',
),
'services-page' => array(
'file' => NEVE_FSE_DIR . 'library/templates/services-page.php',
'title' => __( 'Services Page', 'neve-fse' ),
'template' => 'template-plain',
),
),
)
);

register_nav_menus( array( 'primary' => esc_html__( 'Primary Menu', 'neve-fse' ) ) );
}
Expand Down
104 changes: 104 additions & 0 deletions inc/patterns/layout/columns-testimonials-inv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
/**
* Pattern
*
* @author Themeisle
* @package neve-fse
* @since 1.1.0
*
* slug: columns-testimonials-inv
* title: Three Columns with Testimonials Inverted
* categories: NeveFSE
* keywords: Columns, testimonial, client, review
*/

use NeveFSE\Assets_Manager;

$neve_fse_img06 = Assets_Manager::get_image_url( 'neve-fse-img06.jpg' );
$neve_fse_img07 = Assets_Manager::get_image_url( 'neve-fse-img07.jpg' );
$neve_fse_img08 = Assets_Manager::get_image_url( 'neve-fse-img08.jpg' );

return array(
'title' => __( 'Three Columns with Testimonials Inverted', 'neve-fse' ),
'categories' => array( 'neve-fse' ),
'keywords' => array( 'Columns', 'testimonial', 'client', 'review' ),
'content' => '
<!-- wp:group {"align":"full","style":{"spacing":{"padding":{"top":"64px","bottom":"64px"},"margin":{"top":"0px","bottom":"0px"},"blockGap":"40px"}},"textColor":"ti-fg","layout":{"inherit":true,"type":"constrained"}} -->
<div class="wp-block-group alignfull has-ti-fg-color has-text-color" style="margin-top:0px;margin-bottom:0px;padding-top:64px;padding-bottom:64px">
<!-- wp:group {"align":"wide"} -->
<div class="wp-block-group alignwide">
<!-- wp:columns {"style":{"spacing":{"blockGap":{"top":"24px","left":"24px"}}}} -->
<div class="wp-block-columns">
<!-- wp:column {"style":{"spacing":{"blockGap":"0px"}}} -->
<div class="wp-block-column">
<!-- wp:group {"style":{"border":{"radius":"5px"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="border-radius:5px">
<!-- wp:image {"width":80,"sizeSlug":"full","linkDestination":"none","className":"is-style-rounded"} -->
<figure class="wp-block-image size-full is-resized is-style-rounded">
<img src="' . esc_url( $neve_fse_img08 ) . '" alt="" width="80"/>
</figure>
<!-- /wp:image -->

<!-- wp:paragraph {"align":"left"} -->
<p class="has-text-align-left">"...Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis..."</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"left","fontSize":"small"} -->
<p class="has-text-align-left has-small-font-size"><strong>JANE DOE</strong></p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:column -->

<!-- wp:column {"style":{"spacing":{"blockGap":"0px"}}} -->
<div class="wp-block-column">
<!-- wp:group {"style":{"border":{"radius":"5px"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="border-radius:5px">
<!-- wp:image {"width":80,"sizeSlug":"full","linkDestination":"none","className":"is-style-rounded"} -->
<figure class="wp-block-image size-full is-resized is-style-rounded">
<img src="' . esc_url( $neve_fse_img07 ) . '" alt="" width="80"/>
</figure>
<!-- /wp:image -->

<!-- wp:paragraph {"align":"left"} -->
<p class="has-text-align-left">"...Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis..."</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"left","fontSize":"small"} -->
<p class="has-text-align-left has-small-font-size"><strong>JOHN DOE</strong></p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:column -->

<!-- wp:column {"style":{"spacing":{"blockGap":"0px"}}} -->
<div class="wp-block-column">
<!-- wp:group {"style":{"border":{"radius":"5px"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group" style="border-radius:5px">
<!-- wp:image {"width":80,"height":80,"sizeSlug":"full","linkDestination":"none","className":"is-style-rounded"} -->
<figure class="wp-block-image size-full is-resized is-style-rounded">
<img src="' . esc_url( $neve_fse_img06 ) . '" alt="" width="80" height="80"/>
</figure>
<!-- /wp:image -->

<!-- wp:paragraph {"align":"left"} -->
<p class="has-text-align-left">"...Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis..."</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"align":"left","fontSize":"small"} -->
<p class="has-text-align-left has-small-font-size"><strong>MARIA DOE</strong></p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->
</div>
<!-- /wp:group -->
</div>
<!-- /wp:group -->
',
);
73 changes: 73 additions & 0 deletions inc/patterns/layout/columns-with-services-text.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/**
* Pattern
*
* @author Themeisle
* @package neve-fse
* @since 1.1.0
*
* slug: columns-with-services-text
* title: Columns with Services Text
* categories: NeveFSE
* keywords: columns, services, features, 3col
*/

use NeveFSE\Assets_Manager;

return array(
'title' => __( 'Columns with Services Text', 'neve-fse' ),
'categories' => array( 'neve-fse' ),
'keywords' => array( 'columns', 'services', 'features', '3col' ),
'content' => '
<!-- wp:group {"align":"full","style":{"spacing":{"margin":{"top":"0","bottom":"0"},"padding":{"top":"var:preset|spacing|80","bottom":"var:preset|spacing|80","left":"var:preset|spacing|50","right":"var:preset|spacing|50"}}},"backgroundColor":"ti-bg-alt","layout":{"type":"constrained"}} -->
<div class="wp-block-group alignfull has-ti-bg-alt-background-color has-background" style="margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--80);padding-right:var(--wp--preset--spacing--50);padding-bottom:var(--wp--preset--spacing--80);padding-left:var(--wp--preset--spacing--50)"><!-- wp:columns {"verticalAlignment":"top","align":"wide","style":{"spacing":{"margin":{"top":"var:preset|spacing|80","bottom":"var:preset|spacing|80"},"blockGap":{"left":"var:preset|spacing|60"}}}} -->
<div class="wp-block-columns alignwide are-vertically-aligned-top" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"><!-- wp:column {"verticalAlignment":"top","width":"66.66%","style":{"spacing":{"blockGap":"var:preset|spacing|50"}}} -->
<div class="wp-block-column is-vertically-aligned-top" style="flex-basis:66.66%"><!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Service Title</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.</p>
<!-- /wp:paragraph -->

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Learn more</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div>
<!-- /wp:column -->

<!-- wp:column {"verticalAlignment":"top","width":"66.66%","style":{"spacing":{"blockGap":"var:preset|spacing|50"}}} -->
<div class="wp-block-column is-vertically-aligned-top" style="flex-basis:66.66%"><!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Service Title</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.</p>
<!-- /wp:paragraph -->

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Learn more</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div>
<!-- /wp:column -->

<!-- wp:column {"verticalAlignment":"top","width":"66.66%","style":{"spacing":{"blockGap":"var:preset|spacing|50"}}} -->
<div class="wp-block-column is-vertically-aligned-top" style="flex-basis:66.66%"><!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Service Title</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.</p>
<!-- /wp:paragraph -->

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Learn more</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div>
<!-- /wp:column --></div>
<!-- /wp:columns --></div>
<!-- /wp:group -->',
);
Loading
Loading