Introduce wp_get_mime_types() for fetching the complete list of mime types. Remove the static caching of the types so that filters other than the first filter work. Use wp_get_mime_types() in do_enclose(). fixes #21299 #21594
git-svn-id: https://develop.svn.wordpress.org/trunk@21541 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d022dec53b
commit
ee8cf061f8
@ -458,7 +458,7 @@ function do_enclose( $content, $post_ID ) {
|
|||||||
if ( false !== $url_parts ) {
|
if ( false !== $url_parts ) {
|
||||||
$extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
|
$extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
|
||||||
if ( !empty( $extension ) ) {
|
if ( !empty( $extension ) ) {
|
||||||
foreach ( get_allowed_mime_types( ) as $exts => $mime ) {
|
foreach ( wp_get_mime_types() as $exts => $mime ) {
|
||||||
if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) {
|
if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) {
|
||||||
$type = $mime;
|
$type = $mime;
|
||||||
break;
|
break;
|
||||||
@ -1754,19 +1754,18 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve list of allowed mime types and file extensions.
|
* Retrieve list of mime types and file extensions.
|
||||||
*
|
*
|
||||||
* @since 2.8.6
|
* @since 3.5.0
|
||||||
|
*
|
||||||
|
* @uses apply_filters() Calls 'mime_types' on returned array. This filter should
|
||||||
|
* be used to add types, not remove them. To remove types use the upload_mimes filter.
|
||||||
*
|
*
|
||||||
* @uses apply_filters() Calls 'upload_mimes' on returned array
|
|
||||||
* @return array Array of mime types keyed by the file extension regex corresponding to those types.
|
* @return array Array of mime types keyed by the file extension regex corresponding to those types.
|
||||||
*/
|
*/
|
||||||
function get_allowed_mime_types() {
|
function wp_get_mime_types() {
|
||||||
static $mimes = false;
|
|
||||||
|
|
||||||
if ( !$mimes ) {
|
|
||||||
// Accepted MIME types are set here as PCRE unless provided.
|
// Accepted MIME types are set here as PCRE unless provided.
|
||||||
$mimes = apply_filters( 'upload_mimes', array(
|
return apply_filters( 'mime_types', array(
|
||||||
// Image formats
|
// Image formats
|
||||||
'jpg|jpeg|jpe' => 'image/jpeg',
|
'jpg|jpeg|jpe' => 'image/jpeg',
|
||||||
'gif' => 'image/gif',
|
'gif' => 'image/gif',
|
||||||
@ -1851,8 +1850,18 @@ function get_allowed_mime_types() {
|
|||||||
'wp|wpd' => 'application/wordperfect',
|
'wp|wpd' => 'application/wordperfect',
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
return $mimes;
|
* Retrieve list of allowed mime types and file extensions.
|
||||||
|
*
|
||||||
|
* @since 2.8.6
|
||||||
|
*
|
||||||
|
* @uses apply_filters() Calls 'upload_mimes' on returned array
|
||||||
|
* @uses wp_get_upload_mime_types() to fetch the list of mime types
|
||||||
|
*
|
||||||
|
* @return array Array of mime types keyed by the file extension regex corresponding to those types.
|
||||||
|
*/
|
||||||
|
function get_allowed_mime_types() {
|
||||||
|
return apply_filters( 'upload_mimes', wp_get_mime_types() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user