PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 All 128 releases
← All changes | src/Agent/workflows/theme/tools/change-site-design.js +7 -30 3.1.2 → 3.2.2 View file →
@@ -1,41 +1,15 @@
1 1 import changeHeroSection from '@agent/workflows/theme/tools/change-hero-section';
2 +import updatePalette from '@agent/workflows/theme/tools/update-palette';
2 3 import updateSiteVibes from '@agent/workflows/theme/tools/update-site-vibes';
3 -import { deepMerge } from '@shared/lib/utils';
4 -import apiFetch from '@wordpress/api-fetch';
4 +import updateVariation from '@agent/workflows/theme/tools/update-variation';
5 5
6 -const { globalStylesPostID } = window.extSharedData;
7 -
8 -// Apply the selected variation as authoritative, preserving only block style variations (vibes)
9 -const updateVariation = async ({ variation }) => {
10 - const currentVariations = await apiFetch({
11 - path: '/extendify/v1/agent/block-style-variations',
12 - });
13 -
14 - const preservedBlockVibes = Object.keys(currentVariations).reduce(
15 - (blocks, blockName) => {
16 - blocks[blockName] = { variations: currentVariations[blockName] };
17 - return blocks;
18 - },
19 - {},
20 - );
21 -
22 - const final = deepMerge(variation, {
23 - styles: { blocks: preservedBlockVibes },
24 - });
25 -
26 - return apiFetch({
27 - method: 'POST',
28 - path: `/wp/v2/global-styles/${globalStylesPostID}`,
29 - data: { id: globalStylesPostID, ...final },
30 - });
31 -};
32 -
33 6 export default async ({
34 7 updatedPageBlocks,
35 8 postId,
36 9 vibeSlug,
37 10 colorAndFontsVariation,
11 + colorPalette,
38 12 }) => {
39 13 if (!updatedPageBlocks || !vibeSlug || !colorAndFontsVariation) return;
40 14
41 15 await Promise.all([
@@ -40,9 +14,12 @@
40 14
41 15 await Promise.all([
42 16 changeHeroSection({ updatedPageBlocks, postId }),
43 17 (async () => {
18 + // The vibe write goes last so it owns the contested leaves.
19 + await updateVariation({ variation: colorAndFontsVariation });
20 + // Absent or failing when /api/palettes is down; the vibe write must still run.
21 + if (colorPalette) await updatePalette({ colorPalette }).catch(() => null);
44 22 await updateSiteVibes({ selectedVibe: vibeSlug });
45 - await updateVariation({ variation: colorAndFontsVariation });
46 23 })(),
47 24 ]);
48 25 };