<!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" />
<title>[21948] trunk: Use the regular post type UI for editing single media items (attachments).</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/21948">21948</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-09-21 22:52:54 +0000 (Fri, 21 Sep 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use the regular post type UI for editing single media items (attachments).
 * Attachments now go through post.php, edit_post(), the like, and have show_ui set to true.
 * Taxonomies attached to the media library now appear in the admin menu (if show_ui).
 * Editing, cropping, uploading, etc. is still very rough, but mostly functional.

API-wise:
 * New function: get_taxonomies_for_attachments(). Like get_taxonomies(), for taxonomies specifically registered against attachments.
 * Brings taxonomy support from the posts list table to the media list table. Expect them to converge soon.
 * wp_insert_attachment() now handles taxonomies like wp_insert_post(). Also expect them to converge soon.
 * New edit_form_after_title hook.

props helenyhou, ocean90. see <a href="http://core.trac.wordpress.org/ticket/21391">#21391</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincsswpadmincss">trunk/wp-admin/css/wp-admin.css</a></li>
<li><a href="#trunkwpadmineditformadvancedphp">trunk/wp-admin/edit-form-advanced.php</a></li>
<li><a href="#trunkwpadminedittagsphp">trunk/wp-admin/edit-tags.php</a></li>
<li><a href="#trunkwpadminincludesclasswpmedialisttablephp">trunk/wp-admin/includes/class-wp-media-list-table.php</a></li>
<li><a href="#trunkwpadminincludesclasswptermslisttablephp">trunk/wp-admin/includes/class-wp-terms-list-table.php</a></li>
<li><a href="#trunkwpadminincludesmediaphp">trunk/wp-admin/includes/media.php</a></li>
<li><a href="#trunkwpadminincludesmetaboxesphp">trunk/wp-admin/includes/meta-boxes.php</a></li>
<li><a href="#trunkwpadminincludespostphp">trunk/wp-admin/includes/post.php</a></li>
<li><a href="#trunkwpadminincludesscreenphp">trunk/wp-admin/includes/screen.php</a></li>
<li><a href="#trunkwpadminmenuphp">trunk/wp-admin/menu.php</a></li>
<li><a href="#trunkwpadminpostphp">trunk/wp-admin/post.php</a></li>
<li><a href="#trunkwpincludesadminbarphp">trunk/wp-includes/admin-bar.php</a></li>
<li><a href="#trunkwpincludeslinktemplatephp">trunk/wp-includes/link-template.php</a></li>
<li><a href="#trunkwpincludesmediaphp">trunk/wp-includes/media.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincsswpadmincss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/wp-admin.css (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin.css        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-admin/css/wp-admin.css        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -3759,7 +3759,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> .upload-php .fixed .column-parent {
</span><del>-        width: 25%;
</del><ins>+        width: 15%;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> .js .html-uploader #plupload-upload-ui {
</span><span class="lines">@@ -3938,7 +3938,8 @@
</span><span class="cx">         margin: 8px 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.describe .imgedit-wrap table td {
</del><ins>+.describe .imgedit-wrap table td,
+.wp_attachment_holder .imgedit-wrap table td {
</ins><span class="cx">         vertical-align: top;
</span><span class="cx">         padding-top: 0;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadmineditformadvancedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-form-advanced.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-form-advanced.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-admin/edit-form-advanced.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx">          9 =&gt; sprintf( __('Page scheduled for: &lt;strong&gt;%1$s&lt;/strong&gt;. &lt;a target=&quot;_blank&quot; href=&quot;%2$s&quot;&gt;Preview page&lt;/a&gt;'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post-&gt;post_date ) ), esc_url( get_permalink($post_ID) ) ),
</span><span class="cx">         10 =&gt; sprintf( __('Page draft updated. &lt;a target=&quot;_blank&quot; href=&quot;%s&quot;&gt;Preview page&lt;/a&gt;'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
</span><span class="cx"> );
</span><ins>+$messages['attachment'] = array_fill( 1, 10, __( 'Media attachment updated' ) ); // Hack, for now.
</ins><span class="cx"> 
</span><span class="cx"> $messages = apply_filters( 'post_updated_messages', $messages );
</span><span class="cx"> 
</span><span class="lines">@@ -77,7 +78,7 @@
</span><span class="cx"> 
</span><span class="cx"> $notice = false;
</span><span class="cx"> $form_extra = '';
</span><del>-if ( 'auto-draft' == $post-&gt;post_status ) {
</del><ins>+if ( 'auto-draft' == get_post_status( $post ) ) {
</ins><span class="cx">         if ( 'edit' == $action )
</span><span class="cx">                 $post-&gt;post_title = '';
</span><span class="cx">         $autosave = false;
</span><span class="lines">@@ -106,13 +107,21 @@
</span><span class="cx"> // All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
</span><span class="cx"> require_once('./includes/meta-boxes.php');
</span><span class="cx"> 
</span><del>-add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', null, 'side', 'core');
</del><ins>+if ( 'attachment' == $post_type ) {
+        wp_enqueue_script( 'image-edit' );
+        wp_enqueue_style( 'imgareaselect' );
+        add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' );
+        add_meta_box( 'attachmentdata', __('Attachment Page Content'), 'attachment_data_meta_box', null, 'normal', 'core' );
+        add_action( 'edit_form_after_title', 'edit_form_image_editor' );
+} else {
+        add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core' );
+}
</ins><span class="cx"> 
</span><span class="cx"> if ( current_theme_supports( 'post-formats' ) &amp;&amp; post_type_supports( $post_type, 'post-formats' ) )
</span><span class="cx">         add_meta_box( 'formatdiv', _x( 'Format', 'post format' ), 'post_format_meta_box', null, 'side', 'core' );
</span><span class="cx"> 
</span><span class="cx"> // all taxonomies
</span><del>-foreach ( get_object_taxonomies($post_type) as $tax_name ) {
</del><ins>+foreach ( get_object_taxonomies( $post ) as $tax_name ) {
</ins><span class="cx">         $taxonomy = get_taxonomy($tax_name);
</span><span class="cx">         if ( ! $taxonomy-&gt;show_ui )
</span><span class="cx">                 continue;
</span><span class="lines">@@ -144,10 +153,10 @@
</span><span class="cx"> if ( post_type_supports($post_type, 'comments') )
</span><span class="cx">         add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', null, 'normal', 'core');
</span><span class="cx"> 
</span><del>-if ( ('publish' == $post-&gt;post_status || 'private' == $post-&gt;post_status) &amp;&amp; post_type_supports($post_type, 'comments') )
</del><ins>+if ( ( 'publish' == get_post_status( $post ) || 'private' == get_post_status( $post ) ) &amp;&amp; post_type_supports($post_type, 'comments') )
</ins><span class="cx">         add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core');
</span><span class="cx"> 
</span><del>-if ( !( 'pending' == $post-&gt;post_status &amp;&amp; !current_user_can( $post_type_object-&gt;cap-&gt;publish_posts ) ) )
</del><ins>+if ( ! ( 'pending' == get_post_status( $post ) &amp;&amp; ! current_user_can( $post_type_object-&gt;cap-&gt;publish_posts ) ) )
</ins><span class="cx">         add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core');
</span><span class="cx"> 
</span><span class="cx"> if ( post_type_supports($post_type, 'author') ) {
</span><span class="lines">@@ -269,7 +278,7 @@
</span><span class="cx"> &lt;input type=&quot;hidden&quot; id=&quot;active_post_lock&quot; value=&quot;&lt;?php echo esc_attr( implode( ':', $active_post_lock ) ); ?&gt;&quot; /&gt;
</span><span class="cx"> &lt;?php
</span><span class="cx"> }
</span><del>-if ( 'draft' != $post-&gt;post_status )
</del><ins>+if ( 'draft' != get_post_status( $post ) )
</ins><span class="cx">         wp_original_referer_field(true, 'previous');
</span><span class="cx"> 
</span><span class="cx"> echo $form_extra;
</span><span class="lines">@@ -296,10 +305,10 @@
</span><span class="cx"> if ( !empty($shortlink) )
</span><span class="cx">     $sample_permalink_html .= '&lt;input id=&quot;shortlink&quot; type=&quot;hidden&quot; value=&quot;' . esc_attr($shortlink) . '&quot; /&gt;&lt;a href=&quot;#&quot; class=&quot;button button-small&quot; onclick=&quot;prompt(&amp;#39;URL:&amp;#39;, jQuery(\'#shortlink\').val()); return false;&quot;&gt;' . __('Get Shortlink') . '&lt;/a&gt;';
</span><span class="cx"> 
</span><del>-if ( $post_type_object-&gt;public &amp;&amp; ! ( 'pending' == $post-&gt;post_status &amp;&amp; !current_user_can( $post_type_object-&gt;cap-&gt;publish_posts ) ) ) { ?&gt;
</del><ins>+if ( $post_type_object-&gt;public &amp;&amp; ! ( 'pending' == get_post_status( $post ) &amp;&amp; !current_user_can( $post_type_object-&gt;cap-&gt;publish_posts ) ) ) { ?&gt;
</ins><span class="cx">         &lt;div id=&quot;edit-slug-box&quot;&gt;
</span><span class="cx">         &lt;?php
</span><del>-                if ( ! empty($post-&gt;ID) &amp;&amp; ! empty($sample_permalink_html) &amp;&amp; 'auto-draft' != $post-&gt;post_status )
</del><ins>+                if ( $sample_permalink_html &amp;&amp; 'auto-draft' != get_post_status( $post ) )
</ins><span class="cx">                         echo $sample_permalink_html;
</span><span class="cx">         ?&gt;
</span><span class="cx">         &lt;/div&gt;
</span><span class="lines">@@ -310,10 +319,14 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
</span><span class="cx"> ?&gt;
</span><del>-&lt;/div&gt;
-&lt;?php } ?&gt;
</del><ins>+&lt;/div&gt;&lt;!-- /titlediv --&gt;
+&lt;?php
+}
</ins><span class="cx"> 
</span><del>-&lt;?php if ( post_type_supports($post_type, 'editor') ) { ?&gt;
</del><ins>+do_action( 'edit_form_after_title' );
+
+if ( post_type_supports($post_type, 'editor') ) {
+?&gt;
</ins><span class="cx"> &lt;div id=&quot;postdivrich&quot; class=&quot;postarea&quot;&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;?php wp_editor($post-&gt;post_content, 'content', array('dfw' =&gt; true, 'tabfocus_elements' =&gt; 'sample-permalink,post-preview') ); ?&gt;
</span><span class="lines">@@ -323,7 +336,7 @@
</span><span class="cx">         &lt;td class=&quot;autosave-info&quot;&gt;
</span><span class="cx">         &lt;span class=&quot;autosave-message&quot;&gt;&amp;nbsp;&lt;/span&gt;
</span><span class="cx"> &lt;?php
</span><del>-        if ( 'auto-draft' != $post-&gt;post_status ) {
</del><ins>+        if ( 'auto-draft' != get_post_status( $post ) ) {
</ins><span class="cx">                 echo '&lt;span id=&quot;last-edit&quot;&gt;';
</span><span class="cx">                 if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
</span><span class="cx">                         $last_user = get_userdata($last_id);
</span></span></pre></div>
<a id="trunkwpadminedittagsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/edit-tags.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/edit-tags.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-admin/edit-tags.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx"> $title = $tax-&gt;labels-&gt;name;
</span><span class="cx"> 
</span><span class="cx"> if ( 'post' != $post_type ) {
</span><del>-        $parent_file = &quot;edit.php?post_type=$post_type&quot;;
</del><ins>+        $parent_file = ( 'attachment' == $post_type ) ? 'upload.php' : &quot;edit.php?post_type=$post_type&quot;;
</ins><span class="cx">         $submenu_file = &quot;edit-tags.php?taxonomy=$taxonomy&amp;amp;post_type=$post_type&quot;;
</span><span class="cx"> } else if ( 'link_category' == $tax-&gt;name ) {
</span><span class="cx">         $parent_file = 'link-manager.php';
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpmedialisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-media-list-table.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-media-list-table.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-admin/includes/class-wp-media-list-table.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -132,7 +132,26 @@
</span><span class="cx">                 /* translators: column name */
</span><span class="cx">                 $posts_columns['title'] = _x( 'File', 'column name' );
</span><span class="cx">                 $posts_columns['author'] = __( 'Author' );
</span><del>-                //$posts_columns['tags'] = _x( 'Tags', 'column name' );
</del><ins>+
+                $taxonomies = array();
+
+                $taxonomies = get_taxonomies_for_attachments( 'objects' );
+                $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' =&gt; true ), 'and', 'name' );
+
+                $taxonomies = apply_filters( 'manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment' );
+                $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
+
+                foreach ( $taxonomies as $taxonomy ) {
+                        if ( 'category' == $taxonomy )
+                                $column_key = 'categories';
+                        elseif ( 'post_tag' == $taxonomy )
+                                $column_key = 'tags';
+                        else
+                                $column_key = 'taxonomy-' . $taxonomy;
+
+                        $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )-&gt;labels-&gt;name;
+                }
+
</ins><span class="cx">                 /* translators: column name */
</span><span class="cx">                 if ( !$this-&gt;detached ) {
</span><span class="cx">                         $posts_columns['parent'] = _x( 'Attached to', 'column name' );
</span><span class="lines">@@ -251,23 +270,6 @@
</span><span class="cx"> &lt;?php
</span><span class="cx">                 break;
</span><span class="cx"> 
</span><del>-        case 'tags':
-?&gt;
-                &lt;td &lt;?php echo $attributes ?&gt;&gt;&lt;?php
-                $tags = get_the_tags();
-                if ( !empty( $tags ) ) {
-                        $out = array();
-                        foreach ( $tags as $c )
-                                $out[] = &quot;&lt;a href='edit.php?tag=$c-&gt;slug'&gt; &quot; . esc_html( sanitize_term_field( 'name', $c-&gt;name, $c-&gt;term_id, 'post_tag', 'display' ) ) . &quot;&lt;/a&gt;&quot;;
-                        echo join( ', ', $out );
-                } else {
-                        _e( 'No Tags' );
-                }
-?&gt;
-                &lt;/td&gt;
-&lt;?php
-                break;
-
</del><span class="cx">         case 'desc':
</span><span class="cx"> ?&gt;
</span><span class="cx">                 &lt;td &lt;?php echo $attributes ?&gt;&gt;&lt;?php echo has_excerpt() ? $post-&gt;post_excerpt : ''; ?&gt;&lt;/td&gt;
</span><span class="lines">@@ -339,6 +341,38 @@
</span><span class="cx">                 break;
</span><span class="cx"> 
</span><span class="cx">         default:
</span><ins>+                if ( 'categories' == $column_name )
+                        $taxonomy = 'category';
+                if ( 'tags' == $column_name )
+                        $taxonomy = 'post_tag';
+                elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
+                        $taxonomy = substr( $column_name, 9 );
+                else
+                        $taxonomy = false;
+
+                if ( $taxonomy ) {
+                        $taxonomy_object = get_taxonomy( $taxonomy );
+                        echo '&lt;td ' . $attributes . '&gt;';
+                        if ( $terms = get_the_terms( $post-&gt;ID, $taxonomy ) ) {
+                                $out = array();
+                                foreach ( $terms as $t ) {
+                                        $posts_in_term_qv = array();
+                                        $posts_in_term_qv['taxonomy'] = $taxonomy;
+                                        $posts_in_term_qv['term'] = $t-&gt;slug;
+
+                                        $out[] = sprintf( '&lt;a href=&quot;%s&quot;&gt;%s&lt;/a&gt;',
+                                                esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ),
+                                                esc_html( sanitize_term_field( 'name', $t-&gt;name, $t-&gt;term_id, $taxonomy, 'display' ) )
+                                        );
+                                }
+                                /* translators: used between list items, there is a space after the comma */
+                                echo join( __( ', ' ), $out );
+                        } else {
+                                echo '&amp;#8212;';
+                        }
+                        echo '&lt;/td&gt;';
+                        break;
+                }
</ins><span class="cx"> ?&gt;
</span><span class="cx">                 &lt;td &lt;?php echo $attributes ?&gt;&gt;
</span><span class="cx">                         &lt;?php do_action( 'manage_media_custom_column', $column_name, $id ); ?&gt;
</span></span></pre></div>
<a id="trunkwpadminincludesclasswptermslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-terms-list-table.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-terms-list-table.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-admin/includes/class-wp-terms-list-table.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -299,6 +299,9 @@
</span><span class="cx">                 if ( 'post' != $this-&gt;screen-&gt;post_type )
</span><span class="cx">                         $args['post_type'] = $this-&gt;screen-&gt;post_type;
</span><span class="cx"> 
</span><ins>+                if ( 'attachment' == $this-&gt;screen-&gt;post_type )
+                        return &quot;&lt;a href='&quot; . esc_url ( add_query_arg( $args, 'upload.php' ) ) . &quot;'&gt;$count&lt;/a&gt;&quot;;
+
</ins><span class="cx">                 return &quot;&lt;a href='&quot; . esc_url ( add_query_arg( $args, 'edit.php' ) ) . &quot;'&gt;$count&lt;/a&gt;&quot;;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpadminincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/media.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/media.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-admin/includes/media.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -857,9 +857,9 @@
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Filters input from media_upload_form_handler() and assigns a default
</span><del>- * post_title from the file name if none supplied. 
</del><ins>+ * post_title from the file name if none supplied.
</ins><span class="cx">  *
</span><del>- * Illustrates the use of the attachment_fields_to_save filter 
</del><ins>+ * Illustrates the use of the attachment_fields_to_save filter
</ins><span class="cx">  * which can be used to add default values to any field before saving to DB.
</span><span class="cx">  *
</span><span class="cx">  * @since 2.5.0
</span><span class="lines">@@ -2095,6 +2095,67 @@
</span><span class="cx">         echo '&lt;p&gt;' . sprintf( __( 'Sorry, you have used all of your storage quota of %s MB.' ), get_space_allowed() ) . '&lt;/p&gt;';
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Displays the image and editor in the post editor
+ *
+ * @since 3.5.0
+ */
+function edit_form_image_editor() {
+        $post = get_post();
+
+        $thumb_url = false;
+        if ( $attachment_id = intval( $post-&gt;ID ) )
+                $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 600 ), true );
+
+        $filename = esc_html( basename( $post-&gt;guid ) );
+        $title = esc_attr( $post-&gt;post_title );
+
+        $post_mime_types = get_post_mime_types();
+        $keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post-&gt;post_mime_type ) );
+        $type = array_shift( $keys );
+        $type_html = &quot;&lt;input type='hidden' id='type-of-$attachment_id' value='&quot; . esc_attr( $type ) . &quot;' /&gt;&quot;;
+
+        $media_dims = '';
+        $meta = wp_get_attachment_metadata( $post-&gt;ID );
+        if ( is_array( $meta ) &amp;&amp; array_key_exists( 'width', $meta ) &amp;&amp; array_key_exists( 'height', $meta ) )
+                $media_dims .= &quot;&lt;span id='media-dims-$post-&gt;ID'&gt;{$meta['width']}&amp;nbsp;&amp;times;&amp;nbsp;{$meta['height']}&lt;/span&gt; &quot;;
+        $media_dims = apply_filters( 'media_meta', $media_dims, $post );
+
+        $att_url = wp_get_attachment_url( $post-&gt;ID );
+
+        $image_edit_button = '';
+        if ( gd_edit_image_support( $post-&gt;post_mime_type ) ) {
+                $nonce = wp_create_nonce( &quot;image_editor-$post-&gt;ID&quot; );
+                $image_edit_button = &quot;&lt;input type='button' id='imgedit-open-btn-$post-&gt;ID' onclick='imageEdit.open( $post-&gt;ID, \&quot;$nonce\&quot; )' class='button' value='&quot; . esc_attr__( 'Edit Image' ) . &quot;' /&gt; &lt;img src='&quot; . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . &quot;' class='imgedit-wait-spin' alt='' /&gt;&quot;;
+        }
+
+         ?&gt;
+        &lt;div class=&quot;wp_attachment_holder&quot;&gt;
+                &lt;div class=&quot;imgedit-response&quot; id=&quot;imgedit-response-&lt;?php echo $attachment_id; ?&gt;&quot;&gt;&lt;/div&gt;
+
+                &lt;div class=&quot;wp_attachment_image&quot; id=&quot;media-head-&lt;?php echo $attachment_id; ?&gt;&quot;&gt;
+                        &lt;p&gt;&lt;img class=&quot;thumbnail&quot; src=&quot;&lt;?php echo $thumb_url[0]; ?&gt;&quot; style=&quot;max-width:100%&quot; width=&quot;&lt;?php echo $thumb_url[1]; ?&gt;&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
+                        &lt;p&gt;&lt;?php echo $image_edit_button; ?&gt;&lt;/p&gt;
+                &lt;/div&gt;
+                &lt;div style=&quot;display:none&quot; class=&quot;image-editor&quot; id=&quot;image-editor-&lt;?php echo $attachment_id; ?&gt;&quot;&gt;&lt;/div&gt;
+
+                &lt;div class=&quot;wp_attachment_details&quot;&gt;
+                        &lt;p&gt;
+                                &lt;label for=&quot;attachment_url&quot;&gt;&lt;strong&gt;&lt;?php _e( 'File URL' ); ?&gt;&lt;/strong&gt;&lt;/label&gt;&lt;br /&gt;
+                                &lt;input type=&quot;text&quot; class=&quot;widefat urlfield&quot; readonly=&quot;readonly&quot; name=&quot;attachment_url&quot; value=&quot;&lt;?php echo esc_attr($att_url); ?&gt;&quot; /&gt;&lt;br /&gt;
+                        &lt;/p&gt;
+                        &lt;p&gt;&lt;strong&gt;&lt;?php _e( 'File name:' ); ?&gt;&lt;/strong&gt; &lt;?php echo $filename; ?&gt;&lt;br /&gt;
+                        &lt;strong&gt;&lt;?php _e( 'File type:' ); ?&gt;&lt;/strong&gt; &lt;?php echo $post-&gt;post_mime_type; ?&gt;
+                        &lt;?php
+                                if ( $media_dims )
+                                        echo '&lt;br /&gt;&lt;strong&gt;' . __( 'Dimensions:' ) . '&lt;/strong&gt; ' . $media_dims;
+                        ?&gt;
+                        &lt;/p&gt;
+                &lt;/div&gt;
+        &lt;/div&gt;
+        &lt;?php
+}
+
</ins><span class="cx"> add_filter( 'async_upload_image', 'get_media_item', 10, 2 );
</span><span class="cx"> add_filter( 'async_upload_audio', 'get_media_item', 10, 2 );
</span><span class="cx"> add_filter( 'async_upload_video', 'get_media_item', 10, 2 );
</span></span></pre></div>
<a id="trunkwpadminincludesmetaboxesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/meta-boxes.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/meta-boxes.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-admin/includes/meta-boxes.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> &lt;?php endif; // public post type ?&gt;
</span><span class="cx"> &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
</span><del>-&lt;/div&gt;&lt;?php // /minor-publishing-actions ?&gt;
</del><ins>+&lt;/div&gt;&lt;!-- #minor-publishing-actions --&gt;
</ins><span class="cx"> 
</span><span class="cx"> &lt;div id=&quot;misc-publishing-actions&quot;&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;?php } ?&gt;
</span><del>-&lt;/div&gt;&lt;?php // /misc-pub-section ?&gt;
</del><ins>+&lt;/div&gt;&lt;!-- .misc-pub-section --&gt;
</ins><span class="cx"> 
</span><span class="cx"> &lt;div class=&quot;misc-pub-section&quot; id=&quot;visibility&quot;&gt;
</span><span class="cx"> &lt;?php _e('Visibility:'); ?&gt; &lt;span id=&quot;post-visibility-display&quot;&gt;&lt;?php
</span><span class="lines">@@ -148,7 +148,7 @@
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> &lt;?php } ?&gt;
</span><span class="cx"> 
</span><del>-&lt;/div&gt;&lt;?php // /misc-pub-section ?&gt;
</del><ins>+&lt;/div&gt;&lt;!-- .misc-pub-section --&gt;
</ins><span class="cx"> 
</span><span class="cx"> &lt;?php
</span><span class="cx"> // translators: Publish box date format, see http://php.net/date
</span><span class="lines">@@ -230,6 +230,106 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Display attachment submit form fields.
+ *
+ * @since 3.5.0
+ *
+ * @param object $post
+ */
+function attachment_submit_meta_box( $post ) {
+        global $action;
+
+        $post_type = $post-&gt;post_type;
+        $post_type_object = get_post_type_object($post_type);
+        $can_publish = current_user_can($post_type_object-&gt;cap-&gt;publish_posts);
+?&gt;
+&lt;div class=&quot;submitbox&quot; id=&quot;submitpost&quot;&gt;
+
+&lt;div id=&quot;minor-publishing&quot;&gt;
+
+&lt;?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?&gt;
+&lt;div style=&quot;display:none;&quot;&gt;
+&lt;?php submit_button( __( 'Save' ), 'button', 'save' ); ?&gt;
+&lt;/div&gt;
+
+
+&lt;div id=&quot;misc-publishing-actions&quot;&gt;
+        &lt;?php
+        // translators: Publish box date format, see http://php.net/date
+        $datef = __( 'M j, Y @ G:i' );
+        $stamp = __('Uploaded on: &lt;b&gt;%1$s&lt;/b&gt;');
+        $date = date_i18n( $datef, strtotime( $post-&gt;post_date ) );
+        ?&gt;
+        &lt;div class=&quot;misc-pub-section curtime&quot;&gt;
+                &lt;span id=&quot;timestamp&quot;&gt;&lt;?php printf($stamp, $date); ?&gt;&lt;/span&gt;
+        &lt;/div&gt;&lt;!-- .misc-pub-section --&gt;
+
+        &lt;?php do_action('attachment_submitbox_misc_actions'); ?&gt;
+&lt;/div&gt;&lt;!-- #misc-publishing-actions --&gt;
+&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;&lt;!-- #minor-publishing --&gt;
+
+&lt;div id=&quot;major-publishing-actions&quot;&gt;
+        &lt;div id=&quot;delete-action&quot;&gt;
+        &lt;?php
+        if ( current_user_can( 'delete_post', $post-&gt;ID ) )
+                if ( EMPTY_TRASH_DAYS &amp;&amp; MEDIA_TRASH ) {
+                        echo &quot;&lt;a class='submitdelete deletion' href='&quot; . get_delete_post_link( $post-&gt;ID ) . &quot;'&gt;&quot; . __( 'Trash' ) . &quot;&lt;/a&gt;&quot;;
+                } else {
+                        $delete_ays = ! MEDIA_TRASH ? &quot; onclick='return showNotice.warn();'&quot; : '';
+                        echo  &quot;&lt;a class='submitdelete deletion'$delete_ays href='&quot; . get_delete_post_link( $post-&gt;ID, null, true ) . &quot;''&gt;&quot; . __( 'Delete Permanently' ) . &quot;&lt;/a&gt;&quot;;
+                }
+        ?&gt;
+        &lt;/div&gt;
+
+        &lt;div id=&quot;publishing-action&quot;&gt;
+                &lt;img src=&quot;&lt;?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?&gt;&quot; class=&quot;ajax-loading&quot; id=&quot;ajax-loading&quot; alt=&quot;&quot; /&gt;
+                &lt;input name=&quot;original_publish&quot; type=&quot;hidden&quot; id=&quot;original_publish&quot; value=&quot;&lt;?php esc_attr_e('Update') ?&gt;&quot; /&gt;
+                &lt;input name=&quot;save&quot; type=&quot;submit&quot; class=&quot;button-primary button-large&quot; id=&quot;publish&quot; accesskey=&quot;p&quot; value=&quot;&lt;?php esc_attr_e('Update') ?&gt;&quot; /&gt;
+        &lt;/div&gt;
+        &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
+&lt;/div&gt;&lt;!-- #major-publishing-actions --&gt;
+
+&lt;/div&gt;
+
+&lt;?php
+}
+
+/**
+ * Display attachment/media-specific information
+ *
+ * @since 3.5.0
+ *
+ * @param object $post
+ */
+function attachment_data_meta_box( $post ) {
+        $alt_text = get_post_meta( $post-&gt;ID, '_wp_attachment_image_alt', true );
+        $quicktags_settings = array( 'buttons' =&gt; 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' );
+        $editor_args = array(
+                'textarea_name' =&gt; 'content',
+                'textarea_rows' =&gt; 5,
+                'media_buttons' =&gt; false,
+                'tinymce' =&gt; false,
+                'quicktags' =&gt; $quicktags_settings,
+        );
+?&gt;
+&lt;p&gt;
+        &lt;label class=&quot;screen-reader-text&quot; for=&quot;content&quot;&gt;&lt;strong&gt;&lt;?php _e( 'Attachment Page Content' ); ?&gt;&lt;/strong&gt;&lt;/label&gt;
+        &lt;?php wp_editor( $post-&gt;post_content, 'attachment_content', $editor_args ); ?&gt;
+&lt;/p&gt;
+
+&lt;p&gt;
+        &lt;label for=&quot;attachment_caption&quot;&gt;&lt;strong&gt;&lt;?php _e( 'Caption' ); ?&gt;&lt;/strong&gt;&lt;/label&gt;&lt;br /&gt;
+        &lt;textarea class=&quot;widefat&quot; name=&quot;excerpt&quot; id=&quot;attachment_caption&quot;&gt;&lt;?php echo $post-&gt;post_excerpt; ?&gt;&lt;/textarea&gt;
+&lt;/p&gt;
+&lt;p&gt;
+        &lt;label for=&quot;attachment_alt&quot;&gt;&lt;strong&gt;&lt;?php _e( 'Alternative Text' ); ?&gt;&lt;/strong&gt;&lt;/label&gt;&lt;br /&gt;
+        &lt;input type=&quot;text&quot; class=&quot;widefat&quot; name=&quot;_wp_attachment_image_alt&quot; id=&quot;attachment_alt&quot; value=&quot;&lt;?php echo esc_attr( $alt_text ); ?&gt;&quot; /&gt;
+&lt;/p&gt;
+&lt;?php
+}
+
+/**
</ins><span class="cx">  * Display post format form elements.
</span><span class="cx">  *
</span><span class="cx">  * @since 3.1.0
</span></span></pre></div>
<a id="trunkwpadminincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/post.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/post.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-admin/includes/post.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -235,6 +235,16 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        // Attachment stuff
+        if ( 'attachment' == $post_data['post_type'] &amp;&amp; isset( $post_data['_wp_attachment_image_alt'] ) ) {
+                $image_alt = get_post_meta( $post_ID, '_wp_attachment_image_alt', true );
+                if ( $image_alt != stripslashes( $post_data['_wp_attachment_image_alt'] ) ) {
+                        $image_alt = wp_strip_all_tags( stripslashes( $post_data['_wp_attachment_image_alt'] ), true );
+                        // update_meta expects slashed
+                        update_post_meta( $post_ID, '_wp_attachment_image_alt', addslashes( $image_alt ) );
+                }
+        }
+
</ins><span class="cx">         add_meta( $post_ID );
</span><span class="cx"> 
</span><span class="cx">         update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']-&gt;ID );
</span><span class="lines">@@ -1064,7 +1074,7 @@
</span><span class="cx"> 
</span><span class="cx">         list($permalink, $post_name) = get_sample_permalink($post-&gt;ID, $new_title, $new_slug);
</span><span class="cx"> 
</span><del>-        if ( 'publish' == $post-&gt;post_status ) {
</del><ins>+        if ( 'publish' == get_post_status( $post ) ) {
</ins><span class="cx">                 $ptype = get_post_type_object($post-&gt;post_type);
</span><span class="cx">                 $view_post = $ptype-&gt;labels-&gt;view_item;
</span><span class="cx">                 $title = __('Click to edit this part of the permalink');
</span></span></pre></div>
<a id="trunkwpadminincludesscreenphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/screen.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/screen.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-admin/includes/screen.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -96,7 +96,7 @@
</span><span class="cx">         if ( $use_defaults ) {
</span><span class="cx">                 $hidden = array();
</span><span class="cx">                 if ( 'post' == $screen-&gt;base ) {
</span><del>-                        if ( 'post' == $screen-&gt;post_type || 'page' == $screen-&gt;post_type )
</del><ins>+                        if ( 'post' == $screen-&gt;post_type || 'page' == $screen-&gt;post_type || 'attachment' == $screen-&gt;post_type )
</ins><span class="cx">                                 $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
</span><span class="cx">                         else
</span><span class="cx">                                 $hidden = array( 'slugdiv' );
</span></span></pre></div>
<a id="trunkwpadminmenuphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/menu.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/menu.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-admin/menu.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -64,7 +64,14 @@
</span><span class="cx">         $submenu['upload.php'][5] = array( __('Library'), 'upload_files', 'upload.php');
</span><span class="cx">         /* translators: add new file */
</span><span class="cx">         $submenu['upload.php'][10] = array( _x('Add New', 'file'), 'upload_files', 'media-new.php');
</span><ins>+        foreach ( get_taxonomies_for_attachments( 'objects' ) as $tax ) {
+                if ( ! $tax-&gt;show_ui )
+                        continue;
</ins><span class="cx"> 
</span><ins>+                $submenu['upload.php'][$i++] = array( esc_attr( $tax-&gt;labels-&gt;menu_name ), $tax-&gt;cap-&gt;manage_terms, 'edit-tags.php?taxonomy=' . $tax-&gt;name . '&amp;amp;post_type=attachment' );
+        }
+        unset($tax);
+
</ins><span class="cx"> $menu[15] = array( __('Links'), 'manage_links', 'link-manager.php', '', 'menu-top menu-icon-links', 'menu-links', 'none' );
</span><span class="cx">         $submenu['link-manager.php'][5] = array( _x('All Links', 'admin menu'), 'manage_links', 'link-manager.php' );
</span><span class="cx">         /* translators: add new links */
</span></span></pre></div>
<a id="trunkwpadminpostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/post.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/post.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-admin/post.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -85,8 +85,12 @@
</span><span class="cx"> if ( ! $sendback ||
</span><span class="cx">      strpos( $sendback, 'post.php' ) !== false ||
</span><span class="cx">      strpos( $sendback, 'post-new.php' ) !== false ) {
</span><del>-        $sendback = admin_url( 'edit.php' );
-        $sendback .= ( ! empty( $post_type ) ) ? '?post_type=' . $post_type : '';
</del><ins>+        if ( 'attachment' == $post_type ) {
+                $sendback = admin_url( 'upload.php' );
+        } else {
+                $sendback = admin_url( 'edit.php' );
+                $sendback .= ( ! empty( $post_type ) ) ? '?post_type=' . $post_type : '';
+        }
</ins><span class="cx"> } else {
</span><span class="cx">         $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback );
</span><span class="cx"> }
</span><span class="lines">@@ -148,6 +152,10 @@
</span><span class="cx">                 $parent_file = &quot;edit.php&quot;;
</span><span class="cx">                 $submenu_file = &quot;edit.php&quot;;
</span><span class="cx">                 $post_new_file = &quot;post-new.php&quot;;
</span><ins>+        } elseif ( 'attachment' == $post_type ) {
+                $parent_file = 'upload.php';
+                $submenu_file = 'upload.php';
+                $post_new_file = 'media-new.php';
</ins><span class="cx">         } else {
</span><span class="cx">                 if ( isset( $post_type_object ) &amp;&amp; $post_type_object-&gt;show_in_menu &amp;&amp; $post_type_object-&gt;show_in_menu !== true )
</span><span class="cx">                         $parent_file = $post_type_object-&gt;show_in_menu;
</span></span></pre></div>
<a id="trunkwpincludesadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/admin-bar.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/admin-bar.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-includes/admin-bar.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -487,22 +487,20 @@
</span><span class="cx"> 
</span><span class="cx">         $cpts = (array) get_post_types( array( 'show_in_admin_bar' =&gt; true ), 'objects' );
</span><span class="cx"> 
</span><del>-        if ( isset( $cpts['post'] ) &amp;&amp; current_user_can( $cpts['post']-&gt;cap-&gt;edit_posts ) ) {
</del><ins>+        if ( isset( $cpts['post'] ) &amp;&amp; current_user_can( $cpts['post']-&gt;cap-&gt;edit_posts ) )
</ins><span class="cx">                 $actions[ 'post-new.php' ] = array( $cpts['post']-&gt;labels-&gt;name_admin_bar, 'new-post' );
</span><del>-                unset( $cpts['post'] );
-        }
</del><span class="cx"> 
</span><del>-        if ( current_user_can( 'upload_files' ) )
-                $actions[ 'media-new.php' ] = array( _x( 'Media', 'add new from admin bar' ), 'new-media' );
</del><ins>+        if ( isset( $cpts['attachment'] ) &amp;&amp; current_user_can( 'upload_files' ) )
+                $actions[ 'media-new.php' ] = array( $cpts['attachment']-&gt;labels-&gt;name_admin_bar, 'new-media' );
</ins><span class="cx"> 
</span><span class="cx">         if ( current_user_can( 'manage_links' ) )
</span><span class="cx">                 $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' );
</span><span class="cx"> 
</span><del>-        if ( isset( $cpts['page'] ) &amp;&amp; current_user_can( $cpts['page']-&gt;cap-&gt;edit_posts ) ) {
</del><ins>+        if ( isset( $cpts['page'] ) &amp;&amp; current_user_can( $cpts['page']-&gt;cap-&gt;edit_posts ) )
</ins><span class="cx">                 $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']-&gt;labels-&gt;name_admin_bar, 'new-page' );
</span><del>-                unset( $cpts['page'] );
-        }
</del><span class="cx"> 
</span><ins>+        unset( $cpts['post'], $cpts['page'], $cpts['attachment'] );
+
</ins><span class="cx">         // Add any additional custom post types.
</span><span class="cx">         foreach ( $cpts as $cpt ) {
</span><span class="cx">                 if ( ! current_user_can( $cpt-&gt;cap-&gt;edit_posts ) )
</span></span></pre></div>
<a id="trunkwpincludeslinktemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/link-template.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/link-template.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-includes/link-template.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx">         if ( $post-&gt;post_type == 'page' )
</span><span class="cx">                 return get_page_link($post-&gt;ID, $leavename, $sample);
</span><span class="cx">         elseif ( $post-&gt;post_type == 'attachment' )
</span><del>-                return get_attachment_link($post-&gt;ID);
</del><ins>+                return get_attachment_link( $post-&gt;ID, $leavename );
</ins><span class="cx">         elseif ( in_array($post-&gt;post_type, get_post_types( array('_builtin' =&gt; false) ) ) )
</span><span class="cx">                 return get_post_permalink($post-&gt;ID, $leavename, $sample);
</span><span class="cx"> 
</span><span class="lines">@@ -292,9 +292,10 @@
</span><span class="cx">  * @since 2.0.0
</span><span class="cx">  *
</span><span class="cx">  * @param mixed $post Optional. Post ID or object.
</span><ins>+ * @param bool $leavename Optional. Leave name.
</ins><span class="cx">  * @return string
</span><span class="cx">  */
</span><del>-function get_attachment_link( $post = null ) {
</del><ins>+function get_attachment_link( $post = null, $leavename = false ) {
</ins><span class="cx">         global $wp_rewrite;
</span><span class="cx"> 
</span><span class="cx">         $link = false;
</span><span class="lines">@@ -314,7 +315,10 @@
</span><span class="cx">                         $name = $post-&gt;post_name;
</span><span class="cx"> 
</span><span class="cx">                 if ( strpos($parentlink, '?') === false )
</span><del>-                        $link = user_trailingslashit( trailingslashit($parentlink) . $name );
</del><ins>+                        $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' );
+
+                if ( ! $leavename )
+                        $link = str_replace( '%postname%', $name, $link );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ( ! $link )
</span></span></pre></div>
<a id="trunkwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/media.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/media.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-includes/media.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -986,6 +986,35 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Return all of the taxonomy names that are registered for attachments.
+ *
+ * Handles mime-type-specific taxonomies such as attachment:image and attachment:video.
+ *
+ * @since 3.5.0
+ * @see get_attachment_taxonomies()
+ * @uses get_taxonomies()
+ *
+ * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
+ * @return array The names of all taxonomy of $object_type.
+ */
+function get_taxonomies_for_attachments( $output = 'names' ) {
+        $taxonomies = array();
+        foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) {
+                foreach ( $taxonomy-&gt;object_type as $object_type ) {
+                        if ( 'attachment' == $object_type || 0 === strpos( $object_type, 'attachment:' ) ) {
+                                if ( 'names' == $output )
+                                        $taxonomies[] = $taxonomy-&gt;name;
+                                else
+                                        $taxonomies[ $taxonomy-&gt;name ] = $taxonomy;
+                                break;
+                        }
+                }
+        }
+
+        return $taxonomies;
+}
+
+/**
</ins><span class="cx">  * Check if the installed version of GD supports particular image type
</span><span class="cx">  *
</span><span class="cx">  * @since 2.9.0
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (21947 => 21948)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2012-09-21 22:27:51 UTC (rev 21947)
+++ trunk/wp-includes/post.php        2012-09-21 22:52:54 UTC (rev 21948)
</span><span class="lines">@@ -52,13 +52,16 @@
</span><span class="cx"> 
</span><span class="cx">         register_post_type( 'attachment', array(
</span><span class="cx">                 'labels' =&gt; array(
</span><del>-                        'name' =&gt; __( 'Media' ),
-                        'edit_item' =&gt; __( 'Edit Media' ),
</del><ins>+                        'name' =&gt; _x('Media', 'post type general name'),
+                        'name_admin_bar' =&gt; _x( 'Media', 'add new from admin bar' ),
+                        'add_new' =&gt; _x( 'Add New', 'add new media' ),
+                         'edit_item' =&gt; __( 'Edit Media' ),
+                         'view_item' =&gt; __( 'View Attachment Page' ),
</ins><span class="cx">                 ),
</span><span class="cx">                 'public' =&gt; true,
</span><del>-                'show_ui' =&gt; false,
</del><ins>+                'show_ui' =&gt; true,
</ins><span class="cx">                 '_builtin' =&gt; true, /* internal use only. don't use this when registering your own post type. */
</span><del>-                '_edit_link' =&gt; 'media.php?attachment_id=%d', /* internal use only. don't use this when registering your own post type. */
</del><ins>+                '_edit_link' =&gt; 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
</ins><span class="cx">                 'capability_type' =&gt; 'post',
</span><span class="cx">                 'map_meta_cap' =&gt; true,
</span><span class="cx">                 'hierarchical' =&gt; false,
</span><span class="lines">@@ -66,7 +69,7 @@
</span><span class="cx">                 'query_var' =&gt; false,
</span><span class="cx">                 'show_in_nav_menus' =&gt; false,
</span><span class="cx">                 'delete_with_user' =&gt; true,
</span><del>-                'supports' =&gt; array( 'comments', 'author' ),
</del><ins>+                'supports' =&gt; array( 'title', 'author', 'comments' ),
</ins><span class="cx">         ) );
</span><span class="cx"> 
</span><span class="cx">         register_post_type( 'revision', array(
</span><span class="lines">@@ -3768,13 +3771,12 @@
</span><span class="cx">         if ( ! in_array( $post_status, array( 'inherit', 'private' ) ) )
</span><span class="cx">                 $post_status = 'inherit';
</span><span class="cx"> 
</span><ins>+        if ( !empty($post_category) )
+                $post_category = array_filter($post_category); // Filter out empty terms
+
</ins><span class="cx">         // Make sure we set a valid category.
</span><del>-        if ( !isset($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
-                // 'post' requires at least one category.
-                if ( 'post' == $post_type )
-                        $post_category = array( get_option('default_category') );
-                else
-                        $post_category = array();
</del><ins>+        if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
+                $post_category = array();
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Are we updating or creating?
</span><span class="lines">@@ -3859,8 +3861,23 @@
</span><span class="cx">                 $wpdb-&gt;update( $wpdb-&gt;posts, compact(&quot;post_name&quot;), array( 'ID' =&gt; $post_ID ) );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        wp_set_post_categories($post_ID, $post_category);
</del><ins>+        if ( is_object_in_taxonomy($post_type, 'category') )
+                wp_set_post_categories( $post_ID, $post_category );
</ins><span class="cx"> 
</span><ins>+        if ( isset( $tags_input ) &amp;&amp; is_object_in_taxonomy($post_type, 'post_tag') )
+                wp_set_post_tags( $post_ID, $tags_input );
+
+        // support for all custom taxonomies
+        if ( !empty($tax_input) ) {
+                foreach ( $tax_input as $taxonomy =&gt; $tags ) {
+                        $taxonomy_obj = get_taxonomy($taxonomy);
+                        if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical.
+                                $tags = array_filter($tags);
+                        if ( current_user_can($taxonomy_obj-&gt;cap-&gt;assign_terms) )
+                                wp_set_post_terms( $post_ID, $tags, $taxonomy );
+                }
+        }
+
</ins><span class="cx">         if ( $file )
</span><span class="cx">                 update_attached_file( $post_ID, $file );
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>