WP Extra File Types - Version 0.4.4.1

Version Description

  • user interface fix
Download this release

Release Info

Developer davide.airaghi
Plugin Icon 128x128 WP Extra File Types
Version 0.4.4.1
Comparing to
See all releases

Code changes from version 0.4.3 to 0.4.4.1

Files changed (3) hide show
  1. languages.php +6 -2
  2. readme.txt +8 -2
  3. wp-extra-file-types.php +36 -5
languages.php CHANGED
@@ -14,7 +14,9 @@ $wpeft_lang=array(
14
  'TEXT_NO_STRICT' => 'Check only file extensions',
15
  'TEXT_NO_STRICT_1' => '<i>to be used <u>only</u> if you are unable to upload files you have enabled by selecting their type</i>',
16
  'TEXT_SKIP_WP' => 'Skip WordPress checks',
17
- 'TEXT_SKIP_WP_1' => '<i>to be used <u>only</u> if you want to manage all the file types by yourself, skipping internal WordPress lists and checks</i>'
 
 
18
  ),
19
  'it-IT'=> array(
20
  'ADMIN_PAGE_TITLE' => 'Tipi di file aggiuntivi',
@@ -29,7 +31,9 @@ $wpeft_lang=array(
29
  'TEXT_NO_STRICT' => 'Controlla solo estensione dei file',
30
  'TEXT_NO_STRICT_1' => '<i>da usare <u>solo</u> se ci sono problemi con qualche file</i>',
31
  'TEXT_SKIP_WP' => 'Evita controlli interni di WordPress',
32
- 'TEXT_SKIP_WP_1' => '<i>da usare <u>solo</u> se si vogliono gestire in totale autonomia i tipi di file, ignorando eventuali liste interne di WordPress</i>'
 
 
33
  )
34
  );
35
 
14
  'TEXT_NO_STRICT' => 'Check only file extensions',
15
  'TEXT_NO_STRICT_1' => '<i>to be used <u>only</u> if you are unable to upload files you have enabled by selecting their type</i>',
16
  'TEXT_SKIP_WP' => 'Skip WordPress checks',
17
+ 'TEXT_SKIP_WP_1' => '<i>to be used <u>only</u> if you want to manage all the file types by yourself, skipping internal WordPress lists and checks</i>',
18
+ 'TEXT_GF_HACK' => 'Enable experimental workaround for GravityForms',
19
+ 'TEXT_GF_HACK_1' => '<i>override standard behaviour - <em>Beta version</em> - WP-Extra-File-Types has been developed to integrate only with Wordpress Media Library</i>'
20
  ),
21
  'it-IT'=> array(
22
  'ADMIN_PAGE_TITLE' => 'Tipi di file aggiuntivi',
31
  'TEXT_NO_STRICT' => 'Controlla solo estensione dei file',
32
  'TEXT_NO_STRICT_1' => '<i>da usare <u>solo</u> se ci sono problemi con qualche file</i>',
33
  'TEXT_SKIP_WP' => 'Evita controlli interni di WordPress',
34
+ 'TEXT_SKIP_WP_1' => '<i>da usare <u>solo</u> se si vogliono gestire in totale autonomia i tipi di file, ignorando eventuali liste interne di WordPress</i>',
35
+ 'TEXT_GF_HACK' => 'Abilita workaround sperimentale per GravityForms',
36
+ 'TEXT_GF_HACK_1' => '<i>sovrascrive filtro ufficiale - <em>Versione Beta</em> - ufficialmente WP-Extra-File-Types funziona solo con la Media Library di Wordpress</i>'
37
  )
38
  );
39
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: davide.airaghi
3
  Tags: file type, upload, media library
4
  Requires at least: 4.0
5
- Tested up to: 5.2.3
6
- Stable tag: 0.4.3
7
  License: GPLv2 or later
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -22,6 +22,12 @@ supported by the Media Library upload procedure.
22
 
23
  == Changelog ==
