<!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 => sprintf( __('Page scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview page</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
</span><span class="cx">         10 => sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), 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->post_status ) {
</del><ins>+if ( 'auto-draft' == get_post_status( $post ) ) {
</ins><span class="cx">         if ( 'edit' == $action )
</span><span class="cx">                 $post->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' ) && 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->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->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') )
</del><ins>+if ( ( 'publish' == get_post_status( $post ) || 'private' == get_post_status( $post ) ) && 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->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) )
</del><ins>+if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->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"> <input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" />
</span><span class="cx"> <?php
</span><span class="cx"> }
</span><del>-if ( 'draft' != $post->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 .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button button-small" onclick="prompt(&#39;URL:&#39;, jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
</span><span class="cx">
</span><del>-if ( $post_type_object->public && ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>
</del><ins>+if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>
</ins><span class="cx">         <div id="edit-slug-box">
</span><span class="cx">         <?php
</span><del>-                if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status )
</del><ins>+                if ( $sample_permalink_html && 'auto-draft' != get_post_status( $post ) )
</ins><span class="cx">                         echo $sample_permalink_html;
</span><span class="cx">         ?>
</span><span class="cx">         </div>
</span><span class="lines">@@ -310,10 +319,14 @@
</span><span class="cx"> <?php
</span><span class="cx"> wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
</span><span class="cx"> ?>
</span><del>-</div>
-<?php } ?>
</del><ins>+</div><!-- /titlediv -->
+<?php
+}
</ins><span class="cx">
</span><del>-<?php if ( post_type_supports($post_type, 'editor') ) { ?>
</del><ins>+do_action( 'edit_form_after_title' );
+
+if ( post_type_supports($post_type, 'editor') ) {
+?>
</ins><span class="cx"> <div id="postdivrich" class="postarea">
</span><span class="cx">
</span><span class="cx"> <?php wp_editor($post->post_content, 'content', array('dfw' => true, 'tabfocus_elements' => 'sample-permalink,post-preview') ); ?>
</span><span class="lines">@@ -323,7 +336,7 @@
</span><span class="cx">         <td class="autosave-info">
</span><span class="cx">         <span class="autosave-message">&nbsp;</span>
</span><span class="cx"> <?php
</span><del>-        if ( 'auto-draft' != $post->post_status ) {
</del><ins>+        if ( 'auto-draft' != get_post_status( $post ) ) {
</ins><span class="cx">                 echo '<span id="last-edit">';
</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->labels->name;
</span><span class="cx">
</span><span class="cx"> if ( 'post' != $post_type ) {
</span><del>-        $parent_file = "edit.php?post_type=$post_type";
</del><ins>+        $parent_file = ( 'attachment' == $post_type ) ? 'upload.php' : "edit.php?post_type=$post_type";
</ins><span class="cx">         $submenu_file = "edit-tags.php?taxonomy=$taxonomy&amp;post_type=$post_type";
</span><span class="cx"> } else if ( 'link_category' == $tax->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' => 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 )->labels->name;
+                }
+
</ins><span class="cx">                 /* translators: column name */
</span><span class="cx">                 if ( !$this->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"> <?php
</span><span class="cx">                 break;
</span><span class="cx">
</span><del>-        case 'tags':
-?>
-                <td <?php echo $attributes ?>><?php
-                $tags = get_the_tags();
-                if ( !empty( $tags ) ) {
-                        $out = array();
-                        foreach ( $tags as $c )
-                                $out[] = "<a href='edit.php?tag=$c->slug'> " . esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'post_tag', 'display' ) ) . "</a>";
-                        echo join( ', ', $out );
-                } else {
-                        _e( 'No Tags' );
-                }
-?>
-                </td>
-<?php
-                break;
-
</del><span class="cx">         case 'desc':
</span><span class="cx"> ?>
</span><span class="cx">                 <td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
</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 '<td ' . $attributes . '>';
+                        if ( $terms = get_the_terms( $post->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->slug;
+
+                                        $out[] = sprintf( '<a href="%s">%s</a>',
+                                                esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ),
+                                                esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
+                                        );
+                                }
+                                /* translators: used between list items, there is a space after the comma */
+                                echo join( __( ', ' ), $out );
+                        } else {
+                                echo '&#8212;';
+                        }
+                        echo '</td>';
+                        break;
+                }
</ins><span class="cx"> ?>
</span><span class="cx">                 <td <?php echo $attributes ?>>
</span><span class="cx">                         <?php do_action( 'manage_media_custom_column', $column_name, $id ); ?>
</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->screen->post_type )
</span><span class="cx">                         $args['post_type'] = $this->screen->post_type;
</span><span class="cx">
</span><ins>+                if ( 'attachment' == $this->screen->post_type )
+                        return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>";
+
</ins><span class="cx">                 return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>";
</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 '<p>' . sprintf( __( 'Sorry, you have used all of your storage quota of %s MB.' ), get_space_allowed() ) . '</p>';
</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->ID ) )
+                $thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 600 ), true );
+
+        $filename = esc_html( basename( $post->guid ) );
+        $title = esc_attr( $post->post_title );
+
+        $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 ) . "' />";
+
+        $media_dims = '';
+        $meta = wp_get_attachment_metadata( $post->ID );
+        if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) )
+                $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
+        $media_dims = apply_filters( 'media_meta', $media_dims, $post );
+
+        $att_url = wp_get_attachment_url( $post->ID );
+
+        $image_edit_button = '';
+        if ( gd_edit_image_support( $post->post_mime_type ) ) {
+                $nonce = wp_create_nonce( "image_editor-$post->ID" );
+                $image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <img src='" . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . "' class='imgedit-wait-spin' alt='' />";
+        }
+
+         ?>
+        <div class="wp_attachment_holder">
+                <div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div>
+
+                <div class="wp_attachment_image" id="media-head-<?php echo $attachment_id; ?>">
+                        <p><img class="thumbnail" src="<?php echo $thumb_url[0]; ?>" style="max-width:100%" width="<?php echo $thumb_url[1]; ?>" alt="" /></p>
+                        <p><?php echo $image_edit_button; ?></p>
+                </div>
+                <div style="display:none" class="image-editor" id="image-editor-<?php echo $attachment_id; ?>"></div>
+
+                <div class="wp_attachment_details">
+                        <p>
+                                <label for="attachment_url"><strong><?php _e( 'File URL' ); ?></strong></label><br />
+                                <input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" value="<?php echo esc_attr($att_url); ?>" /><br />
+                        </p>
+                        <p><strong><?php _e( 'File name:' ); ?></strong> <?php echo $filename; ?><br />
+                        <strong><?php _e( 'File type:' ); ?></strong> <?php echo $post->post_mime_type; ?>
+                        <?php
+                                if ( $media_dims )
+                                        echo '<br /><strong>' . __( 'Dimensions:' ) . '</strong> ' . $media_dims;
+                        ?>
+                        </p>
+                </div>
+        </div>
+        <?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"> </div>
</span><span class="cx"> <?php endif; // public post type ?>
</span><span class="cx"> <div class="clear"></div>
</span><del>-</div><?php // /minor-publishing-actions ?>
</del><ins>+</div><!-- #minor-publishing-actions -->
</ins><span class="cx">
</span><span class="cx"> <div id="misc-publishing-actions">
</span><span class="cx">
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx"> </div>
</span><span class="cx">
</span><span class="cx"> <?php } ?>
</span><del>-</div><?php // /misc-pub-section ?>
</del><ins>+</div><!-- .misc-pub-section -->
</ins><span class="cx">
</span><span class="cx"> <div class="misc-pub-section" id="visibility">
</span><span class="cx"> <?php _e('Visibility:'); ?> <span id="post-visibility-display"><?php
</span><span class="lines">@@ -148,7 +148,7 @@
</span><span class="cx"> </div>
</span><span class="cx"> <?php } ?>
</span><span class="cx">
</span><del>-</div><?php // /misc-pub-section ?>
</del><ins>+</div><!-- .misc-pub-section -->
</ins><span class="cx">
</span><span class="cx"> <?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->post_type;
+        $post_type_object = get_post_type_object($post_type);
+        $can_publish = current_user_can($post_type_object->cap->publish_posts);
+?>
+<div class="submitbox" id="submitpost">
+
+<div id="minor-publishing">
+
+<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
+<div style="display:none;">
+<?php submit_button( __( 'Save' ), 'button', 'save' ); ?>
+</div>
+
+
+<div id="misc-publishing-actions">
+        <?php
+        // translators: Publish box date format, see http://php.net/date
+        $datef = __( 'M j, Y @ G:i' );
+        $stamp = __('Uploaded on: <b>%1$s</b>');
+        $date = date_i18n( $datef, strtotime( $post->post_date ) );
+        ?>
+        <div class="misc-pub-section curtime">
+                <span id="timestamp"><?php printf($stamp, $date); ?></span>
+        </div><!-- .misc-pub-section -->
+
+        <?php do_action('attachment_submitbox_misc_actions'); ?>
+</div><!-- #misc-publishing-actions -->
+<div class="clear"></div>
+</div><!-- #minor-publishing -->
+
+<div id="major-publishing-actions">
+        <div id="delete-action">
+        <?php
+        if ( current_user_can( 'delete_post', $post->ID ) )
+                if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
+                        echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
+                } else {
+                        $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
+                        echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "''>" . __( 'Delete Permanently' ) . "</a>";
+                }
+        ?>
+        </div>
+
+        <div id="publishing-action">
+                <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="ajax-loading" alt="" />
+                <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
+                <input name="save" type="submit" class="button-primary button-large" id="publish" accesskey="p" value="<?php esc_attr_e('Update') ?>" />
+        </div>
+        <div class="clear"></div>
+</div><!-- #major-publishing-actions -->
+
+</div>
+
+<?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->ID, '_wp_attachment_image_alt', true );
+        $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' );
+        $editor_args = array(
+                'textarea_name' => 'content',
+                'textarea_rows' => 5,
+                'media_buttons' => false,
+                'tinymce' => false,
+                'quicktags' => $quicktags_settings,
+        );
+?>
+<p>
+        <label class="screen-reader-text" for="content"><strong><?php _e( 'Attachment Page Content' ); ?></strong></label>
+        <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
+</p>
+
+<p>
+        <label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br />
+        <textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
+</p>
+<p>
+        <label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
+        <input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php echo esc_attr( $alt_text ); ?>" />
+</p>
+<?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'] && 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']->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->ID, $new_title, $new_slug);
</span><span class="cx">
</span><del>-        if ( 'publish' == $post->post_status ) {
</del><ins>+        if ( 'publish' == get_post_status( $post ) ) {
</ins><span class="cx">                 $ptype = get_post_type_object($post->post_type);
</span><span class="cx">                 $view_post = $ptype->labels->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->base ) {
</span><del>-                        if ( 'post' == $screen->post_type || 'page' == $screen->post_type )
</del><ins>+                        if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->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->show_ui )
+                        continue;
</ins><span class="cx">
</span><ins>+                $submenu['upload.php'][$i++] = array( esc_attr( $tax->labels->menu_name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name . '&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 = "edit.php";
</span><span class="cx">                 $submenu_file = "edit.php";
</span><span class="cx">                 $post_new_file = "post-new.php";
</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 ) && $post_type_object->show_in_menu && $post_type_object->show_in_menu !== true )
</span><span class="cx">                         $parent_file = $post_type_object->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' => true ), 'objects' );
</span><span class="cx">
</span><del>-        if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->edit_posts ) ) {
</del><ins>+        if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->edit_posts ) )
</ins><span class="cx">                 $actions[ 'post-new.php' ] = array( $cpts['post']->labels->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'] ) && current_user_can( 'upload_files' ) )
+                $actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->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'] ) && current_user_can( $cpts['page']->cap->edit_posts ) ) {
</del><ins>+        if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->edit_posts ) )
</ins><span class="cx">                 $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->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->cap->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->post_type == 'page' )
</span><span class="cx">                 return get_page_link($post->ID, $leavename, $sample);
</span><span class="cx">         elseif ( $post->post_type == 'attachment' )
</span><del>-                return get_attachment_link($post->ID);
</del><ins>+                return get_attachment_link( $post->ID, $leavename );
</ins><span class="cx">         elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) )
</span><span class="cx">                 return get_post_permalink($post->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->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->object_type as $object_type ) {
+                        if ( 'attachment' == $object_type || 0 === strpos( $object_type, 'attachment:' ) ) {
+                                if ( 'names' == $output )
+                                        $taxonomies[] = $taxonomy->name;
+                                else
+                                        $taxonomies[ $taxonomy->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' => array(
</span><del>-                        'name' => __( 'Media' ),
-                        'edit_item' => __( 'Edit Media' ),
</del><ins>+                        'name' => _x('Media', 'post type general name'),
+                        'name_admin_bar' => _x( 'Media', 'add new from admin bar' ),
+                        'add_new' => _x( 'Add New', 'add new media' ),
+                         'edit_item' => __( 'Edit Media' ),
+                         'view_item' => __( 'View Attachment Page' ),
</ins><span class="cx">                 ),
</span><span class="cx">                 'public' => true,
</span><del>-                'show_ui' => false,
</del><ins>+                'show_ui' => true,
</ins><span class="cx">                 '_builtin' => true, /* internal use only. don't use this when registering your own post type. */
</span><del>-                '_edit_link' => 'media.php?attachment_id=%d', /* internal use only. don't use this when registering your own post type. */
</del><ins>+                '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */
</ins><span class="cx">                 'capability_type' => 'post',
</span><span class="cx">                 'map_meta_cap' => true,
</span><span class="cx">                 'hierarchical' => false,
</span><span class="lines">@@ -66,7 +69,7 @@
</span><span class="cx">                 'query_var' => false,
</span><span class="cx">                 'show_in_nav_menus' => false,
</span><span class="cx">                 'delete_with_user' => true,
</span><del>-                'supports' => array( 'comments', 'author' ),
</del><ins>+                'supports' => 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->update( $wpdb->posts, compact("post_name"), array( 'ID' => $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 ) && 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 => $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->cap->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>