PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.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
← All changes | back/Classes/PluginClass.php +0 -145 10.10.2 → 11.1.1 View file →
@@ -1,145 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Classes;
4 -
5 -use AcyMailing\Core\AcymClass;
6 -
7 -class PluginClass extends AcymClass
8 -{
9 - private array $plugins = [];
10 -
11 - public function __construct()
12 - {
13 - parent::__construct();
14 -
15 - $this->table = 'plugin';
16 - $this->pkey = 'id';
17 - }
18 -
19 - public function getPlugins(): array
20 - {
21 - global $acymPluginByFolderName;
22 - if (empty($acymPluginByFolderName)) {
23 - $acymPluginByFolderName = $this->getAll('folder_name');
24 - }
25 -
26 - $this->plugins = $acymPluginByFolderName;
27 -
28 - return $this->plugins;
29 - }
30 -
31 - public function getOnePluginByFolderName(string $folderName): ?object
32 - {
33 - $plugins = $this->getPlugins();
34 -
35 - return $plugins[$folderName] ?? null;
36 - }
37 -
38 - public function getNotUptoDatePlugins(): array
39 - {
40 - $result = acym_loadResult('SHOW TABLES LIKE "%_acym_plugin"');
41 - if (empty($result)) {
42 - return [];
43 - }
44 -
45 - return acym_loadResultArray('SELECT folder_name FROM #__acym_plugin WHERE uptodate = 0');
46 - }
47 -
48 - public function addIntegrationIfMissing(object $plugin): void
49 - {
50 - if (empty($plugin->pluginDescription->name)) {
51 - return;
52 - }
53 -
54 - $plugins = $this->getPlugins();
55 - $data = $plugins[$plugin->name] ?? null;
56 -
57 - $newPlugin = new \stdClass();
58 - $newPlugin->title = $plugin->pluginDescription->name;
59 - $newPlugin->folder_name = $plugin->name;
60 - $newPlugin->version = '1.0';
61 - $newPlugin->active = 1;
62 - $newPlugin->category = $plugin->pluginDescription->category;
63 - $newPlugin->level = 'starter';
64 - $newPlugin->uptodate = 1;
65 - $newPlugin->description = $plugin->pluginDescription->description;
66 - $newPlugin->latest_version = '1.0';
67 - $newPlugin->type = 'PLUGIN';
68 -
69 - if (!empty($data)) {
70 - $newPlugin->id = $data->id;
71 - $newPlugin->settings = $data->settings;
72 -
73 - if ($data->type !== 'ADDON') {
74 - return;
75 - }
76 -
77 -
78 - if (file_exists(ACYM_ADDONS_FOLDER_PATH.$plugin->name)) {
79 - acym_deleteFolder(ACYM_ADDONS_FOLDER_PATH.$plugin->name);
80 - }
81 - }
82 -
83 - $this->save($newPlugin);
84 - }
85 -
86 - public function enable(string $folderName): void
87 - {
88 - $plugin = $this->getOnePluginByFolderName($folderName);
89 - if (empty($plugin)) return;
90 -
91 - $plugin->active = 1;
92 - $this->save($plugin);
93 - }
94 -
95 - public function disable(string $folderName): void
96 - {
97 - $plugin = $this->getOnePluginByFolderName($folderName);
98 - if (empty($plugin)) return;
99 -
100 - $plugin->active = 0;
101 - $this->save($plugin);
102 - }
103 -
104 - public function deleteByFolderName(string $folderName): void
105 - {
106 - $plugin = $this->getOnePluginByFolderName($folderName);
107 - if (empty($plugin)) return;
108 -
109 - parent::delete($plugin->id);
110 - }
111 -
112 - public function updateAddon(string $addon): ?int
113 - {
114 - $plugin = $this->getOnePluginByFolderName($addon);
115 -
116 - if (empty($plugin)) {
117 - return null;
118 - }
119 -
120 - $pluginClass = new PluginClass();
121 - $pluginClass->downloadAddon($addon);
122 -
123 - $pluginToSave = new \stdClass();
124 - $pluginToSave->id = $plugin->id;
125 - $pluginToSave->version = $plugin->latest_version;
126 - $pluginToSave->uptodate = 1;
127 -
128 - return (int)$this->save($pluginToSave);
129 - }
130 -
131 - public function downloadAddon(string $name, bool $ajax = true): ?string
132 - {
133 -
134 - return null;
135 - }
136 -
137 - private function handleError(string $error, bool $ajax): string
138 - {
139 - if ($ajax) {
140 - acym_sendAjaxResponse(acym_translation($error), [], false);
141 - }
142 -
143 - return acym_translation($error);
144 - }
145 -}