PluginProbe
Extendify / 2.2.0
Extendify v2.2.0
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 / PageCreator / lib / processPatterns.js

processPatterns.js in Extendify 2.2.0, at src/PageCreator/lib/processPatterns.js

39 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { processPlaceholders } from '@page-creator/api/WPApi';
2 import { getActivePlugins } from '@page-creator/api/WPApi';
3 import { recordPluginActivity } from '@shared/api/DataApi';
4
5 export const processPatterns = async (patterns) => {
6 const maxAttempts = 3;
7 const delay = 1000; // 1 second delay between retries
8
9 const activePlugins =
10 (await getActivePlugins())?.data?.map((path) => path.split('/')[0]) || [];
11
12 const pluginsActivity = patterns
13 .filter((p) => p.pluginDependency)
14 .map((p) => p.pluginDependency)
15 .filter((p) => !activePlugins.includes(p));
16
17 for (const plugin of pluginsActivity) {
18 recordPluginActivity({
19 slug: plugin,
20 source: 'page-creator',
21 });
22 }
23
24 for (let attempt = 1; attempt <= maxAttempts; attempt++) {
25 try {
26 return await processPlaceholders(patterns);
27 } catch (error) {
28 if (attempt === maxAttempts) {
29 console.error(
30 `Failed to process patterns after ${maxAttempts} attempts:`,
31 error,
32 );
33 return patterns;
34 }
35 await new Promise((resolve) => setTimeout(resolve, delay));
36 }
37 }
38 };
39