In wp_mime_type_icon()
, the length of the $wilds
array varies depending on what is passed as $mime
. Loop over $wilds
instead of arbitrarily checking $wilds[0]
.
Adds unit tests. Fixes #33012. git-svn-id: https://develop.svn.wordpress.org/trunk@34255 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
45c606576c
commit
25710ecc67
@ -5081,11 +5081,16 @@ function wp_mime_type_icon( $mime = 0 ) {
|
||||
$matches['default'] = array('default');
|
||||
|
||||
foreach ( $matches as $match => $wilds ) {
|
||||
if ( isset($types[$wilds[0]])) {
|
||||
$icon = $types[$wilds[0]];
|
||||
if ( !is_numeric($mime) )
|
||||
wp_cache_add("mime_type_icon_$mime", $icon);
|
||||
break;
|
||||
foreach ( $wilds as $wild ) {
|
||||
if ( ! isset( $types[ $wild ] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$icon = $types[ $wild ];
|
||||
if ( ! is_numeric( $mime ) ) {
|
||||
wp_cache_add( "mime_type_icon_$mime", $icon );
|
||||
}
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -512,9 +512,9 @@ class Tests_Post_Attachments extends WP_UnitTestCase {
|
||||
|
||||
$upload = wp_upload_bits( basename( $filename ), null, $contents );
|
||||
|
||||
$this->assertNotEmpty( $upload['error'] );
|
||||
|
||||
remove_filter( 'upload_mimes', array( $this, 'blacklist_jpg_mime_type' ) );
|
||||
|
||||
$this->assertNotEmpty( $upload['error'] );
|
||||
}
|
||||
|
||||
public function whitelist_psd_mime_type( $mimes ) {
|
||||
@ -526,4 +526,22 @@ class Tests_Post_Attachments extends WP_UnitTestCase {
|
||||
unset( $mimes['jpg|jpeg|jpe'] );
|
||||
return $mimes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 33012
|
||||
*/
|
||||
public function test_wp_mime_type_icon() {
|
||||
$icon = wp_mime_type_icon();
|
||||
|
||||
$this->assertContains( 'images/media/default.png', $icon );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 33012
|
||||
*/
|
||||
public function test_wp_mime_type_icon_video() {
|
||||
$icon = wp_mime_type_icon( 'video/mp4' );
|
||||
|
||||
$this->assertContains( 'images/media/video.png', $icon );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user