Make WordPress Core


Ignore:
Timestamp:
09/21/2012 10:52:54 PM (13 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/includes/meta-boxes.php

    r21944 r21948  
    5252<?php endif; // public post type ?>
    5353<div class="clear"></div>
    54 </div><?php // /minor-publishing-actions ?>
     54</div><!-- #minor-publishing-actions -->
    5555
    5656<div id="misc-publishing-actions">
     
    104104
    105105<?php } ?>
    106 </div><?php // /misc-pub-section ?>
     106</div><!-- .misc-pub-section -->
    107107
    108108<div class="misc-pub-section" id="visibility">
     
    149149<?php } ?>
    150150
    151 </div><?php // /misc-pub-section ?>
     151</div><!-- .misc-pub-section -->
    152152
    153153<?php
     
    227227</div>
    228228
     229<?php
     230}
     231
     232/**
     233 * Display attachment submit form fields.
     234 *
     235 * @since 3.5.0
     236 *
     237 * @param object $post
     238 */
     239function attachment_submit_meta_box( $post ) {
     240    global $action;
     241
     242    $post_type = $post->post_type;
     243    $post_type_object = get_post_type_object($post_type);
     244    $can_publish = current_user_can($post_type_object->cap->publish_posts);
     245?>
     246<div class="submitbox" id="submitpost">
     247
     248<div id="minor-publishing">
     249
     250<?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key ?>
     251<div style="display:none;">
     252<?php submit_button( __( 'Save' ), 'button', 'save' ); ?>
     253</div>
     254
     255
     256<div id="misc-publishing-actions">
     257    <?php
     258    // translators: Publish box date format, see http://php.net/date
     259    $datef = __( 'M j, Y @ G:i' );
     260    $stamp = __('Uploaded on: <b>%1$s</b>');
     261    $date = date_i18n( $datef, strtotime( $post->post_date ) );
     262    ?>
     263    <div class="misc-pub-section curtime">
     264        <span id="timestamp"><?php printf($stamp, $date); ?></span>
     265    </div><!-- .misc-pub-section -->
     266
     267    <?php do_action('attachment_submitbox_misc_actions'); ?>
     268</div><!-- #misc-publishing-actions -->
     269<div class="clear"></div>
     270</div><!-- #minor-publishing -->
     271
     272<div id="major-publishing-actions">
     273    <div id="delete-action">
     274    <?php
     275    if ( current_user_can( 'delete_post', $post->ID ) )
     276        if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
     277            echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
     278        } else {
     279            $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
     280            echo  "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, null, true ) . "''>" . __( 'Delete Permanently' ) . "</a>";
     281        }
     282    ?>
     283    </div>
     284
     285    <div id="publishing-action">
     286        <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="ajax-loading" alt="" />
     287        <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e('Update') ?>" />
     288        <input name="save" type="submit" class="button-primary button-large" id="publish" accesskey="p" value="<?php esc_attr_e('Update') ?>" />
     289    </div>
     290    <div class="clear"></div>
     291</div><!-- #major-publishing-actions -->
     292
     293</div>
     294
     295<?php
     296}
     297
     298/**
     299 * Display attachment/media-specific information
     300 *
     301 * @since 3.5.0
     302 *
     303 * @param object $post
     304 */
     305function attachment_data_meta_box( $post ) {
     306    $alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
     307    $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' );
     308    $editor_args = array(
     309        'textarea_name' => 'content',
     310        'textarea_rows' => 5,
     311        'media_buttons' => false,
     312        'tinymce' => false,
     313        'quicktags' => $quicktags_settings,
     314    );
     315?>
     316<p>
     317    <label class="screen-reader-text" for="content"><strong><?php _e( 'Attachment Page Content' ); ?></strong></label>
     318    <?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?>
     319</p>
     320
     321<p>
     322    <label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br />
     323    <textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea>
     324</p>
     325<p>
     326    <label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
     327    <input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php echo esc_attr( $alt_text ); ?>" />
     328</p>
    229329<?php
    230330}
Note: See TracChangeset for help on using the changeset viewer.