PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.11.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.11.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Helpers / global / addon.php

addon.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.11.1, at back/Helpers/global/addon.php

86 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use AcyMailing\Classes\PluginClass;
4
5 global $acymPlugins;
6 global $acymAddonsForSettings;
7
8 function acym_trigger(string $method, array $args = [], ?string $plugin = null, ?callable $callbackOnePlugin = null): ?array
9 {
10 if (!in_array(acym_getPrefix().'acym_configuration', acym_getTableList())) {
11 return null;
12 }
13
14 if (in_array($method, ['replaceContent', 'replaceUserInformation']) && !empty($args[0]->language)) {
15 $previousLanguage = acym_setLanguage($args[0]->language);
16 acym_loadLanguage($args[0]->language);
17 }
18
19 global $acymPlugins;
20 global $acymAddonsForSettings;
21 if (empty($acymPlugins)) {
22 acym_loadPlugins();
23 }
24
25 $result = [];
26 $listAddons = $acymPlugins;
27 if ($method === 'onAcymAddSettings') {
28 $listAddons = $acymAddonsForSettings;
29 }
30
31 foreach ($listAddons as $class => $onePlugin) {
32 if (is_callable($callbackOnePlugin)) $callbackOnePlugin($onePlugin);
33 if (!method_exists($onePlugin, $method)) continue;
34 if (!empty($plugin) && $class !== $plugin) continue;
35
36 try {
37 $value = call_user_func_array([$onePlugin, $method], $args);
38 if (isset($value)) {
39 $result[] = $value;
40 }
41
42 if (!empty($onePlugin->errors)) {
43 $onePlugin->errorCallback();
44 }
45 } catch (\Throwable $e) {
46 acym_logError('An error occurred when triggering the method '.$method.': '.$e->getMessage());
47 }
48 }
49
50 if (!empty($previousLanguage)) {
51 acym_setLanguage($previousLanguage);
52 acym_loadLanguage($previousLanguage);
53 }
54
55 return $result;
56 }
57
58 function acym_checkPluginsVersion(): bool
59 {
60 $pluginClass = new PluginClass();
61 $pluginsInstalled = $pluginClass->getMatchingElements();
62 $pluginsInstalled = $pluginsInstalled['elements'];
63
64 if (empty($pluginsInstalled)) {
65 return true;
66 }
67
68 $response = acym_fileGetContent(ACYM_UPDATEME_API_URL.'public/addons');
69 $pluginsAvailable = @json_decode($response, true);
70 if (empty($pluginsAvailable)) {
71 return true;
72 }
73
74 foreach ($pluginsInstalled as $key => $pluginInstalled) {
75 foreach ($pluginsAvailable as $pluginAvailable) {
76 if ($pluginAvailable['file_name'] === $pluginInstalled->folder_name && !version_compare($pluginInstalled->version, $pluginAvailable['version'], '>=')) {
77 $pluginInstalled->uptodate = 0;
78 $pluginInstalled->latest_version = $pluginAvailable['version'];
79 $pluginClass->save($pluginInstalled);
80 }
81 }
82 }
83
84 return true;
85 }
86