From 1b041b9bfd852e477a9aae073f08b8d055028b8d Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 17 Mar 2008 20:09:55 +0000 Subject: [PATCH] Make media button type default filter in Library browser. Props andy. fixes #6231 git-svn-id: https://develop.svn.wordpress.org/trunk@7349 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/media.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index a983070fce..8d8bed444b 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -966,8 +966,14 @@ $matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_po foreach ( $matches as $_type => $reals ) foreach ( $reals as $real ) $num_posts[$_type] += $_num_posts[$real]; -$class = empty($_GET['post_mime_type']) ? ' class="current"' : ''; -$type_links[] = "
  • ".__('All Types').""; +// If available type specified by media button clicked, filter by that type +if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) { + $_GET['post_mime_type'] = $type; + list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); +} +if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' ) + $class = ' class="current"'; +$type_links[] = "
  • 'all', 'paged'=>false, 'm'=>false)) . "'$class>".__('All Types').""; foreach ( $post_mime_types as $mime_type => $label ) { $class = '';