| @@ -16,8 +16,10 @@ | ||
| 16 | 16 | $data['types'] = $this->types; |
| 17 | 17 | $data['level'] = $this->level; |
| 18 | 18 | $data['workflowHelper'] = new WorkflowHelper(); |
| 19 | 19 | |
| 20 | + acym_addScript(true, 'window.acymailingAvailableAddons = '.json_encode(ACYM_AVAILABLE_PLUGINS).';'); | |
| 21 | + | |
| 20 | 22 | parent::display($data); |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | 25 | public function download(bool $ajax = true, string $pluginFromUpdate = ''): string |
| @@ -24,8 +26,9 @@ | ||
| 24 | 26 | { |
| 25 | 27 | $plugin = []; |
| 26 | 28 | |
| 27 | 29 | if (empty($pluginFromUpdate)) { |
| 30 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 28 | 31 | $this->isLatestAcyMailingVersion(); |
| 29 | 32 | $plugin = acym_getVar('array', 'plugin'); |
| 30 | 33 | } else { |
| 31 | 34 | $plugins = acym_fileGetContent(ACYM_UPDATEME_API_URL.'public/addons'); |
| @@ -46,10 +49,14 @@ | ||
| 46 | 49 | } |
| 47 | 50 | } |
| 48 | 51 | |
| 49 | 52 | $pluginClass = new PluginClass(); |
| 50 | - $pluginClass->downloadAddon($plugin['file_name'], $ajax); | |
| 53 | + $errorMessage = $pluginClass->downloadAddon($plugin['file_name'], $ajax); | |
| 54 | + if (!empty($errorMessage)) { | |
| 55 | + return $errorMessage; | |
| 56 | + } | |
| 51 | 57 | |
| 58 | + // We update the plugin info in DB | |
| 52 | 59 | $pluginToSave = new \stdClass(); |
| 53 | 60 | $pluginToSave->title = $plugin['name']; |
| 54 | 61 | $pluginToSave->folder_name = $plugin['file_name']; |
| 55 | 62 | $pluginToSave->version = $plugin['version']; |
| @@ -73,12 +80,13 @@ | ||
| 73 | 80 | } |
| 74 | 81 | |
| 75 | 82 | public function getAllPluginsAjax(): void |
| 76 | 83 | { |
| 84 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 77 | 85 | acym_sendAjaxResponse('', $this->getAllPlugins()); |
| 78 | 86 | } |
| 79 | 87 | |
| 80 | - public function getAllPlugins(): array | |
| 88 | + private function getAllPlugins(): array | |
| 81 | 89 | { |
| 82 | 90 | $pluginClass = new PluginClass(); |
| 83 | 91 | $plugins = $pluginClass->getMatchingElements(['ordering' => 'title']); |
| 84 | 92 | |