WordPress.org

Make WordPress Core

Ticket #10992: get_post_mime_types.diff

File get_post_mime_types.diff, 4.0 KB (added by scribu, 5 years ago)
  • wp-admin/includes/post.php

     
    837837} 
    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 * 
    842859 * @since unknown 
     
    871888        if ( empty($media_per_page) ) 
    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); 
    880891 
     892        $post_mime_types = get_post_mime_types(); 
    881893        $avail_post_mime_types = get_available_post_mime_types('attachment'); 
    882894 
    883895        if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) ) 
  • wp-admin/includes/media.php

     
    11011101 * @return string HTML form for attachment. 
    11021102 */ 
    11031103function get_media_item( $attachment_id, $args = null ) { 
    1104         global $post_mime_types, $redir_tab; 
     1104        global $redir_tab; 
    11051105 
    11061106        if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) ) 
    11071107                $thumb_url = $thumb_url[0]; 
     
    11261126                $tags = esc_attr(join(', ', $tags)); 
    11271127        } 
    11281128 
    1129         $type = ''; 
    1130         if ( isset($post_mime_types) ) { 
    1131                 $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type)); 
    1132                 $type = array_shift($keys); 
    1133                 $type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />"; 
    1134         } 
     1129        $post_mime_types = get_post_mime_types(); 
     1130        $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type)); 
     1131        $type = array_shift($keys); 
     1132        $type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />"; 
    11351133 
    11361134        $form_fields = get_attachment_fields_to_edit($post, $errors); 
    11371135 
  • wp-admin/upload.php

     
    146146                $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25); 
    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 
    158152        if ( isset($_GET['post_mime_type']) && !array_intersect( (array) $_GET['post_mime_type'], array_keys($post_mime_types) ) )