Consolidate post_mime_type code. props scribu. fixes #10992
git-svn-id: https://develop.svn.wordpress.org/trunk@12110 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ba1f1d3780
commit
a556c8ce89
@ -1105,7 +1105,7 @@ function get_media_items( $post_id, $errors ) {
|
|||||||
* @return string HTML form for attachment.
|
* @return string HTML form for attachment.
|
||||||
*/
|
*/
|
||||||
function get_media_item( $attachment_id, $args = null ) {
|
function get_media_item( $attachment_id, $args = null ) {
|
||||||
global $post_mime_types, $redir_tab;
|
global $redir_tab;
|
||||||
|
|
||||||
if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
|
if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
|
||||||
$thumb_url = $thumb_url[0];
|
$thumb_url = $thumb_url[0];
|
||||||
@ -1130,12 +1130,10 @@ function get_media_item( $attachment_id, $args = null ) {
|
|||||||
$tags = esc_attr(join(', ', $tags));
|
$tags = esc_attr(join(', ', $tags));
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = '';
|
$post_mime_types = get_post_mime_types();
|
||||||
if ( isset($post_mime_types) ) {
|
$keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
|
||||||
$keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
|
$type = array_shift($keys);
|
||||||
$type = array_shift($keys);
|
$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
|
||||||
$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
|
|
||||||
}
|
|
||||||
|
|
||||||
$form_fields = get_attachment_fields_to_edit($post, $errors);
|
$form_fields = get_attachment_fields_to_edit($post, $errors);
|
||||||
|
|
||||||
|
@ -836,6 +836,23 @@ function wp_edit_posts_query( $q = false ) {
|
|||||||
return array($post_stati, $avail_post_stati);
|
return array($post_stati, $avail_post_stati);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get default post mime types
|
||||||
|
*
|
||||||
|
* @since 2.9.0
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function get_post_mime_types() {
|
||||||
|
$post_mime_types = array( // array( adj, noun )
|
||||||
|
'image' => array(__('Images'), __('Manage Images'), _n_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>')),
|
||||||
|
'audio' => array(__('Audio'), __('Manage Audio'), _n_noop('Audio <span class="count">(%s)</span>', 'Audio <span class="count">(%s)</span>')),
|
||||||
|
'video' => array(__('Video'), __('Manage Video'), _n_noop('Video <span class="count">(%s)</span>', 'Video <span class="count">(%s)</span>')),
|
||||||
|
);
|
||||||
|
|
||||||
|
return apply_filters('post_mime_types', $post_mime_types);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@internal Missing Short Description}}
|
* {@internal Missing Short Description}}
|
||||||
*
|
*
|
||||||
@ -871,13 +888,8 @@ function wp_edit_attachments_query( $q = false ) {
|
|||||||
if ( empty($media_per_page) )
|
if ( empty($media_per_page) )
|
||||||
$media_per_page = 20;
|
$media_per_page = 20;
|
||||||
$q['posts_per_page'] = $media_per_page;
|
$q['posts_per_page'] = $media_per_page;
|
||||||
$post_mime_types = array( // array( adj, noun )
|
|
||||||
'image' => array(__('Images'), __('Manage Images'), _n_noop('Image <span class="count">(%s)</span>', 'Images <span class="count">(%s)</span>')),
|
|
||||||
'audio' => array(__('Audio'), __('Manage Audio'), _n_noop('Audio <span class="count">(%s)</span>', 'Audio <span class="count">(%s)</span>')),
|
|
||||||
'video' => array(__('Video'), __('Manage Video'), _n_noop('Video <span class="count">(%s)</span>', 'Video <span class="count">(%s)</span>')),
|
|
||||||
);
|
|
||||||
$post_mime_types = apply_filters('post_mime_types', $post_mime_types);
|
|
||||||
|
|
||||||
|
$post_mime_types = get_post_mime_types();
|
||||||
$avail_post_mime_types = get_available_post_mime_types('attachment');
|
$avail_post_mime_types = get_available_post_mime_types('attachment');
|
||||||
|
|
||||||
if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) )
|
if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) )
|
||||||
|
@ -146,13 +146,7 @@ if ( isset($_GET['detached']) ) {
|
|||||||
$page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25);
|
$page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_mime_types = array(
|
$post_mime_types = get_post_mime_types();
|
||||||
'image' => array(__('Images'), __('Manage Images'), _n_noop('Image (%s)', 'Images (%s)')),
|
|
||||||
'audio' => array(__('Audio'), __('Manage Audio'), _n_noop('Audio (%s)', 'Audio (%s)')),
|
|
||||||
'video' => array(__('Video'), __('Manage Video'), _n_noop('Video (%s)', 'Video (%s)')),
|
|
||||||
);
|
|
||||||
$post_mime_types = apply_filters('post_mime_types', $post_mime_types);
|
|
||||||
|
|
||||||
$avail_post_mime_types = get_available_post_mime_types('attachment');
|
$avail_post_mime_types = get_available_post_mime_types('attachment');
|
||||||
|
|
||||||
if ( isset($_GET['post_mime_type']) && !array_intersect( (array) $_GET['post_mime_type'], array_keys($post_mime_types) ) )
|
if ( isset($_GET['post_mime_type']) && !array_intersect( (array) $_GET['post_mime_type'], array_keys($post_mime_types) ) )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user