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 +47 -54 1.32.151.32.49 View file →
@@ -71,9 +71,9 @@
71 71 $this->helper->load('cache')->purge_pdfs_cache();
72 72 }
73 73
74 74 Model_E2pdf_Options::update_options('common_group', $this->post->get());
75 - $this->add_notification('update', sprintf(__('Success: %s', 'e2pdf'), __('Settings Saved', 'e2pdf')));
75 + $this->add_notification('update', __('Settings Saved', 'e2pdf'));
76 76
77 77 if ($this->post->get('e2pdf_cache_pdfs')) {
78 78 if (!wp_next_scheduled('e2pdf_cache_pdfs_cron')) {
79 79 wp_schedule_event(time(), 'hourly', 'e2pdf_cache_pdfs_cron');
@@ -106,71 +106,71 @@
106 106 if ($this->post->get('_wpnonce')) {
107 107 if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_settings')) {
108 108 if ($this->post->get('e2pdf_purge_objects_cache')) {
109 109 $this->helper->load('cache')->purge_objects_cache();
110 - $this->add_notification('update', sprintf(__('Success: %s', 'e2pdf'), __('Purge Objects Cache', 'e2pdf')));
111 110 $this->redirect(
112 111 $this->helper->get_url(
113 - array(
112 + [
114 113 'page' => 'e2pdf-settings',
115 114 'action' => 'maintenance',
116 - )
115 + 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
116 + ]
117 117 )
118 118 );
119 119 } elseif ($this->post->get('e2pdf_purge_fonts_cache')) {
120 120 $this->helper->load('cache')->purge_fonts_cache();
121 - $this->add_notification('update', sprintf(__('Success: %s', 'e2pdf'), __('Purge Fonts Cache', 'e2pdf')));
122 121 $this->redirect(
123 122 $this->helper->get_url(
124 - array(
123 + [
125 124 'page' => 'e2pdf-settings',
126 125 'action' => 'maintenance',
127 - )
126 + 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
127 + ]
128 128 )
129 129 );
130 130 } elseif ($this->post->get('e2pdf_purge_pdfs_cache')) {
131 131 $this->helper->load('cache')->purge_pdfs_cache();
132 - $this->add_notification('update', sprintf(__('Success: %s', 'e2pdf'), __('Purge PDFs Cache', 'e2pdf')));
133 132 $this->redirect(
134 133 $this->helper->get_url(
135 - array(
134 + [
136 135 'page' => 'e2pdf-settings',
137 136 'action' => 'maintenance',
138 - )
137 + 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
138 + ]
139 139 )
140 140 );
141 141 } elseif ($this->post->get('e2pdf_purge_cache')) {
142 142 $this->helper->load('cache')->purge_cache();
143 - $this->add_notification('update', sprintf(__('Success: %s', 'e2pdf'), __('Purge Full Cache', 'e2pdf')));
144 143 $this->redirect(
145 144 $this->helper->get_url(
146 - array(
145 + [
147 146 'page' => 'e2pdf-settings',
148 147 'action' => 'maintenance',
149 - )
148 + 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
149 + ]
150 150 )
151 151 );
152 152 } elseif ($this->post->get('e2pdf_db_optimize')) {
153 153 $db_prefix = $wpdb->prefix;
154 154 $this->helper->load('db')->db_optimize($db_prefix);
155 - $this->add_notification('update', sprintf(__('Success: %s', 'e2pdf'), __('Optimize DB', 'e2pdf')));
156 155 $this->redirect(
157 156 $this->helper->get_url(
158 - array(
157 + [
159 158 'page' => 'e2pdf-settings',
160 159 'action' => 'maintenance',
161 - )
160 + 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
161 + ]
162 162 )
163 163 );
164 164 } elseif ($this->post->get('e2pdf_recovery_mode_limit')) {
165 165 delete_option('recovery_mode_email_last_sent');
166 - $this->add_notification('update', sprintf(__('Success: %s', 'e2pdf'), __('Clear Recovery Mode Limit', 'e2pdf')));
167 166 $this->redirect(
168 167 $this->helper->get_url(
169 - array(
168 + [
170 169 'page' => 'e2pdf-settings',
171 170 'action' => 'maintenance',
172 - )
171 + 'notification' => $this->add_notification('update', __('Success', 'e2pdf')),
172 + ]
173 173 )
174 174 );
175 175 }
176 176 } else {
@@ -186,43 +186,36 @@
186 186 */
187 187 public function fonts_action() {
188 188 $model_e2pdf_font = new Model_E2pdf_Font();
189 189 if ($this->post->get('_wpnonce')) {
190 - if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_settings')) {
191 - $font = $this->files->get('font');
192 - $name = $font['name'];
193 - $tmp = $font['tmp_name'];
194 - $filename = pathinfo($name, PATHINFO_FILENAME);
195 - $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
196 - $name = $filename . '.' . $extension;
197 - $fonts = $model_e2pdf_font->get_fonts();
190 +
191 + if (!wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_settings')) {
192 + wp_die($this->message('wp_verify_nonce_error'));
193 + }
194 +
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']);
198 + } else {
198 199 $font_name = false;
199 200 $exist = false;
200 - if (in_array($extension, $model_e2pdf_font->get_allowed_extensions())) {
201 - $font_name = $model_e2pdf_font->get_font_info(false, 4, $tmp);
202 - if ($font_name) {
203 - $exist = array_search($font_name, $fonts);
204 - }
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);
205 206 }
206 - if (!$tmp) {
207 - $this->add_notification('error', __('Choose Font file to upload', 'e2pdf'));
208 - } elseif ($font['error']) {
209 - $this->add_notification('error', $font['error']);
210 - } elseif (!in_array($extension, $model_e2pdf_font->get_allowed_extensions())) {
211 - $this->add_notification('error', sprintf(__('Only %s files allowed', 'e2pdf'), '.' . implode(', .', $model_e2pdf_font->get_allowed_extensions())));
212 - } elseif (!$font_name) {
207 + if (!$font_name) {
213 208 $this->add_notification('error', __('Invalid Type', 'e2pdf'));
214 209 } elseif (array_key_exists($name, $fonts) || $exist) {
215 210 $this->add_notification('error', __('A Font with this name already exists', 'e2pdf'));
216 - } elseif (move_uploaded_file($font['tmp_name'], $this->helper->get('fonts_dir') . $name)) {
217 - if (file_exists($this->helper->get('fonts_dir') . $name)) {
218 - $this->add_notification('update', sprintf(__('Uploaded: %d', 'e2pdf'), '1'));
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'));
219 214 } else {
220 - $this->add_notification('error', __('Something went wrong!', 'e2pdf'));
215 + $this->add_notification('update', __('Font Uploaded', 'e2pdf'));
221 216 }
222 217 }
223 - } else {
224 - wp_die($this->message('wp_verify_nonce_error'));
225 218 }
226 219 }
227 220
228 221 $fonts = $model_e2pdf_font->get_fonts();
@@ -238,12 +231,12 @@
238 231 * @url admin.php?page=e2pdf-settings&action=adobesign
239 232 * Backward Compatibility
240 233 */
241 234 public function adobesign_action() {
242 - $redirect_url = array(
235 + $redirect_url = [
243 236 'page' => 'e2pdf-integrations',
244 237 'action' => 'adobesign',
245 - );
238 + ];
246 239 if ($this->get->get('code') && get_option('e2pdf_adobesign_client_id', '') && get_option('e2pdf_adobesign_client_secret', '')) {
247 240 $redirect_url['code'] = $this->get->get('code');
248 241 $redirect_url['_wpnonce'] = wp_create_nonce('e2pdf_adobe');
249 242 }
@@ -261,9 +254,9 @@
261 254 $group_key = $this->get->get('group');
262 255 if ($this->post->get('_wpnonce')) {
263 256 if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_settings')) {
264 257 Model_E2pdf_Options::update_options($group_key, $this->post->get());
265 - $this->add_notification('update', sprintf(__('Success: %s', 'e2pdf'), __('Settings Saved', 'e2pdf')));
258 + $this->add_notification('update', __('Settings Saved', 'e2pdf'));
266 259 } else {
267 260 wp_die($this->message('wp_verify_nonce_error'));
268 261 }
269 262 }
@@ -283,15 +276,15 @@
283 276 update_option('e2pdf_disabled_extensions', array());
284 277 } else {
285 278 update_option('e2pdf_disabled_extensions', array_filter($this->post->get('e2pdf_disabled_extensions')));
286 279 }
287 - $this->add_notification('update', sprintf(__('Success: %s', 'e2pdf'), __('Settings Saved', 'e2pdf')));
288 280 $this->redirect(
289 281 $this->helper->get_url(
290 - array(
282 + [
291 283 'page' => 'e2pdf-settings',
292 284 'action' => 'extensions',
293 - )
285 + 'notification' => $this->add_notification('update', __('Settings Saved', 'e2pdf')),
286 + ]
294 287 )
295 288 );
296 289 } else {
297 290 wp_die($this->message('wp_verify_nonce_error'));
@@ -323,9 +316,9 @@
323 316 }
324 317 }
325 318 }
326 319 }
327 - $this->add_notification('update', sprintf(__('Success: %s', 'e2pdf'), __('Settings Saved', 'e2pdf')));
320 + $this->add_notification('update', __('Settings Saved', 'e2pdf'));
328 321 } else {
329 322 wp_die($this->message('wp_verify_nonce_error'));
330 323 }
331 324 }
@@ -348,9 +341,9 @@
348 341 public function translation_action() {
349 342 if ($this->post->get('_wpnonce')) {
350 343 if (wp_verify_nonce($this->post->get('_wpnonce'), 'e2pdf_settings')) {
351 344 Model_E2pdf_Options::update_options('translation_group', $this->post->get());
352 - $this->add_notification('update', sprintf(__('Success: %s', 'e2pdf'), __('Settings Saved', 'e2pdf')));
345 + $this->add_notification('update', __('Settings Saved', 'e2pdf'));
353 346 } else {
354 347 wp_die($this->message('wp_verify_nonce_error'));
355 348 }
356 349 }
@@ -387,14 +380,14 @@
387 380 if (wp_verify_nonce($this->get->get('_wpnonce'), 'e2pdf_settings')) {
388 381 $font = $this->post->get('data');
389 382 $model_e2pdf_font = new Model_E2pdf_Font();
390 383 $model_e2pdf_font->delete_font($font);
391 - $this->add_notification('update', sprintf(__('Deleted: %d', 'e2pdf'), '1'));
392 384 $response = array(
393 385 'redirect' => $this->helper->get_url(
394 386 array(
395 387 'page' => 'e2pdf-settings',
396 388 'action' => 'fonts',
389 + 'notification' => $this->add_notification('update', __('Font Deleted', 'e2pdf')),
397 390 )
398 391 ),
399 392 );
400 393 } else {