# extendify/3.2.2/src/AutoLaunch/hooks/useInstallRequiredPlugins.js

Extendify, version 3.2.2. 20 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.2.2/code/src/AutoLaunch/hooks/useInstallRequiredPlugins.js
- Raw: https://pluginprobe.com/plugins/extendify/3.2.2/raw/src/AutoLaunch/hooks/useInstallRequiredPlugins.js
- Modified: 2026-10-01T15:30:38+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.2.2/code/src/AutoLaunch/hooks/useInstallRequiredPlugins.js#L10-L20`.

```javascript
import { handleSitePlugins } from '@auto-launch/fetchers/get-plugins';
import { ensurePluginsActive } from '@auto-launch/functions/plugins';
import { useEffect, useRef } from '@wordpress/element';
import useSWR from 'swr/immutable';

export const useInstallRequiredPlugins = ({ enabled = true } = {}) => {
	const { data } = useSWR(enabled ? 'required-plugins' : null, () =>
		handleSitePlugins({ requiredOnly: true }),
	);
	const started = useRef(false);

	useEffect(() => {
		if (started.current || !data?.sitePlugins?.length) return;
		started.current = true;
		ensurePluginsActive(
			data.sitePlugins.map(({ wordpressSlug }) => wordpressSlug),
		);
	}, [data]);
};

```
