PluginProbe
Extendify / 1.17.1
Extendify v1.17.1
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / src / Shared / shared.js

shared.js in Extendify 1.17.1, at src/Shared/shared.js

57 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { subscribe } from '@wordpress/data';
2 import { preFetchImages as preFetchUnsplashImages } from '@shared/lib/unsplash';
3 import '@draft/app.css';
4
5 const isOnLaunch = () => {
6 const query = new URLSearchParams(window.location.search);
7 return query.get('page') === 'extendify-launch';
8 };
9
10 (() => {
11 // Disable the page editor welcome guide always (they can manually open it)
12 const key = `WP_PREFERENCES_USER_${window.extSharedData.userId}`;
13 const existing = window.localStorage.getItem(key) || '{}';
14
15 window.localStorage.setItem(
16 key,
17 JSON.stringify({
18 ...JSON.parse(existing),
19 'core/edit-post': {
20 ...(JSON.parse(existing)?.['core/edit-post'] ?? {}),
21 welcomeGuide: false,
22 },
23 }),
24 );
25
26 if (isOnLaunch()) return;
27
28 preFetchUnsplashImages();
29
30 // TODO: If this PR is released in WP (6.7?), then we can use the localstorage
31 // approach that we use above for the welcome guide
32 // https://github.com/WordPress/gutenberg/pull/65026
33
34 // If the pattern modal shows up within 3 seconds, close it
35 const modalClass = '.editor-start-page-options__modal-content';
36 const modalCloseButton = '.components-modal__header > .components-button';
37
38 // Add CSS to hide the modal initially (avoid content paint flash)
39 const style = document.createElement('style');
40 style.innerHTML =
41 '.components-modal__screen-overlay { display: none!important }';
42 document.head.appendChild(style);
43
44 const unsub = subscribe(() => {
45 const modal = document.querySelector(modalClass);
46 if (!modal) return;
47 modal.style.display = ''; // Temp show to click it
48 document.querySelector(modalCloseButton)?.click();
49 });
50
51 setTimeout(() => {
52 // Remove the CSS rule always
53 document.head.removeChild(style);
54 unsub();
55 }, 3000);
56 })();
57