From b07bafba7e18730a39e9424181b13f24e1aa8b79 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Wed, 20 Mar 2019 20:07:51 +0000 Subject: [PATCH] Media: grid view attachment filter drop down - only show available mime types. In the media library gird view, properly limit the media attachment filter to available mime types, matching the list view. Props itzmekhokan. Fixes #43658. Built from https://develop.svn.wordpress.org/trunk@44947 git-svn-id: http://core.svn.wordpress.org/trunk@44778 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 10 +++++++++- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 019086c3b8..f56318392f 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -3576,10 +3576,18 @@ function wp_enqueue_media( $args = array() ) { $month_year->text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month_year->month ), $month_year->year ); } + // Filter to show only available mime types. + $avail_post_mime_types = get_available_post_mime_types( 'attachment' ); + $mimeTypes = wp_list_pluck( get_post_mime_types(), 0 ); + foreach ( $mimeTypes as $mime_type => $label ) { + if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) { + unset( $mimeTypes[ $mime_type ] ); + } + } $settings = array( 'tabs' => $tabs, 'tabUrl' => add_query_arg( array( 'chromeless' => true ), admin_url( 'media-upload.php' ) ), - 'mimeTypes' => wp_list_pluck( get_post_mime_types(), 0 ), + 'mimeTypes' => $mimeTypes, /** This filter is documented in wp-admin/includes/media.php */ 'captions' => ! apply_filters( 'disable_captions', '' ), 'nonce' => array( diff --git a/wp-includes/version.php b/wp-includes/version.php index b4b19950f8..017ee8bd8b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.2-alpha-44946'; +$wp_version = '5.2-alpha-44947'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.