# extendify/3.0.6/src/Agent/hooks/useThemeFontsVariations.js

Extendify, version 3.0.6. 42 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.0.6/code/src/Agent/hooks/useThemeFontsVariations.js
- Raw: https://pluginprobe.com/plugins/extendify/3.0.6/raw/src/Agent/hooks/useThemeFontsVariations.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.6/code/src/Agent/hooks/useThemeFontsVariations.js#L10-L20`.

```javascript
import apiFetch from '@wordpress/api-fetch';
import { __ } from '@wordpress/i18n';
import useSWRImmutable from 'swr/immutable';

export const useThemeFontsVariations = () => {
	const { data, error, isLoading } = useSWRImmutable(
		{
			key: 'theme-fonts-variations',
			themeSlug: window.extAgentData.context.themeSlug,
		},
		fetcher,
	);
	return { variations: data?.variations, error, isLoading };
};

const fetcher = async () => {
	const path = window.location.pathname;
	const s = new URLSearchParams(window.location.search);
	const onEditor =
		path.includes('/wp-admin/post.php') && s.get('action') === 'edit';

	const variations = await apiFetch({
		method: 'GET',
		// On the frontend we need to include layout styles
		path: `/extendify/v1/agent/theme-fonts-variations${onEditor ? '' : '?includeLayoutStyles'}`,
	});
	if (!variations || !Array.isArray(variations)) {
		throw new Error(
			__('Failed to fetch theme font variations.', 'extendify-local'),
		);
	}
	return {
		// remove duplicate variations by title
		variations: variations.reduce((acc, variation) => {
			if (!acc.some((v) => v.title === variation.title)) {
				acc.push(variation);
			}
			return acc;
		}, []),
	};
};

```
