WP Extra File Types - Version 0.4.4

Version Description

  • released experimental fix to have better integration with GravityForms
Download this release

Release Info

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

Code changes from version 0.4.2 to 0.4.4

Files changed (3) hide show
  1. languages.php +4 -2
  2. readme.txt +8 -2
  3. wp-extra-file-types.php +34 -2
languages.php CHANGED
@@ -14,7 +14,8 @@ $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 +30,8 @@ $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 workaround for GravityForms(override standard behaviour - <em>Beta version</em> - WP-Extra-File-Types has been developed to integrate only with Wordpress Media Library)'
19
  ),
20
  'it-IT'=> array(
21
  'ADMIN_PAGE_TITLE' => 'Tipi di file aggiuntivi',
30
  'TEXT_NO_STRICT' => 'Controlla solo estensione dei file',
31
  'TEXT_NO_STRICT_1' => '<i>da usare <u>solo</u> se ci sono problemi con qualche file</i>',
32
  'TEXT_SKIP_WP' => 'Evita controlli interni di WordPress',
33
+ '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>',
34
+ 'TEXT_GF_HACK' => 'Abilita workaround per GravityForms(sovrascrive filtro ufficiale - <em>Versione Beta</em> - ufficialmente WP-Extra-File-Types funziona solo con la Media Library di Wordpress)'
35
  )
36
  );
37
 
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.0.2
6
- Stable tag: 0.4.2
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.2 =
26
  * mime types database updated
27
 
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.4
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 =
26
+ * released experimental fix to have better integration with GravityForms
27
+
28
+ = 0.4.3 =
29
+ * fix on custom file types
30
+
31
  = 0.4.2 =
32
  * mime types database updated
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.2
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() {
@@ -109,6 +110,7 @@ class WPEFT {
109
  $ext = trim($_POST['custom_e'][$k]);
110
  $mime = trim($_POST['custom_m'][$k]);
111
  if ($ext=='' || $mime=='') { continue; }
 
112
  if (!substr($ext,0,1)=='.') { $ext = '.'.$ext; }
113
  $custom[] = array( 'description'=>$description, 'extension'=>$ext, 'mime'=>$mime );
114
  }
@@ -125,6 +127,11 @@ class WPEFT {
125
  } else {
126
  update_option('wpeft_no_wp',false);
127
  }
 
 
 
 
 
128
  }
129
  $selected = get_option('wpeft_types','');
130
  if (!$selected) {
@@ -138,6 +145,7 @@ class WPEFT {
138
  $nostrict = get_option('wpeft_no_strict',false);
139
  $nowp = get_option('wpeft_no_wp',false);
140
  $custom = get_option('wpeft_custom_types','');
 
141
  if (!$custom) {
142
  $custom = array();
143
  }
@@ -204,6 +212,11 @@ class WPEFT {
204
  <td valign="top">&nbsp;</td>
205
  <td valign="top"><input type="checkbox" name="no_wp" <?php if ($nowp) { echo 'checked="checked" '; } ?>> <?php echo $this->lang['TEXT_SKIP_WP_1'];?></td>
206
  </tr>
 
 
 
 
 
207
  <tr>
208
  <td colspan="3">
209
  <hr />
@@ -340,6 +353,21 @@ class WPEFT {
340
  return $ret;
341
  }
342
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
  protected function _inWP($ext) {
344
  $ext = strtolower($ext);
345
  $wpmime = wp_get_mime_types();
@@ -370,7 +398,9 @@ class WPEFT {
370
  } else {
371
  $_optc = array();
372
  foreach ($optc as $c) {
373
- if (substr($c['extension'],0,1)=='.') { $c['extension'] = substr($c['extension'],1); }
 
 
374
  $_optc[ $c['extension'] ] = $c['mime'];
375
  }
376
  $optc = $_optc;
@@ -388,6 +418,8 @@ add_filter('upload_mimes',array($wpeft_obj,'mime'));
388
 
389
  add_filter('wp_check_filetype_and_ext',array($wpeft_obj,'mime2'),10,4);
390
 
 
 
391
  /* add_filter('upload_mimes','add_extra_mime_types');
392
 
393
  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
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() {
110
  $ext = trim($_POST['custom_e'][$k]);
111
  $mime = trim($_POST['custom_m'][$k]);
112
  if ($ext=='' || $mime=='') { continue; }
113
+ if (strpos($mime,'/')===false) { $mime = 'application/octet-stream'; }
114
  if (!substr($ext,0,1)=='.') { $ext = '.'.$ext; }
115
  $custom[] = array( 'description'=>$description, 'extension'=>$ext, 'mime'=>$mime );
116
  }
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'];?></td>
219
+ </tr>
220
  <tr>
221
  <td colspan="3">
222
  <hr />
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){