| @@ -18,8 +18,11 @@ | ||
| 18 | 18 | $data['level'] = $this->level; |
| 19 | 19 | $data['plugins'] = $this->getAllPlugins(); |
| 20 | 20 | $data['workflowHelper'] = new WorkflowHelper(); |
| 21 | 21 | |
| 22 | + acym_addScript(true, 'window.acymailingAddons = '.json_encode($data['plugins']).';'); | |
| 23 | + acym_addScript(true, 'window.acymailingAvailableAddons = '.json_encode(ACYM_AVAILABLE_PLUGINS).';'); | |
| 24 | + | |
| 22 | 25 | parent::display($data); |
| 23 | 26 | } |
| 24 | 27 | |
| 25 | 28 | public function checkUpdates(): void |
| @@ -29,8 +32,10 @@ | ||
| 29 | 32 | } |
| 30 | 33 | |
| 31 | 34 | public function saveSettings(): void |
| 32 | 35 | { |
| 36 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 37 | + | |
| 33 | 38 | $pluginFolderName = acym_getVar('string', 'plugin__folder_name', ''); |
| 34 | 39 | |
| 35 | 40 | if (empty($pluginFolderName)) { |
| 36 | 41 | acym_enqueueMessage(acym_translation('ACYM_COULD_NOT_SAVE_SETTINGS')); |
| @@ -84,8 +89,10 @@ | ||
| 84 | 89 | } |
| 85 | 90 | |
| 86 | 91 | public function update(): void |
| 87 | 92 | { |
| 93 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 94 | + | |
| 88 | 95 | $this->isLatestAcyMailingVersion(); |
| 89 | 96 | |
| 90 | 97 | $plugin = acym_getVar('array', 'plugin'); |
| 91 | 98 | |
| @@ -99,8 +106,10 @@ | ||
| 99 | 106 | } |
| 100 | 107 | |
| 101 | 108 | public function deletePlugin(): void |
| 102 | 109 | { |
| 110 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 111 | + | |
| 103 | 112 | $pluginClass = new PluginClass(); |
| 104 | 113 | $id = acym_getVar('int', 'id'); |
| 105 | 114 | |
| 106 | 115 | $plugin = $pluginClass->getOneById($id); |
| @@ -112,9 +121,9 @@ | ||
| 112 | 121 | $routePlugin = dirname(acym_getPluginPath($plugin->folder_name)); |
| 113 | 122 | |
| 114 | 123 | if (file_exists($routePlugin)) { |
| 115 | 124 | acym_deleteFolder($routePlugin); |
| 116 | - if ($pluginClass->delete($id)) { | |
| 125 | + if ($pluginClass->delete([$id])) { | |
| 117 | 126 | acym_sendAjaxResponse(acym_translation('ACYM_ADD_ON_SUCCESSFULLY_DELETED')); |
| 118 | 127 | } |
| 119 | 128 | } |
| 120 | 129 | acym_sendAjaxResponse(acym_translation('ACYM_ADD_ON_NOT_FOUND'), [], false); |
| @@ -121,8 +130,10 @@ | ||
| 121 | 130 | } |
| 122 | 131 | |
| 123 | 132 | public function toggleActivate(): void |
| 124 | 133 | { |
| 134 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 135 | + | |
| 125 | 136 | $pluginClass = new PluginClass(); |
| 126 | 137 | $id = acym_getVar('int', 'id'); |
| 127 | 138 | |
| 128 | 139 | $plugin = $pluginClass->getOneById($id); |
| @@ -133,9 +144,10 @@ | ||
| 133 | 144 | } |
| 134 | 145 | |
| 135 | 146 | $plugin->active = $plugin->active == 0 ? 1 : 0; |
| 136 | 147 | |
| 137 | - if (!$pluginClass->save($plugin)) { | |
| 148 | + $savedPluginId = $pluginClass->save($plugin); | |
| 149 | + if (empty($savedPluginId)) { | |
| 138 | 150 | acym_sendAjaxResponse(acym_translation('ACYM_COULD_NOT_SAVE_ADD_ON'), [], false); |
| 139 | 151 | } |
| 140 | 152 | |
| 141 | 153 | acym_sendAjaxResponse(); |
| @@ -142,8 +154,10 @@ | ||
| 142 | 154 | } |
| 143 | 155 | |
| 144 | 156 | public function getCustomViewPlugin(): void |
| 145 | 157 | { |
| 158 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 159 | + | |
| 146 | 160 | $plugin = $this->getPluginClassAjaxCustomView(); |
| 147 | 161 | |
| 148 | 162 | $customLayoutPath = ACYM_CUSTOM_PLUGIN_LAYOUT.$plugin['folderName'].'.html'; |
| 149 | 163 | |
| @@ -156,8 +170,10 @@ | ||
| 156 | 170 | } |
| 157 | 171 | |
| 158 | 172 | public function saveCustomViewPlugin(): void |
| 159 | 173 | { |
| 174 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 175 | + | |
| 160 | 176 | $plugin = $this->getPluginClassAjaxCustomView(); |
| 161 | 177 | $pluginCustomView = acym_getVar('string', 'custom_view', ''); |
| 162 | 178 | $pluginCustomView = urldecode($pluginCustomView); |
| 163 | 179 | |
| @@ -173,8 +189,10 @@ | ||
| 173 | 189 | } |
| 174 | 190 | |
| 175 | 191 | public function deleteCustomViewPlugin(): void |
| 176 | 192 | { |
| 193 | + wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token'); | |
| 194 | + | |
| 177 | 195 | $plugin = $this->getPluginClassAjaxCustomView(); |
| 178 | 196 | |
| 179 | 197 | $customLayoutPath = ACYM_CUSTOM_PLUGIN_LAYOUT.$plugin['folderName'].'.html'; |
| 180 | 198 | |