PluginProbe
Extendify / 3.1.5
Extendify v3.1.5
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 / AutoLaunch / functions / theme.js

theme.js in Extendify 3.1.5, at src/AutoLaunch/functions/theme.js

60 lines 1.7 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 import { dispatch, select } from '@wordpress/data';
3 import { __ } from '@wordpress/i18n';
4
5 const { globalStylesPostID } = window.extSharedData;
6
7 export const updateVariation = (variation) =>
8 updateThemeVariation(globalStylesPostID, variation);
9
10 export const updateThemeVariation = (id, variation = {}) => {
11 const { settings, styles } = variation;
12 if (!settings || !styles) return;
13 return apiFetch({
14 path: `wp/v2/global-styles/${id}`,
15 method: 'POST',
16 data: { id, settings, styles },
17 });
18 };
19
20 export const updateGlobalStyles = (stylesData) =>
21 apiFetch({
22 path: `wp/v2/global-styles/${globalStylesPostID}`,
23 method: 'POST',
24 data: stylesData,
25 });
26
27 export const getGlobalStyles = () =>
28 apiFetch({ path: `wp/v2/global-styles/themes/extendable?context=edit` });
29
30 export const updateTemplatePart = (slug, content) =>
31 apiFetch({
32 path: `wp/v2/template-parts/${slug}`,
33 method: 'POST',
34 data: {
35 slug,
36 theme: 'extendable',
37 type: 'wp_template_part',
38 status: 'publish',
39 // See: https://github.com/extendify/company-product/issues/833#issuecomment-1804179527
40 // translators: Launch is the product name. Unless otherwise specified by the glossary, do not translate this name.
41 description: __('Added by Launch', 'extendify-local'),
42 content,
43 },
44 });
45
46 // We set this to 'template-locked' to remove template from editor ui
47 export const setThemeRenderingMode = (mode) => {
48 const renderingModes =
49 select('core/preferences').get('core', 'renderingModes') || {};
50
51 if (renderingModes?.extendable?.page === mode) return;
52 dispatch('core/preferences').set('core', 'renderingModes', {
53 ...renderingModes,
54 extendable: {
55 ...(renderingModes.extendable || {}),
56 page: mode,
57 },
58 });
59 };
60