Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/extendif.../src/PageCrea.../lib
File: processPatterns.js
import { getActivePlugins, processPlaceholders } from '@page-creator/api/WPApi';
[0] Fix | Delete
import { recordPluginActivity } from '@shared/api/DataApi';
[1] Fix | Delete
[2] Fix | Delete
export const processPatterns = async (patterns) => {
[3] Fix | Delete
const maxAttempts = 3;
[4] Fix | Delete
const delay = 1000; // 1 second delay between retries
[5] Fix | Delete
[6] Fix | Delete
const activePlugins =
[7] Fix | Delete
(await getActivePlugins())?.data?.map((path) => path.split('/')[0]) || [];
[8] Fix | Delete
[9] Fix | Delete
const pluginsActivity = patterns
[10] Fix | Delete
.filter((p) => p.pluginDependency)
[11] Fix | Delete
.map((p) => p.pluginDependency)
[12] Fix | Delete
.filter((p) => !activePlugins.includes(p));
[13] Fix | Delete
[14] Fix | Delete
for (const plugin of pluginsActivity) {
[15] Fix | Delete
recordPluginActivity({
[16] Fix | Delete
slug: plugin,
[17] Fix | Delete
source: 'page-creator',
[18] Fix | Delete
});
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
[22] Fix | Delete
try {
[23] Fix | Delete
return await processPlaceholders(patterns);
[24] Fix | Delete
} catch (error) {
[25] Fix | Delete
if (attempt === maxAttempts) {
[26] Fix | Delete
console.error(
[27] Fix | Delete
`Failed to process patterns after ${maxAttempts} attempts:`,
[28] Fix | Delete
error,
[29] Fix | Delete
);
[30] Fix | Delete
return patterns;
[31] Fix | Delete
}
[32] Fix | Delete
await new Promise((resolve) => setTimeout(resolve, delay));
[33] Fix | Delete
}
[34] Fix | Delete
}
[35] Fix | Delete
};
[36] Fix | Delete
[37] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function