<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12110] trunk/wp-admin: Consolidate post_mime_type code.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12110">12110</a></dd>
<dt>Author</dt> <dd>markjaquith</dd>
<dt>Date</dt> <dd>2009-10-26 17:56:28 +0000 (Mon, 26 Oct 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Consolidate post_mime_type code. props scribu. fixes <a href="http://trac.wordpress.org/ticket/10992">#10992</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesmediaphp">trunk/wp-admin/includes/media.php</a></li>
<li><a href="#trunkwpadminincludespostphp">trunk/wp-admin/includes/post.php</a></li>
<li><a href="#trunkwpadminuploadphp">trunk/wp-admin/upload.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/media.php (12109 => 12110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/media.php        2009-10-26 13:57:55 UTC (rev 12109)
+++ trunk/wp-admin/includes/media.php        2009-10-26 17:56:28 UTC (rev 12110)
</span><span class="lines">@@ -1105,7 +1105,7 @@
</span><span class="cx"> * @return string HTML form for attachment.
</span><span class="cx"> */
</span><span class="cx"> function get_media_item( $attachment_id, $args = null ) {
</span><del>-        global $post_mime_types, $redir_tab;
</del><ins>+        global $redir_tab;
</ins><span class="cx">
</span><span class="cx">         if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
</span><span class="cx">                 $thumb_url = $thumb_url[0];
</span><span class="lines">@@ -1130,12 +1130,10 @@
</span><span class="cx">                 $tags = esc_attr(join(', ', $tags));
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        $type = '';
-        if ( isset($post_mime_types) ) {
-                $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
-                $type = array_shift($keys);
-                $type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
-        }
</del><ins>+        $post_mime_types = get_post_mime_types();
+        $keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
+        $type = array_shift($keys);
+        $type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
</ins><span class="cx">
</span><span class="cx">         $form_fields = get_attachment_fields_to_edit($post, $errors);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/post.php (12109 => 12110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/post.php        2009-10-26 13:57:55 UTC (rev 12109)
+++ trunk/wp-admin/includes/post.php        2009-10-26 17:56:28 UTC (rev 12110)
</span><span class="lines">@@ -837,6 +837,23 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * 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);
+}
+
+/**
</ins><span class="cx"> * {@internal Missing Short Description}}
</span><span class="cx"> *
</span><span class="cx"> * @since unknown
</span><span class="lines">@@ -871,13 +888,8 @@
</span><span class="cx">         if ( empty($media_per_page) )
</span><span class="cx">                 $media_per_page = 20;
</span><span class="cx">         $q['posts_per_page'] = $media_per_page;
</span><del>-        $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);
</del><span class="cx">
</span><ins>+        $post_mime_types = get_post_mime_types();
</ins><span class="cx">         $avail_post_mime_types = get_available_post_mime_types('attachment');
</span><span class="cx">
</span><span class="cx">         if ( isset($q['post_mime_type']) && !array_intersect( (array) $q['post_mime_type'], array_keys($post_mime_types) ) )
</span></span></pre></div>
<a id="trunkwpadminuploadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/upload.php (12109 => 12110)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/upload.php        2009-10-26 13:57:55 UTC (rev 12109)
+++ trunk/wp-admin/upload.php        2009-10-26 17:56:28 UTC (rev 12110)
</span><span class="lines">@@ -146,13 +146,7 @@
</span><span class="cx">                 $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        $post_mime_types = array(
-                                '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);
-
</del><ins>+        $post_mime_types = get_post_mime_types();
</ins><span class="cx">         $avail_post_mime_types = get_available_post_mime_types('attachment');
</span><span class="cx">
</span><span class="cx">         if ( isset($_GET['post_mime_type']) && !array_intersect( (array) $_GET['post_mime_type'], array_keys($post_mime_types) ) )
</span></span></pre>
</div>
</div>
</body>
</html>