| @@ 1083-1127 (lines=45) @@ | ||
| 1080 | ||
| 1081 | $mime_types = wp_get_mime_types(); |
|
| 1082 | ||
| 1083 | if ( in_array( $limit_file_type, array( 'images', 'audio', 'video' ), true ) ) { |
|
| 1084 | $new_limit_types = array(); |
|
| 1085 | ||
| 1086 | foreach ( $mime_types as $type => $mime ) { |
|
| 1087 | if ( 0 === strpos( $mime, $limit_file_type ) ) { |
|
| 1088 | $type = explode( '|', $type ); |
|
| 1089 | ||
| 1090 | $new_limit_types = array_merge( $new_limit_types, $type ); |
|
| 1091 | } |
|
| 1092 | } |
|
| 1093 | ||
| 1094 | if ( ! empty( $new_limit_types ) ) { |
|
| 1095 | $limit_types = implode( ',', $new_limit_types ); |
|
| 1096 | } |
|
| 1097 | } elseif ( 'any' != $limit_file_type ) { |
|
| 1098 | $new_limit_types = array(); |
|
| 1099 | ||
| 1100 | $limit_types = explode( ',', $limit_types ); |
|
| 1101 | ||
| 1102 | foreach ( $limit_types as $k => $limit_type ) { |
|
| 1103 | $found = false; |
|
| 1104 | ||
| 1105 | foreach ( $mime_types as $type => $mime ) { |
|
| 1106 | if ( 0 === strpos( $mime, $limit_type ) ) { |
|
| 1107 | $type = explode( '|', $type ); |
|
| 1108 | ||
| 1109 | foreach ( $type as $t ) { |
|
| 1110 | if ( ! in_array( $t, $new_limit_types, true ) ) { |
|
| 1111 | $new_limit_types[] = $t; |
|
| 1112 | } |
|
| 1113 | } |
|
| 1114 | ||
| 1115 | $found = true; |
|
| 1116 | } |
|
| 1117 | } |
|
| 1118 | ||
| 1119 | if ( ! $found ) { |
|
| 1120 | $new_limit_types[] = $limit_type; |
|
| 1121 | } |
|
| 1122 | } |
|
| 1123 | ||
| 1124 | if ( ! empty( $new_limit_types ) ) { |
|
| 1125 | $limit_types = implode( ',', $new_limit_types ); |
|
| 1126 | } |
|
| 1127 | } |
|
| 1128 | ||
| 1129 | $limit_types = explode( ',', $limit_types ); |
|
| 1130 | ||
| @@ 78-119 (lines=42) @@ | ||
| 75 | ||
| 76 | $mime_types = wp_get_mime_types(); |
|
| 77 | ||
| 78 | if ( in_array( $limit_file_type, array( 'images', 'audio', 'video' ) ) ) { |
|
| 79 | $new_limit_types = array(); |
|
| 80 | ||
| 81 | foreach ( $mime_types as $type => $mime ) { |
|
| 82 | if ( 0 === strpos( $mime, $limit_file_type ) ) { |
|
| 83 | $type = explode( '|', $type ); |
|
| 84 | ||
| 85 | $new_limit_types = array_merge( $new_limit_types, $type ); |
|
| 86 | } |
|
| 87 | } |
|
| 88 | ||
| 89 | if ( !empty( $new_limit_types ) ) |
|
| 90 | $limit_types = implode( ',', $new_limit_types ); |
|
| 91 | } |
|
| 92 | elseif ( 'any' != $limit_file_type ) { |
|
| 93 | $new_limit_types = array(); |
|
| 94 | ||
| 95 | $limit_types = explode( ',', $limit_types ); |
|
| 96 | ||
| 97 | foreach ( $limit_types as $k => $limit_type ) { |
|
| 98 | $found = false; |
|
| 99 | ||
| 100 | foreach ( $mime_types as $type => $mime ) { |
|
| 101 | if ( 0 === strpos( $mime, $limit_type ) ) { |
|
| 102 | $type = explode( '|', $type ); |
|
| 103 | ||
| 104 | foreach ( $type as $t ) { |
|
| 105 | if ( !in_array( $t, $new_limit_types ) ) |
|
| 106 | $new_limit_types[] = $t; |
|
| 107 | } |
|
| 108 | ||
| 109 | $found = true; |
|
| 110 | } |
|
| 111 | } |
|
| 112 | ||
| 113 | if ( !$found ) |
|
| 114 | $new_limit_types[] = $limit_type; |
|
| 115 | } |
|
| 116 | ||
| 117 | if ( !empty( $new_limit_types ) ) |
|
| 118 | $limit_types = implode( ',', $new_limit_types ); |
|
| 119 | } |
|
| 120 | ||
| 121 | if ( !empty( $limit_types ) ) |
|
| 122 | $plupload_init[ 'filters' ][ 0 ][ 'extensions' ] = $limit_types; |
|