PHP 8.2.31
Preview: useInstallRequiredPlugins.js Size: 948 B
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/extendify_old/src/AutoLaunch/hooks/useInstallRequiredPlugins.js

import { handleSitePlugins } from '@auto-launch/fetchers/get-plugins';
import { activatePlugin, installPlugin } from '@auto-launch/functions/plugins';
import useSWR from 'swr/immutable';

const { installedPluginsSlugs } = window.extSharedData || {};

export const useInstallRequiredPlugins = () => {
	const { data, error } = useSWR('required-plugins', () =>
		handleSitePlugins({ requiredOnly: true }),
	);

	if (data?.sitePlugins?.sitePlugins?.length) {
		const pluginsToInstall = data.sitePlugins.sitePlugins.filter(
			({ wordpressSlug: slug }) => !installedPluginsSlugs?.includes(slug),
		);
		if (pluginsToInstall.length === 0) return;
		(async function install() {
			for (const { wordpressSlug: slug } of pluginsToInstall) {
				const p = await installPlugin(slug);
				await activatePlugin(p?.plugin ?? slug);
			}
		})();
	}

	return {
		requiredPlugins: data?.selectedPlugins || [],
		isLoading: !error && !data,
		isError: error,
	};
};

Directory Contents

Dirs: 0 × Files: 4

Name Size Perms Modified Actions
17.31 KB lrw-r--r-- 2026-04-27 23:36:32
Edit Download
948 B lrw-r--r-- 2026-04-27 23:36:32
Edit Download
711 B lrw-r--r-- 2026-02-27 04:48:52
Edit Download
533 B lrw-r--r-- 2026-02-27 04:48:52
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).