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

Development #2020

Merged
merged 118 commits into from
Dec 18, 2023
Merged
Changes from 1 commit
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
06b4a8b
fix: slider not working inside a flex container[#1750]
Oct 2, 2023
5d89296
chore: revert changes on package-lock.json
Oct 2, 2023
b1a72ae
Sync branch [skip ci]
pirate-bot Nov 14, 2023
1e52410
Sync branch [skip ci]
pirate-bot Nov 14, 2023
4c399bc
Sync branch [skip ci]
pirate-bot Nov 14, 2023
42b5c2e
Sync branch [skip ci]
pirate-bot Nov 14, 2023
dbbc899
Sync branch [skip ci]
pirate-bot Nov 14, 2023
96e6544
Sync branch [skip ci]
pirate-bot Nov 16, 2023
fc98f35
Sync branch [skip ci]
pirate-bot Nov 16, 2023
99d3740
Sync branch [skip ci]
pirate-bot Nov 18, 2023
035c119
Sync branch [skip ci]
pirate-bot Nov 18, 2023
aa3e24e
Initial work on Onboarding
HardeepAsrani Nov 20, 2023
9e47725
Sync branch [skip ci]
pirate-bot Nov 21, 2023
2ab98cf
Sync branch [skip ci]
pirate-bot Nov 21, 2023
ba3ca2f
Sync branch [skip ci]
pirate-bot Nov 21, 2023
cbc4540
Sync branch [skip ci]
pirate-bot Nov 22, 2023
721653a
Sync branch [skip ci]
pirate-bot Nov 22, 2023
6d0df63
Add Homepage Preview
HardeepAsrani Nov 22, 2023
224cf34
Merge branch 'development' into onboarding
HardeepAsrani Nov 22, 2023
be06bf0
Finish Site Info & Appearance UI
HardeepAsrani Nov 22, 2023
7815267
Add Saving Mechanism
HardeepAsrani Nov 23, 2023
3f0c161
Add Archive Step & Saving
HardeepAsrani Nov 24, 2023
74959c2
Add Single Step & Saving
HardeepAsrani Nov 25, 2023
71a70e6
Add Page Templates Step
HardeepAsrani Nov 25, 2023
7c4c38e
Finish Page Templates & Onboarding Complete Page
HardeepAsrani Nov 27, 2023
511fffa
fix: widget_styles Codeinwp/neve#4150
preda-bogdan Nov 27, 2023
be60d78
Add Steps Condition
HardeepAsrani Nov 27, 2023
db6a5de
Add Frontpage Step
HardeepAsrani Nov 27, 2023
8ed7969
Add Onboarding Support Docs
HardeepAsrani Nov 27, 2023
75090a0
Responsiveness Changes
HardeepAsrani Nov 27, 2023
4149e1b
Improve Homepage Preview
HardeepAsrani Nov 27, 2023
734a953
Add Redirection Conditions
HardeepAsrani Nov 28, 2023
332f6c5
fix: css generation for blocks when saving inside widgets via rest
preda-bogdan Nov 28, 2023
87e020f
chore: code cleanup
preda-bogdan Nov 28, 2023
f652cdf
Move Onboarding menu to Appearance
HardeepAsrani Nov 29, 2023
08336cb
Small code changes
HardeepAsrani Nov 30, 2023
011e993
chore(deps-dev): bump @testing-library/jest-dom from 5.17.0 to 6.1.5
dependabot[bot] Dec 1, 2023
22760a8
chore(deps-dev): bump @wordpress/block-editor from 12.12.0 to 12.15.0
dependabot[bot] Dec 1, 2023
85809ce
chore(deps): bump @wordpress/icons from 9.35.0 to 9.38.0
dependabot[bot] Dec 1, 2023
88879ad
chore(deps-dev): bump @wordpress/data from 9.14.0 to 9.17.0
dependabot[bot] Dec 1, 2023
81accc1
chore(deps-dev): bump @wordpress/env from 8.9.0 to 8.13.0
dependabot[bot] Dec 1, 2023
382a2cb
chore(deps-dev): bump @automattic/babel-plugin-replace-textdomain
dependabot[bot] Dec 1, 2023
1ad0b88
chore(deps): bump stripe/stripe-php from 13.3.0 to 13.5.0
dependabot[bot] Dec 1, 2023
6e80bb1
chore(deps-dev): bump php-stubs/woocommerce-stubs from 8.2.2 to 8.3.1
dependabot[bot] Dec 1, 2023
73559bd
Add e2e Tests
HardeepAsrani Dec 5, 2023
b07e1bd
fix: otter blocks inside customizer preview
preda-bogdan Dec 6, 2023
7b6ee61
chore: code cleanup
preda-bogdan Dec 7, 2023
761f6fb
chore: code cleanup
preda-bogdan Dec 7, 2023
4c07ac8
Add event tracking
HardeepAsrani Dec 8, 2023
fe77f82
Update readme
HardeepAsrani Dec 8, 2023
ccd22ec
Add Welcome Screen
HardeepAsrani Dec 11, 2023
23c3942
chore: fix phpcs
HardeepAsrani Dec 11, 2023
ebe7cbd
Allow PHP Templates
HardeepAsrani Dec 12, 2023
09ca3b2
fix: undefined array key in block conditions
HardeepAsrani Dec 12, 2023
2f5c5d4
phpunit: add tests for load_condition_hide_on_styles method
HardeepAsrani Dec 12, 2023
23870fe
Update Start.js
JohnPixle Dec 13, 2023
0e11996
Update Start.js
JohnPixle Dec 13, 2023
af9e19c
fix: doc link in onboarding
HardeepAsrani Dec 13, 2023
7a445bd
Update style.scss
JohnPixle Dec 13, 2023
49a2f62
Update Finish.js
JohnPixle Dec 13, 2023
144dded
Update Finish.js
JohnPixle Dec 13, 2023
a5dd0ff
Add Onboarding Toggle Field
HardeepAsrani Dec 13, 2023
25bfc63
Rebase
HardeepAsrani Dec 13, 2023
6461a8b
Add NPS Survey
HardeepAsrani Dec 13, 2023
ac1820e
chore: fix phpcs
HardeepAsrani Dec 14, 2023
8b601a1
Merge branch 'development' into fix/slider-not-working
Soare-Robert-Daniel Dec 14, 2023
0bbfa37
fix: glider root selector in frontend
Soare-Robert-Daniel Dec 14, 2023
42170c6
Show textarea label in Finish step
HardeepAsrani Dec 14, 2023
bfafb7e
chore: url to alphanum
HardeepAsrani Dec 14, 2023
8a75aab
fix: button group breaking when nofollow isn't being used
HardeepAsrani Dec 14, 2023
89146b3
chore: remove unused file
HardeepAsrani Dec 14, 2023
297b186
Sync branch [skip ci]
pirate-bot Dec 14, 2023
6031ec4
chore: fix phpunit failing
HardeepAsrani Dec 14, 2023
baf3cb5
Sync branch [skip ci]
pirate-bot Dec 14, 2023
fb3a0ca
chore(deps-dev): bump phpstan/phpstan from 1.10.41 to 1.10.50
dependabot[bot] Dec 14, 2023
f7c7428
Merge pull request #2013 from Codeinwp/dependabot/composer/developmen…
HardeepAsrani Dec 14, 2023
16f4e50
Merge pull request #1995 from Codeinwp/dependabot/composer/developmen…
HardeepAsrani Dec 14, 2023
62a4962
Sync branch [skip ci]
pirate-bot Dec 14, 2023
296422a
Merge pull request #1989 from Codeinwp/dependabot/npm_and_yarn/develo…
HardeepAsrani Dec 14, 2023
5873839
Sync branch [skip ci]
pirate-bot Dec 14, 2023
80cdfc1
Merge pull request #1988 from Codeinwp/dependabot/npm_and_yarn/develo…
HardeepAsrani Dec 14, 2023
a45d965
Sync branch [skip ci]
pirate-bot Dec 14, 2023
3fc1237
Merge pull request #1986 from Codeinwp/dependabot/npm_and_yarn/develo…
HardeepAsrani Dec 14, 2023
baaa31f
Sync branch [skip ci]
pirate-bot Dec 14, 2023
7ed72ff
Merge pull request #1990 from Codeinwp/dependabot/npm_and_yarn/develo…
HardeepAsrani Dec 14, 2023
a903070
Sync branch [skip ci]
pirate-bot Dec 14, 2023
198a5f9
chore(deps-dev): bump @wordpress/block-editor from 12.15.0 to 12.16.0
dependabot[bot] Dec 14, 2023
57646b7
chore(deps-dev): bump @wordpress/dom-ready from 3.47.0 to 3.48.0
dependabot[bot] Dec 14, 2023
abde81a
Merge pull request #1991 from Codeinwp/dependabot/npm_and_yarn/develo…
HardeepAsrani Dec 14, 2023
484d3be
Sync branch [skip ci]
pirate-bot Dec 14, 2023
ba7f317
Merge pull request #2014 from Codeinwp/dependabot/npm_and_yarn/develo…
HardeepAsrani Dec 14, 2023
d08d092
Merge pull request #2016 from Codeinwp/dependabot/npm_and_yarn/develo…
HardeepAsrani Dec 14, 2023
dd39e31
Sync branch [skip ci]
pirate-bot Dec 14, 2023
5f1d5ec
Merge pull request #1994 from Codeinwp/dependabot/composer/developmen…
HardeepAsrani Dec 14, 2023
6540036
Sync branch [skip ci]
pirate-bot Dec 14, 2023
86c8667
Merge pull request #1982 from Codeinwp/dependabot/npm_and_yarn/develo…
HardeepAsrani Dec 14, 2023
79bfb31
Sync branch [skip ci]
pirate-bot Dec 14, 2023
69bdd0f
Merge branch 'development' into fix/issue-124
HardeepAsrani Dec 14, 2023
37bedf1
Update Start.js
JohnPixle Dec 15, 2023
5a842d0
Update Dashboard.js
JohnPixle Dec 15, 2023
73db521
Add Email Subscription
HardeepAsrani Dec 15, 2023
96eded0
Improve Wonky nature of Templates Preview
HardeepAsrani Dec 15, 2023
6192a5a
Update Start.js
JohnPixle Dec 18, 2023
e9eb573
Update Finish.js
JohnPixle Dec 18, 2023
3d10a10
Toggle Email field with consent checkbox
HardeepAsrani Dec 18, 2023
017dfa9
Merge pull request #2012 from Codeinwp/fix/issue-2009
HardeepAsrani Dec 18, 2023
8cbf1fb
Merge pull request #2008 from Codeinwp/fix/issue-2001
HardeepAsrani Dec 18, 2023
f1d4b19
Sync branch [skip ci]
pirate-bot Dec 18, 2023
a256849
Merge pull request #2010 from Codeinwp/fix/issue-124
HardeepAsrani Dec 18, 2023
9f272c9
Sync branch [skip ci]
pirate-bot Dec 18, 2023
2a1a87e
Merge branch 'next' into onboarding
HardeepAsrani Dec 18, 2023
9eb25ea
Merge pull request #1979 from Codeinwp/fix/widget_styles
HardeepAsrani Dec 18, 2023
2bb6cd2
Sync branch [skip ci]
pirate-bot Dec 18, 2023
d3997e8
Merge pull request #1906 from Codeinwp/fix/slider-not-working
HardeepAsrani Dec 18, 2023
38240d2
Sync branch [skip ci]
pirate-bot Dec 18, 2023
d3bb4c3
Merge pull request #1976 from Codeinwp/onboarding
HardeepAsrani Dec 18, 2023
3f78fc9
Merge pull request #2019 from Codeinwp/next
HardeepAsrani Dec 18, 2023
379dddd
chore: update workflow
HardeepAsrani Dec 18, 2023
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
Prev Previous commit
Next Next commit
Add Redirection Conditions
  • Loading branch information
HardeepAsrani committed Nov 28, 2023
commit 734a953c50b81c3302dad45f54c4bd351f20c7da
156 changes: 131 additions & 25 deletions inc/plugins/class-fse-onboarding.php
Original file line number Diff line number Diff line change
@@ -25,20 +25,108 @@ class FSE_Onboarding {
* Initialize the class
*/
public function init() {
add_action( 'after_switch_theme', array( $this, 'on_switch_theme' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_options_assets' ) );
add_action( 'admin_menu', array( $this, 'register_menu_page' ) );
}

/**
* Register menu page
*
* @access public
* @return void
*/
public function register_menu_page() {
$has_support = get_theme_support( 'otter-onboarding' );

if ( false === $has_support || ! current_user_can( 'manage_options' ) ) {
return;
}

add_submenu_page(
'otter',
esc_html__( 'FSE Onboarding', 'otter-blocks' ),
esc_html__( 'FSE Onboarding', 'otter-blocks' ),
'manage_options',
'otter-onboarding',
function() {
$redirect = add_query_arg(
array(
'onboarding' => 'true',
),
admin_url( 'site-editor.php' )
);

echo '<p>Redirecting...</p>
<script>document.location.href = "' . esc_url( $redirect ) . '";</script>';
}
);
}

/**
* On switch theme
*
* @access public
* @return void
*/
public function on_switch_theme() {
// Check if the theme has support for FSE.
$support = get_theme_support( 'otter-onboarding' );

if ( false === $support ) {
return;
}

$status = get_option( 'otter_onboarding_status', array() );
$slug = get_stylesheet();

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

// Run the onboarding.
self::run_onboarding();
}

/**
* Run the onboarding.
*
* @access public
* @return void
*/
public static function run_onboarding() {
$redirect = add_query_arg(
array(
'onboarding' => 'true',
),
admin_url( 'site-editor.php' )
);

// Set the onboarding ran option.
$status = get_option( 'otter_onboarding_status', array() );
$slug = get_stylesheet();
$status[ $slug ] = true;
update_option( 'otter_onboarding_status', $status );

// Redirect to the onboarding.
wp_safe_redirect( $redirect );
exit;
}

/**
* Get Theme Templates
*
* @access public
* @return array|false
*/
public function get_templates() {
$support = get_theme_support( 'otter-onboarding' );
$support = get_theme_support( 'otter-onboarding' );

if ( false === $support && ! is_array( $support ) || ( ! isset( $support[0]['templates'] ) && ! isset( $support[0]['page_templates'] ) ) ) {
return false;
}
if ( false === $support || ! is_array( $support ) || ( ! isset( $support[0]['templates'] ) && ! isset( $support[0]['page_templates'] ) ) ) {
return false;
}

$template = array();
$templates = array();

if ( isset( $support[0]['templates'] ) ) {
$templates = $support[0]['templates'];
@@ -48,26 +136,29 @@ public function get_templates() {
$templates['page_templates'] = $support[0]['page_templates'];
}

if ( ! $templates ) {
return false;
}

foreach ( $templates as $key => $categories ) {
foreach ( $categories as $i => $template ) {
if ( file_exists( $template['file'] ) ) {
$templates[ $key ][ $i ]['content']['raw'] = file_get_contents( $template['file'] );
unset( $templates[ $key ][ $i ]['file'] );
} else {
unset( $templates[ $key ][ $i ] );
}
}
}
if ( ! $templates ) {
return false;
}

foreach ( $templates as $key => $categories ) {
foreach ( $categories as $i => $template ) {
if ( file_exists( $template['file'] ) ) {
$templates[ $key ][ $i ]['content']['raw'] = file_get_contents( $template['file'] );
unset( $templates[ $key ][ $i ]['file'] );
} else {
unset( $templates[ $key ][ $i ] );
}
}
}

return $templates;
}

/**
* Get Templates Types
*
* @access public
* @return array
*/
public function get_templates_types() {
$templates = $this->get_templates();
@@ -79,10 +170,25 @@ public function get_templates_types() {
return array_keys( $templates );
}

/**
* Enqueue options assets.
*/
public function enqueue_options_assets() {
/**
* Enqueue options assets.
*
* @access public
* @return void
*/
public function enqueue_options_assets() {
$current_screen = get_current_screen();
$has_support = get_theme_support( 'otter-onboarding' );

if (
false === $has_support ||
! current_user_can( 'manage_options' ) ||
! isset( $current_screen->id ) ||
'site-editor' !== $current_screen->id
) {
return;
}

$asset_file = include OTTER_BLOCKS_PATH . '/build/onboarding/index.asset.php';

wp_enqueue_media();
@@ -106,7 +212,7 @@ public function enqueue_options_assets() {

wp_localize_script(
'otter-onboarding-scripts',
'otterObj',
'otterOnboardingData',
apply_filters(
'otter_onboarding_data',
array(
@@ -116,7 +222,7 @@ public function enqueue_options_assets() {
)
)
);
}
}

/**
* The instance method for the static class.
41 changes: 11 additions & 30 deletions inc/server/class-fse-onboarding-server.php
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ public function register_routes() {
'methods' => \WP_REST_Server::READABLE,
'callback' => array( $this, 'get_templates' ),
'permission_callback' => function () {
return current_user_can( 'manage_options' );
return current_user_can( 'manage_options' );
},
),
)
@@ -76,16 +76,16 @@ public function get_templates( \WP_REST_Request $request ) {

$templates = $fse_onboarding->get_templates();

if ( ! $templates ) {
return rest_ensure_response(
array(
'success' => false,
'data' => array(
'message' => __( 'Missing templates', 'otter-blocks' ),
),
)
);
}
if ( ! $templates ) {
return rest_ensure_response(
array(
'success' => false,
'data' => array(
'message' => __( 'Missing templates', 'otter-blocks' ),
),
)
);
}

return rest_ensure_response(
array(
@@ -95,25 +95,6 @@ public function get_templates( \WP_REST_Request $request ) {
);
}

/**
* Get Product Pricing.
*
* @param \WP_REST_Request $request The request.
*
* @return \WP_REST_Response
* @access public
*/
public function get_price( \WP_REST_Request $request ) {
return ( new Stripe_API() )->create_request(
'prices',
array(
'active' => true,
'product' => $request->get_param( 'id' ),
'limit' => 50,
)
);
}

/**
* The instance method for the static class.
* Defines and returns the instance of the static class.
4 changes: 2 additions & 2 deletions src/onboarding/components/Finish.js
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import { useSelect } from '@wordpress/data';

import { useState } from '@wordpress/element';

const { version } = window.otterObj;
const { version } = window.otterOnboardingData;

const Finish = () => {
const [ feedback, setFeedback ] = useState( '' );
@@ -74,7 +74,7 @@ const Finish = () => {
<div className="o-finish__container">
<img
className="o-finish__logo"
src={ `${ window.otterObj.assetsPath }images/logo-alt.png` }
src={ `${ window.otterOnboardingData.assetsPath }images/logo-alt.png` }
/>

<h1>{ __( 'Your website is ready to go!', 'otter-blocks' ) }</h1>
2 changes: 1 addition & 1 deletion src/onboarding/components/Sidebar.js
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ const Sidebar = ({ isEditorLoading }) => {
<div className="o-sidebar__header">
<img
className="o-sidebar__logo"
src={ `${ window.otterObj.assetsPath }images/logo-alt.png` }
src={ `${ window.otterOnboardingData.assetsPath }images/logo-alt.png` }
/>

{ 0 !== stepIndex ? (
14 changes: 11 additions & 3 deletions src/onboarding/index.js
Original file line number Diff line number Diff line change
@@ -19,6 +19,14 @@ const Render = () => {
);
};

registerPlugin( 'otter-onboarding', {
render: Render
});
// Check the URL for the onboarding query string.
const urlParams = new URLSearchParams( window.location.search );
const onboarding = urlParams.get( 'onboarding' );
console.log( onboarding );

// If the onboarding query string is present, render the onboarding modal.
if ( 'true' === onboarding ) {
registerPlugin( 'otter-onboarding', {
render: Render
});
}
2 changes: 1 addition & 1 deletion src/onboarding/steps.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import Template from './components/steps/Template';
import Pages from './components/steps/Pages';

const isSupported = step => {
const { supportedSteps } = window.otterObj;
const { supportedSteps } = window.otterOnboardingData;

return supportedSteps.includes( step );
};
2 changes: 1 addition & 1 deletion src/onboarding/style.scss
Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ div.error, div.notice {
}

@media ( min-width: 1920px ) {
width: 25vw;
width: 20vw;
}
}