Skip to content

Commit

Permalink
Puzzle app: update blueprint (#1499)
Browse files Browse the repository at this point in the history
## Motivation for the change, related issues

We need to update puzzle app blueprints based on sponsor feedback.

I also found a bug with the processor where it would not use the landing
page in cases a single blueprint with multiple plugins was used.

## Implementation details

## Testing Instructions (or ideally a Blueprint)
  • Loading branch information
bgrgicak authored Jun 11, 2024
1 parent bbd5a25 commit bcb55a7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
34 changes: 24 additions & 10 deletions packages/playground/puzzle/src/site-builder/blueprints/yith.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
{
"landingPage": "/wp-admin/edit.php?post_type=gift_card&post_status=publish&yith-plugin-fw-panel-skip-redirect=1",
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"landingPage": "/wp-admin/admin.php?page=yith_wcwl_panel&tab=settings&sub_tab=settings-add_to_wishlist",
"steps": [
{
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org/plugins",
"slug": "woocommerce"
},
"options": {
"activate": true
}
},
{
"step": "runPHP",
"code": "<?php require_once '/wordpress/wp-load.php'; update_option('woocommerce_onboarding_profile', ['skipped' => true]);"
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org/plugins",
"slug": "wordpress-importer"
}
},
{
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org/plugins",
"slug": "yith-woocommerce-gift-cards"
},
"options": {
"activate": true
"slug": "yith-woocommerce-wishlist"
}
},
{
"step": "wp-cli",
"command": "wp option update yith_wcwl_show_on_loop 'yes'"
},
{
"step": "wp-cli",
"command": "wp import /wordpress/wp-content/plugins/woocommerce/sample-data/sample_products.xml --authors=create"
},
{
"step": "wp-cli",
"command": "wp transient set _wc_activation_redirect 0 259200"
},
{
"step": "wp-cli",
"command": "wp option update woocommerce_onboarding_profile '{\"skipped\": true}' --format=json"
}
]
}
13 changes: 3 additions & 10 deletions packages/playground/puzzle/src/site-builder/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export const processImage = async (actions: string[]) => {
);
if (actions.includes('/wp-admin/')) {
blueprint['landingPage'] = '/wp-admin/';
} else if (actions.length > 1) {
blueprint['landingPage'] = '/wp-admin/plugins.php';
}

if (actions.includes('multisite')) {
Expand Down Expand Up @@ -188,7 +190,6 @@ const mergeBlueprints = (blueprints: any[]) => {
};

const landingPages: string[] = [];
let pluginsInstalled = 0;
let themeInstalled = false;
for (const blueprint of blueprints) {
if (!blueprint) {
Expand All @@ -207,10 +208,6 @@ const mergeBlueprints = (blueprints: any[]) => {
),
];

pluginsInstalled += blueprint.steps.filter(
(step: any) => step.step === 'installPlugin'
).length;

if (
themeInstalled === false &&
blueprint.steps.find((step: any) => step.step === 'installTheme')
Expand All @@ -219,12 +216,8 @@ const mergeBlueprints = (blueprints: any[]) => {
}
}

// If multiple plugins are installed, go to the plugins list
if (pluginsInstalled > 1) {
newBlueprint.landingPage = '/wp-admin/plugins.php';
}
// If one landing page is defined, use it
else if (themeInstalled) {
if (themeInstalled) {
newBlueprint.landingPage = '/';
}
// If multiple landing pages are defined, go to the first one
Expand Down

0 comments on commit bcb55a7

Please sign in to comment.