Make WordPress Core


Ignore:
Timestamp:
02/19/2008 06:13:20 AM (17 years ago)
Author:
ryan
Message:

Media Library design updates from Andy. see #5911

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/post.php

    r6872 r6910  
    503503            );
    504504
     505    $post_stati = apply_filters('post_stati', $post_stati);
     506
    505507    $avail_post_stati = get_available_post_statuses('post');
    506508
     
    523525
    524526    return array($post_stati, $avail_post_stati);
     527}
     528
     529function get_available_post_mime_types($type = 'attachment') {
     530    global $wpdb;
     531
     532    $types = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type));
     533    return $types;
     534}
     535
     536function wp_edit_attachments_query( $q = false ) {
     537    global $wpdb;
     538    if ( false === $q )
     539        $q = $_GET;
     540    $q['m']   = (int) $q['m'];
     541    $q['cat'] = (int) $q['cat'];
     542    $q['post_type'] = 'attachment';
     543    $q['post_status'] = 'any';
     544    $post_mime_types = array(   //  array( adj, noun )
     545                'image' => array(__('Images'), __('Manage Images'), __('Images (%s)')),
     546                'audio' => array(__('Audio'), __('Manage Audio'), __('Audio (%s)')),
     547                'video' => array(__('Video'), __('Manage Video'), __('Video (%s)')),
     548            );
     549    $post_mime_types = apply_filters('post_mime_types', $post_mime_types);
     550
     551    $avail_post_mime_types = get_available_post_mime_types('attachment');
     552
     553    if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) )
     554        unset($q['post_mime_type']);
     555
     556    wp($q);
     557
     558    return array($post_mime_types, $avail_post_mime_types);
    525559}
    526560
Note: See TracChangeset for help on using the changeset viewer.