PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.7.2
Block Animations, Motion & Scroll Effects – Ghost Kit v3.7.2
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / store / plugins / customizer / controls.js

controls.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.7.2, at gutenberg/store/plugins/customizer/controls.js

56 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import apiFetch from '@wordpress/api-fetch';
2
3 export function API_FETCH({ request }) {
4 // create iframe with customizer url to prepare customizer data.
5 async function maybeGetCustomizerData() {
6 const promise = new Promise((resolve) => {
7 const iframe = document.createElement('iframe');
8 iframe.style.display = 'none';
9 iframe.onload = () => {
10 iframe.parentNode.removeChild(iframe);
11 resolve();
12 };
13 iframe.src = `${window.GHOSTKIT.adminUrl}customize.php`;
14 document.body.appendChild(iframe);
15 });
16
17 return promise;
18 }
19
20 return apiFetch(request)
21 .catch(async (fetchedData) => {
22 // try to get customizer data.
23 if (
24 fetchedData &&
25 fetchedData.error &&
26 fetchedData.error_code === 'no_options_found'
27 ) {
28 await maybeGetCustomizerData();
29 return apiFetch(request);
30 }
31
32 return fetchedData;
33 })
34 .catch((fetchedData) => {
35 if (
36 fetchedData &&
37 fetchedData.error &&
38 fetchedData.error_code === 'no_options_found'
39 ) {
40 return {
41 response: {},
42 error: false,
43 success: true,
44 };
45 }
46
47 return false;
48 })
49 .then((fetchedData) => {
50 if (fetchedData && fetchedData.success && fetchedData.response) {
51 return fetchedData.response;
52 }
53 return {};
54 });
55 }
56