| 1 |
import apiFetch from '@wordpress/api-fetch'; |
| 2 |
import { __ } from '@wordpress/i18n'; |
| 3 |
import { addQueryArgs } from '@wordpress/url'; |
| 4 |
|
| 5 |
export const getSiteStyle = async () => { |
| 6 |
const siteStyles = await apiFetch({ |
| 7 |
method: 'GET', |
| 8 |
path: addQueryArgs('/extendify/v1/page-creator/settings/get-option', { |
| 9 |
name: 'extendify_siteStyle', |
| 10 |
}), |
| 11 |
}); |
| 12 |
|
| 13 |
if (siteStyles) return siteStyles; |
| 14 |
|
| 15 |
return { vibe: 'standard' }; |
| 16 |
}; |
| 17 |
|
| 18 |
export const updateOption = async (option, value) => |
| 19 |
await apiFetch({ |
| 20 |
path: '/extendify/v1/page-creator/settings/single', |
| 21 |
method: 'POST', |
| 22 |
data: { key: option, value }, |
| 23 |
}); |
| 24 |
|
| 25 |
export const processPlaceholders = (patterns) => |
| 26 |
apiFetch({ |
| 27 |
path: '/extendify/v1/shared/process-placeholders', |
| 28 |
method: 'POST', |
| 29 |
data: { patterns }, |
| 30 |
}); |
| 31 |
|
| 32 |
export const updatePageTitlePattern = (pageTitlePattern) => { |
| 33 |
const templateContent = ` |
| 34 |
<!-- wp:template-part {"slug":"header","tagName":"header"} /--> |
| 35 |
<!-- wp:group {"tagName":"main","style":{"spacing":{"margin":{"top":"0px","bottom":"0px"},"blockGap":"0"}}} --> |
| 36 |
<main class="wp-block-group" style="margin-top:0px;margin-bottom:0px"> |
| 37 |
${pageTitlePattern} |
| 38 |
<!-- wp:post-content {"layout":{"type":"constrained"}} /--> |
| 39 |
</main> |
| 40 |
<!-- /wp:group --> |
| 41 |
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /--> |
| 42 |
`; |
| 43 |
|
| 44 |
return apiFetch({ |
| 45 |
path: '/wp/v2/templates/extendable/page-with-title', |
| 46 |
method: 'POST', |
| 47 |
data: { |
| 48 |
slug: 'page-with-title', |
| 49 |
theme: 'extendable', |
| 50 |
type: 'wp_template', |
| 51 |
status: 'publish', |
| 52 |
description: __('Added by Launch', 'extendify-local'), |
| 53 |
content: templateContent, |
| 54 |
}, |
| 55 |
}); |
| 56 |
}; |
| 57 |
|
| 58 |
export const getActivePlugins = async () => |
| 59 |
await apiFetch({ |
| 60 |
path: '/extendify/v1/launch/active-plugins', |
| 61 |
method: 'GET', |
| 62 |
}); |
| 63 |
|