PluginProbe
Extendify / trunk
Extendify vtrunk
3.2.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 All 127 releases
← All changes | src/AutoLaunch/functions/pages.js +11 -8 3.1.4 → trunk View file →
@@ -1,11 +1,12 @@
1 1 import { importImage, updateOption } from '@auto-launch/functions/wp';
2 +import { launchStrings } from '@auto-launch/strings';
2 3 import { PATTERNS_HOST } from '@constants';
3 4 import { reqDataBasics } from '@shared/lib/data';
4 5 import { pageNames } from '@shared/lib/pages';
5 6 import apiFetch from '@wordpress/api-fetch';
6 7 import { createBlock, parse, serialize } from '@wordpress/blocks';
7 -import { __, sprintf } from '@wordpress/i18n';
8 +import { __ } from '@wordpress/i18n';
8 9 import { setStatus } from './helpers';
9 10
10 11 // Slugs that plugins own — skip creating design-build pages for these.
11 12 export const PLUGIN_OWNED_PAGES = [
@@ -125,8 +126,15 @@
125 126
126 127 return serialize(parse(rawHTML).map(walk));
127 128 };
128 129
130 +// navSlug: the design menu entry this section was picked for (applyDesignBuildNav).
131 +export const sectionSlug = (pattern) =>
132 + pattern.navSlug ??
133 + Object.values(pageNames).find(({ alias }) =>
134 + alias.includes(pattern.patternTypes?.[0]),
135 + )?.slug;
136 +
129 137 export const createWpPages = async (
130 138 pagesRaw,
131 139 { skipSectionIds = false } = {},
132 140 ) => {
@@ -135,18 +143,13 @@
135 143 for (const page of pagesRaw) {
136 144 const content = [];
137 145 const seenPatternTypes = new Set();
138 146
139 - setStatus(sprintf(__('Adding page: %s', 'extendify-local'), page.name));
147 + setStatus(launchStrings().statusAddingPage(page.name));
140 148
141 149 for (const [_, pattern] of page.patterns.entries()) {
142 150 const code = pattern.code;
143 - const patternType = pattern.patternTypes?.[0];
144 -
145 - const { slug } =
146 - Object.values(pageNames).find(({ alias }) =>
147 - alias.includes(patternType),
148 - ) || {};
151 + const slug = sectionSlug(pattern);
149 152
150 153 if (skipSectionIds || seenPatternTypes.has(slug) || !slug) {
151 154 content.push(code);
152 155 continue;