24
 
 
 
 
 
 
 
25
  = 0.4.3 =
26
  * fix on custom file types
27
 
2
  Contributors: davide.airaghi
3
  Tags: file type, upload, media library
4
  Requires at least: 4.0
5
+ Tested up to: 5.3.2
6
+ Stable tag: 0.4.4.1
7
  License: GPLv2 or later
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
22
 
23
  == Changelog ==
24
 
25
+ = 0.4.4.1 =
26
+ * user interface fix
27
+
28
+ = 0.4.4 =
29
+ * released experimental fix to have better integration with GravityForms
30
+
31
  = 0.4.3 =
32
  * fix on custom file types
33
 
wp-extra-file-types.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WP Extra File Types
4
  * Description: Plugin to let you extend the list of allowed file types supported by the Wordpress Media Library.
5
  * Plugin URI: http://www.airaghi.net/en/2015/01/02/wordpress-custom-mime-types/
6
- * Version: 0.4.3
7
  * Author: Davide Airaghi
8
  * Author URI: http://www.airaghi.net
9
  * License: GPLv2 or later
@@ -60,6 +60,7 @@ class WPEFT {
60
  register_setting('wp-extra-file-types-page','wpeft_custom_types');
61
  register_setting('wp-extra-file-types-page','wpeft_no_strict');
62
  register_setting('wp-extra-file-types-page','wpeft_no_wp');
 
63
  }
64
 
65
  public function admin() {
@@ -126,6 +127,11 @@ class WPEFT {
126
  } else {
127
  update_option('wpeft_no_wp',false);
128
  }
 
 
 
 
 
129
  }
130
  $selected = get_option('wpeft_types','');
