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 / PageCreator / lib / processPatterns.js

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

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