Make WordPress Core

Changeset 12110


Ignore:
Timestamp:
10/26/2009 05:56:28 PM (17 years ago)
Author:
markjaquith
Message:

Consolidate post_mime_type code. props scribu. fixes #10992

Location:
trunk/wp-admin
Files:
3 edited

Legend:

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

    r12098 r12110  
    11061106 */
    11071107function get_media_item( $attachment_id, $args = null ) {
    1108         global $post_mime_types, $redir_tab;
     1108        global $redir_tab;
    11091109
    11101110        if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
     
    11311131        }
    11321132
    1133         $type = '';
    1134         if ( isset($post_mime_types) ) {
    1135                 $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
    1136                 $type = array_shift($keys);
    1137                 $type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
    1138         }
     1133        $post_mime_types = get_post_mime_types();
     1134        $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
     1135        $type = array_shift($keys);
     1136        $type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
    11391137
    11401138        $form_fields = get_attachment_fields_to_edit($post, $errors);
  • trunk/wp-admin/includes/post.php

    r12069 r12110  
    838838
    839839/**
     840 * Get default post mime types
     841 *
     842 * @since 2.9.0
     843 *
     844 * @return array
     845 */
     846function get_post_mime_types() {
     847        $post_mime_types = array(       //      array( adj, noun )
     848                'image' => array(__('Images'), __('Manage Images'), _n_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>')),
     849                'audio' => array(__('Audio'), __('Manage Audio'), _n_noop('Audio <span class="count">(%s)</span>', 'Audio <span class="count">(%s)</span>')),
     850                'video' => array(__('Video'), __('Manage Video'), _n_noop('Video <span class="count">(%s)</span>', 'Video <span class="count">(%s)</span>')),
     851        );
     852
     853        return apply_filters('post_mime_types', $post_mime_types);
     854}
     855
     856/**
    840857 * {@internal Missing Short Description}}
    841858 *
     
    872889                $media_per_page = 20;
    873890        $q['posts_per_page'] = $media_per_page;
    874         $post_mime_types = array(       //      array( adj, noun )
    875                                 'image' => array(__('Images'), __('Manage Images'), _n_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>')),
    876                                 'audio' => array(__('Audio'), __('Manage Audio'), _n_noop('Audio <span class="count">(%s)</span>', 'Audio <span class="count">(%s)</span>')),
    877                                 'video' => array(__('Video'), __('Manage Video'), _n_noop('Video <span class="count">(%s)</span>', 'Video <span class="count">(%s)</span>')),
    878                         );
    879         $post_mime_types = apply_filters('post_mime_types', $post_mime_types);
    880 
     891
     892        $post_mime_types = get_post_mime_types();
    881893        $avail_post_mime_types = get_available_post_mime_types('attachment');
    882894
  • trunk/wp-admin/upload.php

    r11979 r12110  
    147147        }
    148148
    149         $post_mime_types = array(
    150                                 'image' => array(__('Images'), __('Manage Images'), _n_noop('Image (%s)', 'Images (%s)')),
    151                                 'audio' => array(__('Audio'), __('Manage Audio'), _n_noop('Audio (%s)', 'Audio (%s)')),
    152                                 'video' => array(__('Video'), __('Manage Video'), _n_noop('Video (%s)', 'Video (%s)')),
    153                         );
    154         $post_mime_types = apply_filters('post_mime_types', $post_mime_types);
    155 
     149        $post_mime_types = get_post_mime_types();
    156150        $avail_post_mime_types = get_available_post_mime_types('attachment');
    157151
Note: See TracChangeset for help on using the changeset viewer.