131
  if (!$selected) {
@@ -139,6 +145,7 @@ class WPEFT {
139
  $nostrict = get_option('wpeft_no_strict',false);
140
  $nowp = get_option('wpeft_no_wp',false);
141
  $custom = get_option('wpeft_custom_types','');
 
142
  if (!$custom) {
143
  $custom = array();
144
  }
@@ -205,6 +212,11 @@ class WPEFT {
205
  <td valign="top">&nbsp;</td>
206
  <td valign="top"><input type="checkbox" name="no_wp" <?php if ($nowp) { echo 'checked="checked" '; } ?>> <?php echo $this->lang['TEXT_SKIP_WP_1'];?></td>
207
  </tr>
 
 
 
 
 
208
  <tr>
209
  <td colspan="3">
210
  <hr />
@@ -328,8 +340,8 @@ class WPEFT {
328
  if (!$nowp) {
329
  // if the user want to use also WordPress internals (default case) ...
330
  if ($inwp || !$nostrict) {
331
- // do nothing for WordPress file types or when we do not have to force anything ...
332
- return $ret;
333
  }
334
  }
335
  $usr = $this->_buildList();
@@ -340,7 +352,22 @@ class WPEFT {
340
  }
341
  return $ret;
342
  }
343
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  protected function _inWP($ext) {
345
  $ext = strtolower($ext);
346
  $wpmime = wp_get_mime_types();
@@ -371,7 +398,9 @@ class WPEFT {
371
  } else {
372
  $_optc = array();
373
  foreach ($optc as $c) {
374
- if (substr($c['extension'],0,1)=='.') { $c['extension'] = substr($c['extension'],1); }
 
 
375
  $_optc[ $c['extension'] ] = $c['mime'];
376
  }
377
  $optc = $_optc;
@@ -389,6 +418,8 @@ add_filter('upload_mimes',array($wpeft_obj,'mime'));
389
 
390
  add_filter('wp_check_filetype_and_ext',array($wpeft_obj,'mime2'),10,4);
391
 
 
 
392
  /* add_filter('upload_mimes','add_extra_mime_types');
393
 
394
  function add_extra_mime_types($mimes){
3
  * Plugin Name: WP Extra File Types
4
  * Description: Plugin to let you extend the list of allowed file types supported by the Wordpress Media Library.
5
  * Plugin URI: http://www.airaghi.net/en/2015/01/02/wordpress-custom-mime-types/
6
+ * Version: 0.4.4.1
7
  * Author: Davide Airaghi
8
  * Author URI: http://www.airaghi.net
9
  * License: GPLv2 or later
60
  register_setting('wp-extra-file-types-page','wpeft_custom_types');
61
  register_setting('wp-extra-file-types-page','wpeft_no_strict');
62
  register_setting('wp-extra-file-types-page','wpeft_no_wp');
63
+ register_setting('wp-extra-file-types-page','wpeft_gf_hack');
64
  }
65
 
66
  public function admin() {
127
  } else {
128
  update_option('wpeft_no_wp',false);
129
  }
130
+ if (isset($_POST['gf_hack']) && $_POST['gf_hack']) {
131
+ update_option('wpeft_gf_hack',true);
132
+ } else {
133
+ update_option('wpeft_gf_hack',false);
134
+ }
135
  }
136
  $selected = get_option('wpeft_types','');
137
  if (!$selected) {
145
  $nostrict = get_option('wpeft_no_strict',false);
146
  $nowp = get_option('wpeft_no_wp',false);
147
  $custom = get_option('wpeft_custom_types','');
148
+ $gf_hack = get_option('wpeft_gf_hack',false);
149
  if (!$custom) {
150
  $custom = array();
151
  }
212
  <td valign="top">&nbsp;</td>
213
  <td valign="top"><input type="checkbox" name="no_wp" <?php if ($nowp) { echo 'checked="checked" '; } ?>> <?php echo $this->lang['TEXT_SKIP_WP_1'];?></td>
214
  </tr>
215
+ <tr>
216
+ <td valign="top"><?php echo $this->lang['TEXT_GF_HACK'];?></td>
217
+ <td valign="top">&nbsp;</td>
218
+ <td valign="top"><input type="checkbox" name="gf_hack" <?php if ($gf_hack) { echo 'checked="checked" '; } ?>> <?php echo $this->lang['TEXT_GF_HACK_1'];?></td>
219
+ </tr>
220
  <tr>
221
  <td colspan="3">
222
  <hr />
340
  if (!$nowp) {
341
  // if the user want to use also WordPress internals (default case) ...
342
  if ($inwp || !$nostrict) {
343
+ // do nothing for WordPress file types or when we do not have to force anything ...
344
+ return $ret;
345
  }
346
  }
347
  $usr = $this->_buildList();
352
  }
353
  return $ret;
354
  }
355
+
356
+ public function gf_hack($extensions)
357
+ {
358
+ $gf_hack = get_option('wpeft_gf_hack');
359
+ if (!$gf_hack) {
360
+ return $extensions;
361
+ }
362
+ $ok_list = $this->_buildList();
363
+ foreach ($extensions as $key => $ext) {
364
+ if ($ok_list && isset($ok_list[$ext])) {
365
+ unset($extensions[$key]);
366
+ }
367
+ }
368
+ return $extensions;
369
+ }
370
+
371
  protected function _inWP($ext) {
372
  $ext = strtolower($ext);
373
  $wpmime = wp_get_mime_types();
398
  } else {
399
  $_optc = array();
400
  foreach ($optc as $c) {
401
+ if (substr($c['extension'],0,1)=='.') {
402
+ $c['extension'] = substr($c['extension'],1);
403
+ }
404
  $_optc[ $c['extension'] ] = $c['mime'];
405
  }
406
  $optc = $_optc;
418
 
419
  add_filter('wp_check_filetype_and_ext',array($wpeft_obj,'mime2'),10,4);
420
 
421
+ add_filter('gform_disallowed_file_extensions',array($wpeft_obj,'gf_hack'));
422
+
423
  /* add_filter('upload_mimes','add_extra_mime_types');
424
 
425
  function add_extra_mime_types($mimes){