PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.49
E2Pdf – Export Pdf Tool for WordPress v1.32.49
1.32.49 1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 1.08.00 1.08.06 All 72 releases
← All changes | classes/controller/e2pdf-settings.php +281 -215 1.08.061.32.49 View file →
@@ -1,11 +1,10 @@
1 1 <?php
2 2
3 3 /**
4 4 * E2pdf Settings Controller
5 - *
6 5 * @copyright Copyright 2017 https://e2pdf.com
7 - * @license GPL v2
6 + * @license GPLv3
8 7 * @version 1
9 8 * @link https://e2pdf.com
10 9 * @since 0.00.01
11 10 */
@@ -18,141 +17,235 @@
18 17 /**
19 18 * @url admin.php?page=e2pdf-settings
20 19 */
21 20 public function index_action() {
22 - if ($this->post->get()) {
23 - $this->check_nonce($this->post->get('_nonce'), 'e2pdf_post');
24 - Model_E2pdf_Options::update_options('common_group', $this->post->get());
25 - $this->add_notification('update', __('Settings saved', 'e2pdf'));
26 - }
21 + if ($this->post->get('_wpnonce')) {
22 + if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_settings')) {
23 + $reload = false;
24 + if (
25 + get_option('e2pdf_debug', '0') != $this->post->get('e2pdf_debug') ||
26 + get_option('e2pdf_recovery_mode_email', '') != $this->post->get('e2pdf_recovery_mode_email') ||
27 + ($this->post->get('e2pdf_debug') && get_option('e2pdf_memory_time', '0') != $this->post->get('e2pdf_debug'))
28 + ) {
29 + $reload = true;
30 + }
27 31
28 - $options = Model_E2pdf_Options::get_options(false, array('common_group'));
29 - $groups = $this->get_groups();
32 + $check_update = false;
33 + if (get_option('e2pdf_dev_update', '0') != $this->post->get('e2pdf_dev_update')) {
34 + $check_update = true;
35 + }
30 36
31 - $this->view('options', $options);
32 - $this->view('groups', $groups);
33 - }
37 + if ($this->post->get('e2pdf_api') && $this->post->get('e2pdf_api') != get_option('e2pdf_api', 'api.e2pdf.com')) {
38 + update_option('e2pdf_cached_fonts', array());
39 + }
34 40
35 - /**
36 - * @url admin.php?page=e2pdf-settings&action=fonts
37 - */
38 - public function fonts_action() {
41 + if (get_option('e2pdf_user_email', '') != $this->post->get('e2pdf_user_email')) {
42 + $model_e2pdf_api = new Model_E2pdf_Api();
43 + $model_e2pdf_api->set(
44 + array(
45 + 'action' => 'common/owner',
46 + 'data' => array(
47 + 'email' => trim($this->post->get('e2pdf_user_email')),
48 + ),
49 + )
50 + );
51 + $request = $model_e2pdf_api->request();
39 52
40 - $model_e2pdf_font = new Model_E2pdf_Font();
41 - $groups = $this->get_groups();
53 + if (isset($request['error'])) {
54 + if ($request['error'] === 'incorrect_email') {
55 + $request['error'] = sprintf(__('An account with that E-mail address was not found at E2Pdf.com. You can register at %s', 'e2pdf'), 'https://e2pdf.com/register');
56 + }
57 + $this->post->set('e2pdf_user_email', get_option('e2pdf_user_email', ''));
58 + $this->add_notification('error', $request['error']);
59 + }
60 + }
42 61
43 - if ($this->post->get()) {
44 - $this->check_nonce($this->post->get('_nonce'), 'e2pdf_post');
62 + if (get_option('e2pdf_cache', '1') !== $this->post->get('e2pdf_cache')) {
63 + $this->helper->load('cache')->purge_objects_cache();
64 + }
45 65
46 - $allowed_ext = array(
47 - 'ttf'
48 - );
66 + if (get_option('e2pdf_cache_fonts', '1') !== $this->post->get('e2pdf_cache_fonts')) {
67 + $this->helper->load('cache')->purge_fonts_cache();
68 + }
49 69
50 - $font = $this->files->get('font');
70 + if (get_option('e2pdf_cache_pdfs', '0') !== $this->post->get('e2pdf_cache_pdfs')) {
71 + $this->helper->load('cache')->purge_pdfs_cache();
72 + }
51 73
52 - $name = $font['name'];
53 - $tmp = $font['tmp_name'];
74 + Model_E2pdf_Options::update_options('common_group', $this->post->get());
75 + $this->add_notification('update', __('Settings Saved', 'e2pdf'));
54 76
77 + if ($this->post->get('e2pdf_cache_pdfs')) {
78 + if (!wp_next_scheduled('e2pdf_cache_pdfs_cron')) {
79 + wp_schedule_event(time(), 'hourly', 'e2pdf_cache_pdfs_cron');
80 + }
81 + } else {
82 + wp_clear_scheduled_hook('e2pdf_cache_pdfs_cron');
83 + $this->helper->load('cache')->purge_pdfs_cache();
84 + }
55 85
56 - $filename = pathinfo($name, PATHINFO_FILENAME);
57 - $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
58 - $name = $filename . "." . $ext;
86 + if ($check_update) {
87 + delete_site_transient('update_plugins');
88 + }
89 + if ($reload) {
90 + $this->redirect($this->helper->get_url(array('page' => 'e2pdf-settings')));
91 + }
92 + } else {
93 + wp_die($this->message('wp_verify_nonce_error'));
94 + }
95 + }
59 96
60 - $fonts = $model_e2pdf_font->get_fonts();
97 + $this->view('options', Model_E2pdf_Options::get_options(false, array('common_group')));
98 + $this->view('groups', $this->get_groups());
99 + }
61 100
62 - $font_info = false;
63 - $exist = false;
64 -
65 - if (in_array($ext, $allowed_ext)) {
66 - $font_info = $model_e2pdf_font->get_font_info(false, 4, $tmp);
67 - if ($font_info) {
68 - $exist = array_search($font_info, $fonts);
101 + /**
102 + * @url admin.php?page=e2pdf-settings&action=maintenance
103 + */
104 + public function maintenance_action() {
105 + global $wpdb;
106 + if ($this->post->get('_wpnonce')) {
107 + if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_settings')) {
108 + if ($this->post->get('e2pdf_purge_objects_cache')) {
109 + $this->helper->load('cache')->purge_objects_cache();
110 + $this->redirect(
111 + $this->helper->get_url(
112 + [
113 + 'page' => 'e2pdf-settings',
114 + 'action' => 'maintenance',
115 + 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
116 + ]
117 + )
118 + );
119 + } elseif ($this->post->get('e2pdf_purge_fonts_cache')) {
120 + $this->helper->load('cache')->purge_fonts_cache();
121 + $this->redirect(
122 + $this->helper->get_url(
123 + [
124 + 'page' => 'e2pdf-settings',
125 + 'action' => 'maintenance',
126 + 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
127 + ]
128 + )
129 + );
130 + } elseif ($this->post->get('e2pdf_purge_pdfs_cache')) {
131 + $this->helper->load('cache')->purge_pdfs_cache();
132 + $this->redirect(
133 + $this->helper->get_url(
134 + [
135 + 'page' => 'e2pdf-settings',
136 + 'action' => 'maintenance',
137 + 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
138 + ]
139 + )
140 + );
141 + } elseif ($this->post->get('e2pdf_purge_cache')) {
142 + $this->helper->load('cache')->purge_cache();
143 + $this->redirect(
144 + $this->helper->get_url(
145 + [
146 + 'page' => 'e2pdf-settings',
147 + 'action' => 'maintenance',
148 + 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
149 + ]
150 + )
151 + );
152 + } elseif ($this->post->get('e2pdf_db_optimize')) {
153 + $db_prefix = $wpdb->prefix;
154 + $this->helper->load('db')->db_optimize($db_prefix);
155 + $this->redirect(
156 + $this->helper->get_url(
157 + [
158 + 'page' => 'e2pdf-settings',
159 + 'action' => 'maintenance',
160 + 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
161 + ]
162 + )
163 + );
164 + } elseif ($this->post->get('e2pdf_recovery_mode_limit')) {
165 + delete_option('recovery_mode_email_last_sent');
166 + $this->redirect(
167 + $this->helper->get_url(
168 + [
169 + 'page' => 'e2pdf-settings',
170 + 'action' => 'maintenance',
171 + 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
172 + ]
173 + )
174 + );
69 175 }
176 + } else {
177 + wp_die($this->message('wp_verify_nonce_error'));
70 178 }
71 -
72 - if (!$tmp) {
73 - $this->add_notification('error', __('Please choose font to upload', 'e2pdf'));
74 - } else if ($font['error']) {
75 - $this->add_notification('error', $font['error']);
76 - } elseif (!in_array($ext, $allowed_ext)) {
77 - $this->add_notification('error', __('Incorrect file extension', 'e2pdf'));
78 - } elseif (!$font_info) {
79 - $this->add_notification('error', __('Incompatible type', 'e2pdf'));
80 - } elseif (array_key_exists($name, $fonts)) {
81 - $this->add_notification('error', __('Font with this filename already exists', 'e2pdf'));
82 - } elseif ($exist) {
83 - $this->add_notification('error', __('Font with this name already exists', 'e2pdf'));
84 - } elseif (move_uploaded_file($font['tmp_name'], $this->helper->get('fonts_dir') . $name)) {
85 - $this->add_notification('update', __('Font uploaded successfully', 'e2pdf'));
86 - }
87 179 }
88 180
89 - $fonts = $model_e2pdf_font->get_fonts();
90 -
91 - $this->view('fonts', $fonts);
92 - $this->view('groups', $groups);
93 - $this->view('upload_max_filesize', $this->helper->load('files')->get_upload_max_filesize());
181 + $this->view('groups', $this->get_groups());
94 182 }
95 183
96 184 /**
97 - * @url admin.php?page=e2pdf-settings&action=adobesign
185 + * @url admin.php?page=e2pdf-settings&action=fonts
98 186 */
99 - public function adobesign_action() {
187 + public function fonts_action() {
188 + $model_e2pdf_font = new Model_E2pdf_Font();
189 + if ($this->post->get('_wpnonce')) {
100 190
101 - if ($this->post->get()) {
102 - $this->check_nonce($this->post->get('_nonce'), 'e2pdf_post');
103 - Model_E2pdf_Options::update_options('adobesign_group', $this->post->get());
104 -
105 - $model_e2pdf_adobesign = new Model_E2pdf_AdobeSign();
106 - $request = $model_e2pdf_adobesign->request_code();
107 -
108 - if (isset($request['error'])) {
109 - $this->add_notification('error', $request['error']);
110 - } elseif (isset($request['redirect'])) {
111 - $this->redirect($request['redirect']);
112 - } else {
113 - $this->add_notification('update', __('Settings saved', 'e2pdf'));
191 + if (!wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_settings')) {
192 + wp_die($this->message('wp_verify_nonce_error'));
114 193 }
115 - } elseif ($this->get->get('code') && $this->get->get('api_access_point')) {
116 - update_option('e2pdf_adobesign_code', $this->get->get('code'));
117 - update_option('e2pdf_adobesign_api_access_point', $this->get->get('api_access_point'));
118 194
119 - $model_e2pdf_adobesign = new Model_E2pdf_AdobeSign();
120 - $request = $model_e2pdf_adobesign->request_refresh_token();
121 -
122 - if (isset($request['error'])) {
123 - $this->add_notification('error', $request['error']);
195 + $file = $this->helper->load('files')->upload($this->files->get('font'), $model_e2pdf_font->get_allowed_extensions());
196 + if (isset($file['error'])) {
197 + $this->add_notification('error', $file['error']);
124 198 } else {
125 - $this->add_notification('update', __('App authorized successfully', 'e2pdf'));
199 + $font_name = false;
200 + $exist = false;
201 + $fonts = $model_e2pdf_font->get_fonts();
202 + $font_name = $model_e2pdf_font->get_font_info(false, 4, $file['tmp_name']);
203 + $name = pathinfo($file['name'], PATHINFO_FILENAME) . '.' . $file['ext'];
204 + if ($font_name) {
205 + $exist = array_search($font_name, $fonts);
206 + }
207 + if (!$font_name) {
208 + $this->add_notification('error', __('Invalid Type', 'e2pdf'));
209 + } elseif (array_key_exists($name, $fonts) || $exist) {
210 + $this->add_notification('error', __('A Font with this name already exists', 'e2pdf'));
211 + } else {
212 + if (!move_uploaded_file($file['tmp_name'], $this->helper->get('fonts_dir') . $name)) {
213 + $this->add_notification('error', __('Failed to move uploaded file', 'e2pdf'));
214 + } else {
215 + $this->add_notification('update', __('Font Uploaded', 'e2pdf'));
216 + }
217 + }
126 218 }
127 - $location = $this->helper->get_url(array('page' => 'e2pdf-settings', 'action' => 'adobesign'));
128 - $this->redirect($location);
129 - return;
130 219 }
131 220
132 - $options = Model_E2pdf_Options::get_options(false, array('adobesign_group'));
221 + $fonts = $model_e2pdf_font->get_fonts();
133 222
134 - $this->view('options', $options);
135 - $groups = $this->get_groups();
136 - $this->view('groups', $groups);
223 + $this->view('fonts', $fonts);
224 + $this->view('allowed_extensions', $model_e2pdf_font->get_allowed_extensions());
225 + $this->view('cached_fonts', get_option('e2pdf_cached_fonts', array()));
226 + $this->view('groups', $this->get_groups());
227 + $this->view('upload_max_filesize', $this->helper->load('files')->get_upload_max_filesize());
137 228 }
138 229
139 230 /**
140 - * @url admin.php?page=e2pdf-settings&action=docusign
231 + * @url admin.php?page=e2pdf-settings&action=adobesign
232 + * Backward Compatibility
141 233 */
142 - public function docusign_action() {
143 -
144 - if ($this->post->get()) {
145 - $this->check_nonce($this->post->get('_nonce'), 'e2pdf_post');
146 - Model_E2pdf_Options::update_options('docusign_group', $this->post->get());
147 - $this->add_notification('update', __('Settings saved', 'e2pdf'));
234 + public function adobesign_action() {
235 + $redirect_url = [
236 + 'page' => 'e2pdf-integrations',
237 + 'action' => 'adobesign',
238 + ];
239 + if ($this->get->get('code') && get_option('e2pdf_adobesign_client_id', '') && get_option('e2pdf_adobesign_client_secret', '')) {
240 + $redirect_url['code'] = $this->get->get('code');
241 + $redirect_url['_wpnonce'] = wp_create_nonce('e2pdf_adobe');
148 242 }
149 -
150 - $options = Model_E2pdf_Options::get_options(false, array('docusign_group'));
151 -
152 - $this->view('options', $options);
153 - $groups = $this->get_groups();
154 - $this->view('groups', $groups);
243 + $this->redirect(
244 + $this->helper->get_url(
245 + $redirect_url
246 + )
247 + );
155 248 }
156 249
157 250 /**
158 251 * @url admin.php?page=e2pdf-settings&action=extension
@@ -157,22 +250,20 @@
157 250 /**
158 251 * @url admin.php?page=e2pdf-settings&action=extension
159 252 */
160 253 public function extension_action() {
161 -
162 254 $group_key = $this->get->get('group');
163 -
164 - if ($this->post->get()) {
165 - $this->check_nonce($this->post->get('_nonce'), 'e2pdf_post');
166 - Model_E2pdf_Options::update_options($group_key, $this->post->get());
167 - $this->add_notification('update', __('Settings saved', 'e2pdf'));
255 + if ($this->post->get('_wpnonce')) {
256 + if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_settings')) {
257 + Model_E2pdf_Options::update_options($group_key, $this->post->get());
258 + $this->add_notification('update', __('Settings Saved', 'e2pdf'));
259 + } else {
260 + wp_die($this->message('wp_verify_nonce_error'));
261 + }
168 262 }
169 263
170 - $options = Model_E2pdf_Options::get_options(false, array($group_key));
171 - $groups = $this->get_groups();
172 -
173 - $this->view('options', $options);
174 - $this->view('groups', $groups);
264 + $this->view('options', Model_E2pdf_Options::get_options(false, array($group_key)));
265 + $this->view('groups', $this->get_groups());
175 266 }
176 267
177 268 /**
178 269 * @url admin.php?page=e2pdf-settings&action=extensions
@@ -178,26 +269,30 @@
178 269 * @url admin.php?page=e2pdf-settings&action=extensions
179 270 */
180 271 public function extensions_action() {
181 272
182 - if ($this->post->get()) {
183 -
184 - $this->check_nonce($this->post->get('_nonce'), 'e2pdf_post');
185 -
186 - if (!$this->post->get('e2pdf_disabled_extensions')) {
187 - update_option('e2pdf_disabled_extensions', array());
273 + if ($this->post->get('_wpnonce')) {
274 + if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_settings')) {
275 + if (!$this->post->get('e2pdf_disabled_extensions')) {
276 + update_option('e2pdf_disabled_extensions', array());
277 + } else {
278 + update_option('e2pdf_disabled_extensions', array_filter($this->post->get('e2pdf_disabled_extensions')));
279 + }
280 + $this->redirect(
281 + $this->helper->get_url(
282 + [
283 + 'page' => 'e2pdf-settings',
284 + 'action' => 'extensions',
285 + 'notification' => $this->add_notification('update', __('Settings Saved', 'e2pdf')),
286 + ]
287 + )
288 + );
188 289 } else {
189 - update_option('e2pdf_disabled_extensions', $this->post->get('e2pdf_disabled_extensions'));
290 + wp_die($this->message('wp_verify_nonce_error'));
190 291 }
191 -
192 - $this->add_notification('update', __('Settings saved', 'e2pdf'));
193 292 }
194 -
195 - $options = Model_E2pdf_Options::get_options(false, array('extensions_group'));
196 - $groups = $this->get_groups();
197 -
198 - $this->view('options', $options);
199 - $this->view('groups', $groups);
293 + $this->view('options', Model_E2pdf_Options::get_options(false, array('extensions_group')));
294 + $this->view('groups', $this->get_groups());
200 295 }
201 296
202 297 /**
203 298 * @url admin.php?page=e2pdf-settings&action=permissions
@@ -202,31 +297,33 @@
202 297 /**
203 298 * @url admin.php?page=e2pdf-settings&action=permissions
204 299 */
205 300 public function permissions_action() {
206 - if ($this->post->get()) {
207 - $this->check_nonce($this->post->get('_nonce'), 'e2pdf_post');
208 - $permissions = $this->post->get('permissions');
209 - $roles = wp_roles()->roles;
210 - $caps = $this->helper->get_caps();
211 - foreach ($permissions as $permission_key => $permission) {
212 - $role = get_role($permission_key);
213 - if ($role) {
214 - foreach ($permission as $cap_key => $cap) {
215 - if (isset($caps[$cap_key])) {
216 - if ($cap) {
217 - $role->add_cap($cap_key);
218 - } else {
219 - $role->remove_cap($cap_key);
301 + if ($this->post->get('_wpnonce')) {
302 + if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_settings')) {
303 + $permissions = $this->post->get('permissions');
304 + $roles = wp_roles()->roles;
305 + $caps = $this->helper->get_caps();
306 + foreach ($permissions as $permission_key => $permission) {
307 + $role = get_role($permission_key);
308 + if ($role) {
309 + foreach ($permission as $cap_key => $cap) {
310 + if (isset($caps[$cap_key])) {
311 + if ($cap) {
312 + $role->add_cap($cap_key);
313 + } else {
314 + $role->remove_cap($cap_key);
315 + }
220 316 }
221 317 }
222 318 }
223 319 }
320 + $this->add_notification('update', __('Settings Saved', 'e2pdf'));
321 + } else {
322 + wp_die($this->message('wp_verify_nonce_error'));
224 323 }
225 - $this->add_notification('update', __('Settings saved', 'e2pdf'));
226 324 }
227 325
228 - $groups = $this->get_groups();
229 326 $roles = wp_roles()->roles;
230 327 foreach ($roles as $role_key => $role) {
231 328 if (isset($role['capabilities']['manage_options']) && $role['capabilities']['manage_options']) {
232 329 unset($roles[$role_key]);
@@ -231,24 +328,45 @@
231 328 if (isset($role['capabilities']['manage_options']) && $role['capabilities']['manage_options']) {
232 329 unset($roles[$role_key]);
233 330 }
234 331 }
235 - $caps = $this->helper->get_caps();
236 332
237 - $this->view('groups', $groups);
333 + $this->view('groups', $this->get_groups());
238 334 $this->view('roles', $roles);
239 - $this->view('caps', $caps);
335 + $this->view('caps', $this->helper->get_caps());
240 336 }
241 337
242 338 /**
339 + * @url admin.php?page=e2pdf-settings&action=extensions
340 + */
341 + public function translation_action() {
342 + if ($this->post->get('_wpnonce')) {
343 + if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_settings')) {
344 + Model_E2pdf_Options::update_options('translation_group', $this->post->get());
345 + $this->add_notification('update', __('Settings Saved', 'e2pdf'));
346 + } else {
347 + wp_die($this->message('wp_verify_nonce_error'));
348 + }
349 + }
350 + $this->view('options', Model_E2pdf_Options::get_options(false, array('translation_group')));
351 + $this->view('groups', $this->get_groups());
352 + }
353 +
354 + /**
243 355 * Get options list
244 - *
245 356 * @return array() - Options list
246 357 */
247 358 public function get_groups() {
248 - $groups = Model_E2pdf_Options::get_options(false, array(
359 + $groups = Model_E2pdf_Options::get_options(
360 + false,
361 + array(
249 362 'static_group',
250 - ), true);
363 + 'adobesign_group',
364 + 'gdrive_group',
365 + 'zapier_group',
366 + ),
367 + true
368 + );
251 369
252 370 return $groups;
253 371 }
254 372
@@ -255,79 +373,27 @@
255 373 /**
256 374 * Remove font via ajax
257 375 * action: wp_ajax_e2pdf_delete_font
258 376 * function: e2pdf_delete_font
259 - *
260 377 * @return json
261 378 */
262 379 public function ajax_delete_font() {
263 -
264 - $this->check_nonce($this->get->get('_nonce'), 'e2pdf_ajax');
265 - $font = $this->post->get('data');
266 -
267 - $model_e2pdf_font = new Model_E2pdf_Font();
268 - $model_e2pdf_font->delete_font($font);
269 -
270 - $response = array(
271 - 'redirect' => $this->helper->get_url(array(
272 - 'page' => 'e2pdf-settings',
273 - 'action' => 'fonts'
274 - )
275 - )
276 - );
277 -
278 - $this->add_notification('update', __('Font removed successfully', 'e2pdf'));
279 - $this->json_response($response);
280 - }
281 -
282 - /**
283 - * Confirm Email via ajax
284 - * action: wp_ajax_e2pdf_email
285 - * function: e2pdf_email
286 - *
287 - * @return json
288 - */
289 - public function ajax_email() {
290 - $this->check_nonce($this->get->get('_nonce'), 'e2pdf_ajax');
291 -
292 - $data = $this->post->get('data');
293 - $email = isset($data['email']) ? trim($data['email']) : '';
294 - $email_code = isset($data['email_code']) ? trim($data['email_code']) : '';
295 -
296 - $model_e2pdf_api = new Model_E2pdf_Api();
297 - $model_e2pdf_api->set(array(
298 - 'action' => 'common/email',
299 - 'data' => array(
300 - 'email' => $email,
301 - 'email_code' => $email_code,
302 - 'email_confirm' => isset($data['email_code'])
303 - )
304 - ));
305 - $request = $model_e2pdf_api->request();
306 -
307 - if (isset($request['error'])) {
308 - if ($request['error'] === 'incorrect_email') {
309 - $response = array(
310 - 'error' => __('E-mail address incorrect', 'e2pdf')
311 - );
312 - } elseif ($request['error'] === 'incorrect_code') {
313 - $response = array(
314 - 'error' => __('Confirmation code incorrect', 'e2pdf')
315 - );
316 - } else {
317 - $response = array(
318 - 'error' => $request['error']
319 - );
320 - }
321 - } elseif (isset($request['success'])) {
380 + if (wp_verify_nonce($this->get->get('_wpnonce'), 'e2pdf_settings')) {
381 + $font = $this->post->get('data');
382 + $model_e2pdf_font = new Model_E2pdf_Font();
383 + $model_e2pdf_font->delete_font($font);
322 384 $response = array(
323 - 'content' => $request['success']
385 + 'redirect' => $this->helper->get_url(
386 + array(
387 + 'page' => 'e2pdf-settings',
388 + 'action' => 'fonts',
389 + 'notification' => $this->add_notification('update', __('Font Deleted', 'e2pdf')),
390 + )
391 + ),
324 392 );
325 - if ($request['success'] == 'subscribed') {
326 - update_option('e2pdf_email', $email);
327 - }
393 + } else {
394 + $response['error'] = $this->message('wp_verify_nonce_error');
328 395 }
329 396
330 397 $this->json_response($response);
331 398 }
332 -
333 399 }