WordPress.org

Make WordPress Core

Ticket #6231: 6231.diff

File 6231.diff, 1.1 KB (added by andy, 7 years ago)

media button type is default filter in Library browser

  • wp-admin/includes/media.php

     
    956966foreach ( $matches as $_type => $reals ) 
    957967        foreach ( $reals as $real ) 
    958968                $num_posts[$_type] += $_num_posts[$real]; 
    959 $class = empty($_GET['post_mime_type']) ? ' class="current"' : ''; 
    960 $type_links[] = "<li><a href='" . remove_query_arg(array('post_mime_type', 'paged', 'm')) . "'$class>".__('All Types')."</a>"; 
     969// If available type specified by media button clicked, filter by that type 
     970if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) { 
     971        $_GET['post_mime_type'] = $type; 
     972        list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); 
     973} 
     974if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' ) 
     975        $class = ' class="current"'; 
     976$type_links[] = "<li><a href='" . add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false)) . "'$class>".__('All Types')."</a>"; 
    961977foreach ( $post_mime_types as $mime_type => $label ) { 
    962978        $class = ''; 
    963979