Make WordPress Core


Ignore:
Timestamp:
09/21/2012 10:52:54 PM (12 years ago)
Author:
nacin
Message:

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 #21391.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-form-advanced.php

    r21944 r21948  
    6464    10 => sprintf( __('Page draft updated. <a target="_blank" href="%s">Preview page</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
    6565);
     66$messages['attachment'] = array_fill( 1, 10, __( 'Media attachment updated' ) ); // Hack, for now.
    6667
    6768$messages = apply_filters( 'post_updated_messages', $messages );
     
    7879$notice = false;
    7980$form_extra = '';
    80 if ( 'auto-draft' == $post->post_status ) {
     81if ( 'auto-draft' == get_post_status( $post ) ) {
    8182    if ( 'edit' == $action )
    8283        $post->post_title = '';
     
    107108require_once('./includes/meta-boxes.php');
    108109
    109 add_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', null, 'side', 'core');
     110if ( 'attachment' == $post_type ) {
     111    wp_enqueue_script( 'image-edit' );
     112    wp_enqueue_style( 'imgareaselect' );
     113    add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' );
     114    add_meta_box( 'attachmentdata', __('Attachment Page Content'), 'attachment_data_meta_box', null, 'normal', 'core' );
     115    add_action( 'edit_form_after_title', 'edit_form_image_editor' );
     116} else {
     117    add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core' );
     118}
    110119
    111120if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) )
     
    113122
    114123// all taxonomies
    115 foreach ( get_object_taxonomies($post_type) as $tax_name ) {
     124foreach ( get_object_taxonomies( $post ) as $tax_name ) {
    116125    $taxonomy = get_taxonomy($tax_name);
    117126    if ( ! $taxonomy->show_ui )
     
    145154    add_meta_box('commentstatusdiv', __('Discussion'), 'post_comment_status_meta_box', null, 'normal', 'core');
    146155
    147 if ( ('publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') )
     156if ( ( 'publish' == get_post_status( $post ) || 'private' == get_post_status( $post ) ) && post_type_supports($post_type, 'comments') )
    148157    add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', null, 'normal', 'core');
    149158
    150 if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) )
     159if ( ! ( 'pending' == get_post_status( $post ) && ! current_user_can( $post_type_object->cap->publish_posts ) ) )
    151160    add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', null, 'normal', 'core');
    152161
     
    270279<?php
    271280}
    272 if ( 'draft' != $post->post_status )
     281if ( 'draft' != get_post_status( $post ) )
    273282    wp_original_referer_field(true, 'previous');
    274283
     
    297306    $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>';
    298307
    299 if ( $post_type_object->public && ! ( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>
     308if ( $post_type_object->public && ! ( 'pending' == get_post_status( $post ) && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>
    300309    <div id="edit-slug-box">
    301310    <?php
    302         if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status )
     311        if ( $sample_permalink_html && 'auto-draft' != get_post_status( $post ) )
    303312            echo $sample_permalink_html;
    304313    ?>
     
    311320wp_nonce_field( 'samplepermalink', 'samplepermalinknonce', false );
    312321?>
    313 </div>
    314 <?php } ?>
    315 
    316 <?php if ( post_type_supports($post_type, 'editor') ) { ?>
     322</div><!-- /titlediv -->
     323<?php
     324}
     325
     326do_action( 'edit_form_after_title' );
     327
     328if ( post_type_supports($post_type, 'editor') ) {
     329?>
    317330<div id="postdivrich" class="postarea">
    318331
     
    324337    <span class="autosave-message">&nbsp;</span>
    325338<?php
    326     if ( 'auto-draft' != $post->post_status ) {
     339    if ( 'auto-draft' != get_post_status( $post ) ) {
    327340        echo '<span id="last-edit">';
    328341        if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
Note: See TracChangeset for help on using the changeset viewer.