# extendify/3.0.4/src/Agent/workflows/theme/tools/update-variation.js

Extendify, version 3.0.4. 33 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.0.4/code/src/Agent/workflows/theme/tools/update-variation.js
- Raw: https://pluginprobe.com/plugins/extendify/3.0.4/raw/src/Agent/workflows/theme/tools/update-variation.js
- Modified: 2026-02-18T22:27:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.0.4/code/src/Agent/workflows/theme/tools/update-variation.js#L10-L20`.

```javascript
import { deepMerge } from '@shared/lib/utils';
import apiFetch from '@wordpress/api-fetch';

const { globalStylesPostID } = window.extSharedData;

// Will merge into the current variation and preserve block style variations (vibes)
export default async ({ variation }) => {
	const currentTheme = await apiFetch({
		path: `/wp/v2/global-styles/${globalStylesPostID}?context=edit`,
	});
	const currentVariations = await apiFetch({
		path: '/extendify/v1/agent/block-style-variations',
	});

	const preservedBlockVibes = Object.keys(currentVariations).reduce(
		(blocks, blockName) => {
			blocks[blockName] = { variations: currentVariations[blockName] };
			return blocks;
		},
		{},
	);

	const final = deepMerge(currentTheme, variation, {
		styles: { blocks: preservedBlockVibes },
	});

	return apiFetch({
		method: 'POST',
		path: `/wp/v2/global-styles/${globalStylesPostID}`,
		data: { id: globalStylesPostID, ...final },
	});
};

```
