REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 3.14 KB
Close
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/extendify_old/src/Agent/hooks/useVariationOverride.js
Text
Base64
import { getDynamicDuotoneMap } from '@agent/lib/svg-blocks-scanner'; import { replaceDuotoneSVG } from '@agent/lib/svg-helpers'; import { parse } from '@wordpress/blocks'; import { useSelect } from '@wordpress/data'; import { useCallback, useEffect, useRef, useState } from '@wordpress/element'; const id = 'global-styles-inline-css'; const path = window.location.pathname; const s = new URLSearchParams(window.location.search); const onEditor = path.includes('/wp-admin/post.php') && s.get('action') === 'edit'; export const useVariationOverride = ({ css, duotoneTheme }) => { const frontStyles = useRef(null); const duotoneCleanup = useRef(null); const [theDocument, setDocument] = useState(null); useEffect(() => { if (!css || onEditor) return; const style = document.getElementById(id); if (!style) return; if (!frontStyles.current) { frontStyles.current = style.innerHTML; } style.innerHTML = css; }, [css]); // Handle the editor useEffect(() => { if (!css || !theDocument || !onEditor) return; const style = theDocument.getElementById(id); const hasIframe = document.querySelector('iframe[name="editor-canvas"]'); style.innerHTML = css.replaceAll( ':root', // If the iframe was removed, target the editor the old way hasIframe ? ':root' : '.editor-styles-wrapper', ); }, [css, theDocument]); useEffect(() => { if (theDocument) return; const timer = setTimeout(() => { if (theDocument) return; const frame = document.querySelector('iframe[name="editor-canvas"]'); const doc = frame?.contentDocument || document; if (!doc || !doc.body) return; // Add a tag to the body const newStyle = doc.createElement('style'); newStyle.id = id; doc.body.appendChild(newStyle); setDocument(doc); }, 300); // wait for iframe return () => clearTimeout(timer); }, [theDocument]); const dynamicDuotone = useSelect((select) => { let blocks = select('core/block-editor')?.getBlocks?.() ?? []; const hasShowTemplateOn = blocks.find( (block) => block.name === 'core/template-part', ); if (hasShowTemplateOn) { const { getEditedPostContent } = select('core/editor'); blocks = parse(getEditedPostContent(), {}); } return getDynamicDuotoneMap(blocks); }, []); // Handle duotone changes useEffect(() => { if (!duotoneTheme) return; // Clean up previous duotone changes if (duotoneCleanup.current) { duotoneCleanup.current(); duotoneCleanup.current = null; } // Apply new duotone changes and store cleanup duotoneCleanup.current = replaceDuotoneSVG({ duotoneTheme, dynamicDuotone, }); }, [css, duotoneTheme, dynamicDuotone]); const undoChange = useCallback(() => { // Revert duotone changes if (duotoneCleanup.current) { duotoneCleanup.current(); duotoneCleanup.current = null; } // Revert CSS changes const style = document.getElementById(id); if (style && frontStyles.current) { style.innerHTML = frontStyles.current; } // Remove editor CSS if (!onEditor) return; const iframe = document.querySelector('iframe[name="editor-canvas"]'); const doc = iframe?.contentDocument || document; doc?.getElementById(id)?.remove(); }, []); return { undoChange }; };
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 12
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
useDraggable.js
3.77 KB
lrw-r--r--
2026-02-19 03:27:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
useFontVariationOverride.js
3.92 KB
lrw-r--r--
2026-03-19 23:35:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
useIframeScale.js
1.11 KB
lrw-r--r--
2026-04-16 23:02:08
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
useLockPost.js
607 B
lrw-r--r--
2026-03-24 18:55:54
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
usePortal.js
478 B
lrw-r--r--
2026-03-19 23:35:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
useResizable.js
3.17 KB
lrw-r--r--
2026-02-19 03:27:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
useSiteVibesOverride.js
2.39 KB
lrw-r--r--
2026-03-19 23:35:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
useSiteVibesVariations.js
1.82 KB
lrw-r--r--
2026-02-19 03:27:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
useThemeFontsVariations.js
1.17 KB
lrw-r--r--
2026-02-19 03:27:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
useThemeVariations.js
1.14 KB
lrw-r--r--
2025-09-09 19:55:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
useVariationOverride.js
3.14 KB
lrw-r--r--
2026-03-19 23:35:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
useWhenFinishedToolProps.js
2.20 KB
lrw-r--r--
2026-03-05 22:57:38
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).